JAVASCRIPT
Stick elements to the viewport
All samples are using Ink.requireModules
, please read how to use it at Ink.requireModules section
Ink.UI.Sticky makes an element "stick" to the screen and stay in the same place as the user scrolls. To use it, just select an element as you create the Sticky. As you scroll past it, it will stick to the top of the screen.
The activateInLayouts
option controls in what layouts this behaviour happens. By default, it is disabled for the small
and tiny
layouts. Pass a comma-separated string to choose just the layouts you need. You can use the offsetTop
option if you want it to keep some distance from the top of the screen. To avoid it going under the footer of your page, pass a selector to your footer as the bottomElement
option.
Method name | Description |
---|---|
new Sticky(selector, [options]) | Constructor |
selector
Element or selectoroptions
Options Options object.options.offsetBottom
Number of pixels of distance from the bottomElement. Defaults to 0.options.offsetTop
Number of pixels of distance from the topElement. Defaults to 0.options.inlineDimensions
Set to false to disable setting inline CSS dimensions. Use this if you want to use CSS to define your own dimensions. Defaults to true.options.inlinePosition
Set to false to disable setting inline CSS positions. Use this if you want to use CSS to define your own positioning. Defaults to true.options.wrapperClass
CSS class for the wrapper element. Defaults to 'ink-sticky-wrapper'.options.stickyClass
CSS class to stick the element to the screen. Defaults to 'ink-sticky-stuck'.options.topElement
CSS Selector that specifies a top element with which the component could collide.options.bottomElement
CSS Selector that specifies a bottom element with which the component could collide.options.activateInLayouts
Layouts in which the sticky behaviour is present. Pass an array or comma-separated string. Defaults to null, meaning it's enabled in every layout.Scroll down and see the sticky element stick to the top of your screen.
Demo
Duct tape or duck tape is cloth- or scrim-backed pressure-sensitive tape often coated with polyethylene. There are a variety of constructions using different backings and adhesives. One variation is gaffer tape designed to be cleanly removed, while duct tape is not. Another variation is heat-resistant duct tape useful for sealing heating/ventilation/air-conditioning (HVAC) ducts, produced because standard duct tape fails quickly when used on heating ducts. Duct tape is generally gray or black but also available in other colors.
During World War II, Revolite, then a division of Johnson & Johnson, developed an adhesive tape made from a rubber-based adhesive applied to a durable duck cloth backing. This tape resisted water and was used as sealing tape on ammunition cases during World War II.
I am a bottom element
Code