Nolanus / ngx-page-scroll

Animated scrolling functionality for angular written in pure typescript
https://nolanus.github.io/ngx-page-scroll/
MIT License
477 stars 106 forks source link

Is it possible to scroll within specified container #409

Closed ColinMorris83 closed 4 years ago

ColinMorris83 commented 4 years ago

Looking at moving away from https://www.npmjs.com/package/@nicky-lenaers/ngx-scroll-to to use your library, but can't see any options for scrolling within a container, seems like can only scroll on the top level Document. Is it possible in your library to specify an HtmlElement as the scrollable container? The use case is things like a side drawer that open and then need to scroll within that drawer.

I see on the demo page there is nested scrolling example, so looks like it is possible, is there some example code of using the scroll service to do this?

Nolanus commented 4 years ago

Hi @ColinMorris83, yes, scrolling inside other containers than the main html body is possible with "nested scrolling" feature. The following code from the demo app showcases how to use the service for scrolling:

https://github.com/Nolanus/ngx-page-scroll/blob/de9723f74070eb75ee27e97dc0a0d4a3b24199d4/src/app/nested-scroll/nested-scroll.component.ts#L40-L45

You can define the container using the scrollViews property.

ColinMorris83 commented 4 years ago

Yep great, just found that exact piece of code looking around the source code. Thanks a lot, library seems great.