Skip to content

Latest commit

 

History

History
58 lines (33 loc) · 1.37 KB

README.md

File metadata and controls

58 lines (33 loc) · 1.37 KB

Sticky

Position:sticky that works.

$ npm install --save component-sticky

var Sticky = require('component-sticky');

var sticky = new Sticky(document.querySelector(".sticky-element"), {
	...
});

Options

offset: 0

How many pixels to skip from the top

within: parent

Any element, element selector or bounding box like {top: 0, bottom: 100 } or { top: element, bottom: element }

stickyClass: 'is-stuck'

Class to add when element is sticked

stubClass: 'sticky-stub'

Class to add to a spacer (placeholder when element is stuck)

bottomClass: 'is-bottom'

When element is parked bottom

topClass: 'is-top'

When element is parked on top

stack: null

Name of a group to stack elements within. undefined stack won’t relate element to any group

API

aticky.recalc()

Update position, sizes, sticking. Automatically called on window resize.

sticky.disable()

Unhook sticky controller from element. Called automatically when element is removed.

sticky.enable(

Enable previously disabled sticky element.

NPM