0.3.0 • Published 8 years ago

affixed v0.3.0

Weekly downloads
24
License
MIT
Repository
github
Last release
8 years ago

Affixed

Make something affix on scroll.

Usage

// es6 imports
import affixed from 'affixed';

// commonjs
// var affixed = require('affixed');

var menu = new affixed({
  element: document.getElementById('sticky-menu'),
  offset: 70,
  position: 'fixed',
  throttle: 10,
});
<div id="sticky-menu">
  ... content here
</div>

Parameters

ParamDescription
elementThe DOM element to affix.
offsetAmount of pixels to scroll before the element is affixed.
positionEither absolute fixed, or mirror positioning.
throttleSpecify the milliseconds to throttle the position updates.

Notes

absolute positioned element's are reposition on every scroll which may perform slow in some instances. You should set the position to fixed whenever possible. If your element is within a container that is positioned relative, you will need to set the position parameter to absolute.

You can also choose to use the mirror position option. A mirror will be created and added to the <body/> element as a clone of your specified element. This mirror will now act as the affixed element.

Lint

$ npm run lint

Dev

$ npm run dev

Build

$ npm run build

License

MIT © Vu Tran

0.3.0

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago