Sticky

Classes

ClassDescription
stickyThe sticky element
sticky-checkUse the sticky script to check if the sticky element is sticking
stickingWill be present when the sticky element is sticking

CSS Properties

PropertyDefaultDescription
top0The top position of the sticky element
bottom-The bottom position of the sticky element
left-The left position of the sticky element
right-The right position of the sticky element

CSS Variables

VariableDefaultDescription
--z-index15z-index value for the sticky element

sticky script

Use the sticky script like this:

import { sticky } from '@splendidlabz/styles/scripts'
sticky(selector, {
observerTimeout: 1000,
})
PropDefaultDescription
selectorundefinedObserves all elements with sticky-check inside this container. When undefined, it defaults to document.body.
observerTimeout1000The amount of time to watch for elements with sticky-check. To disable watching behaviour, set this to 0