sticky-ts
sticky-ts is a library for sticky elements written in vanilla javascript. With this library you can easily set sticky elements on your website. It's also responsive.
Features
- No dependencies
- The safety of TypeScript and the minimalism of vanilla JavaScript
- Lightweight
- You may sticky an element the entire page or a specific container
- No additional CSS needed
Install
npm install sticky-ts
Usage
Simply include
<script src="sticky.min.js"></script>
Then have element
<div class="selector">Sticky element</div>
Initialize with javascript
var sticky = new Sticky('.selector');
CommonJS
var Sticky = require('sticky-js');
var sticky = new Sticky('.selector');
Sticky to the nearest parent container with [data-sticky-container]
<div data-sticky-container>
<div class="selector">Sticky element</div>
</div>
List of options available here.
Browser compatibility
Library is using ECMAScript 5 features. Full support available on caniuse.
- IE 9+
- Chrome 23+
- Firefox 21+
- Safari 6+
- Opera 15+
If you need this library working with older browsers you should use ECMAScript 5 polyfill.