smooth-jumper
v0.0.4
Published
Enable smooth scrolling with and within DOM elements
Readme
smooth-jumper
A simple dependency-free JavaScript smooth scroll helper. Enables scrolling between any DOM elements, including within positioned and specifically styled elements. React friendly!
Demos
- Vanilla JS - Performs a smooth scroll example on the document.body.
- React - Performs a smooth scroll between three elements within an absolute element of fixed height.
Using
Via NPM:
npm install smooth-jumper --save.Or use the
lib/smooth-jumper.min.jsfile as an external script. Usage:smoothJump(containerEl, targetEl, options = {});Exports a single function with 3 arguments:
- The DOM container element
- The DOM target element
- Options - JS Object (options listed below)
Options
- 'easing' for easing types:
ease-in-out,ease-in-cubic,in-out-quint - 'duration': Integer (in milliseconds; default is 500ms)
- 'offset': Integer (in pixels; default is 0)
Building, useful commands
npm run dev- Entry route issrc/examples/index.js. This loads the React app with Hot Module Replacement (hot reloading).npm run build- Builds the NPM production version smooth-jumper.js in thelibdirectory.npm run build:min- Builds the minified production version smooth-jumper.min.js in thelibdirectory.npm run build:examples- Builds the static JavaScript and SCSS files. The following files are created in the *examplesdirectory:bundle.jsandstyle.css.npm run lint- Runs an ES lint to check everything's nice and tidy.
License
MIT
