Home > Scroll > sticky-js – Pure JavaScript Sticky Element Library
sticky-js - Pure JavaScript Sticky Element Library

sticky-js – Pure JavaScript Sticky Element Library

Sticky-js is a vanilla JavaScript library which makes DOM elements to be fix positioned relative. With this library you can easily set sticky elements on your website. It’s also responsive.

Features

  • Written in vanilla javascript, no dependencies needed
  • Lightweight (minified: ~6.08kb, gzipped: ~1.67kb)
  • It can be sticky to the entire page or to selected parent container
  • No additional CSS needed

Install

npm install sticky-js

bower install sticky.js

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>
  Website Demo

About admin