ng2-scroll-to
angular 2 library to animate scrolling to anchor links.
Features
- jump to the top edge of an element referenced in the href attribute (
href="#mytarget"
) or scrollTargetSelector attribute(scrollTargetSelector="#mytarget"
) - jump to the the to given coordinates (
scrollYTarget="0"
)
Install
npm install ng2-scroll-to --save
Usage
Import ScrollToModule and add it to the imports array of your component.
// app.module.ts;
In your template you may now add the scrollTo
attribute to anchors elements.
// app.awesome.component.ts
Attributes
scrollTo required
scrollTargetSelector string Element target for scroll.
href string Element target for scroll.
scrollYTarget number Y axis target for scroll.
scrollableElementSelector string Scrollable element selector. Sometimes there are multiple scrollable elements in your page; through this attribute you may specify the element you want to scroll.