This helper can be used to make elements of your website sticky. Means they stick to the top of the page. There is a css attribute which can do that "position: sticky" but it isn't currently supported by IE. It also works best in an "position: relative" context.
Yea, there are plugins out there that do that kind of stuff, but I don't see why I would add thounds of lines of code to do such a simple thing o.O
By default it will check if the given element is below the upper, visible border of the viewport, if not it will add two inline styles: "position: fixed; top: 0" which should do the trick for "position: absolute" elements. In addition to that it will set a css class "sticky" to the target element which allows you to have a finer control about your sticky element.
Offset, attributes and classname can be configured using the options.
NOTE: Make sure to use destroyStickyElement() when you delete your dom element to prevent memory leaks!
Generated using TypeDoc
Receives a sticky html element and destroys it in our internal logic and converts it back to its original state