Package Exports
- scroll-element
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (scroll-element) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
scroll-element
Scroll to an element
Install
npm install scroll-element --save
Usage
Scroll-Element has 2 functions, scrollToElement
scrolls to an element within a container div with overflow scroll. scrollWindowToElement
just scrolls the window to the element. Check out the example for more info.
import { scrollToElement, scrollWindowToElement } from 'scroll-element'
let targetElement = document.getElementById('my-item')
scrollWindowToElement(targetElement, 1000, -100)
Params
targetElement
The dom element to scroll to.
duration
Duration of time to scroll to the element in milliseconds. (Optional)
offset
An additional offset in pixels from the element being scrolled to. (Optional)
containerElement
The dom element to scroll, set this to overflow. (Only used for scrollWindowToElement function)
Development
npm install
npm run build
npm start