1.0.7 • Published 6 years ago

stick-it v1.0.7

Weekly downloads
2
License
Beerware
Repository
github
Last release
6 years ago

Stick It

Lightweight plugin to stick an element of the DOM within a bounding container. Pure vanilla javascript. No dependencies.

Installation

yarn add stick-it

npm i stick-it

Usage

import stickIt from 'stick-it'

const Stky = new stickIt('.js-sticky')

Recommendation

The sticky element should be in position: absolute to avoid the content from jumping

Options

const Stky = new stickIt('.js-sticky', {
    // options, defaults listed
    
    bound: 'body',
    // the bounding container
    // can either be a string or a DOM element
    
    class: false,
    // the class to be added to the element when it is stuck
    
    offset: {
        top: 0,
        bottom: 0
    },
    // The top/bottom offset of the initial position by of number of pixels
    
    watchCSS: false
    // watches the content of :after of the element
    // activates if #element:after { content: 'stick-it' }
}
1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago