-
-
Notifications
You must be signed in to change notification settings - Fork 101
Smooth Scroll
Murhaf Sousli edited this page Sep 10, 2019
·
8 revisions
Smooth scroll feature is built-in NgScrollbar component, but if you like to use this feature outside the NgScrollbar component, then use SmoothScrollModule which is available as an independent module. it allows you to use smooth scroll functions on any scrollable element.
SmoothScrollModule provides:
-
SmoothScrolla directive for template usage -
SmoothScrollManagera service for code usage
Import SmoothScrollModule in your module
import { SmoothScrollModule } from 'ngx-scrollbar/smooth-scroll';
@NgModule({
imports: [
SmoothScrollModule
]
})<div smoothScroll #scrollable="smoothScroll" class="scrollable-container">
<div>{{scrollableContent}}</div>
</div>
<button (click)="scrollable.scrollTo({ bottom: 0, duration: 500 })">Scroll to bottom</button>@Component({...})
export class FooComponent {
constructor(private el: ElementRef, private smoothScroll: SmoothScrollManager) {
}
scrollTop() {
this.smoothScroll.scrollTo(this.el.nativeElement, { top: 0, duration: 800 });
}
}See all ScrollTo Functions.
Become a sponsor and get your logo on our README on GitHub and the front page of https://ngx-scrollbar.netlify.com/.
Become a backer and get your logo on our README on GitHub.
Latest version (v15)
Addons:
Older version (v13)
- Demo for v13
- Usage
- Styling
- Global Options
- Pointer Events
- Scroll Event
- Updated Event
- Smooth Scroll Functions
- Performance tweak
- Integration
- Reached events