yads / ngTinyScrollbar

An angular directive port of the TinyScrollbar
MIT License
55 stars 20 forks source link

scrollIntoView() or setScrollPosition() method? #31

Open willhoney7 opened 8 years ago

willhoney7 commented 8 years ago

I need to be able to update the scroll position. Is there some sort of scrollIntoView() method? So I could pass in a node and it would scroll until it was visible. Another, simpler, option would be a setScrollPosition method where I could find the element position myself and just update the scroller to where I need it to go. Is there something available to accomplish what I need currently? As of now I'm planning on just hacking the top position css... but that's not very pretty.

Thanks so much for ngTinyScrollbar – it's great!

yads commented 8 years ago

Yes, it exposes an update method. Specify the position you want to scroll to in your outer directive.

Mossar commented 7 years ago

Can you help me how to use this update function? For example I have:

<div ng-controller="exampleCtrl"> <div scrollbar></div> </div>

and how to call update(x) from exampleCtrl or how to bind this to this directive.

yads commented 7 years ago

@Mossar you would do it inside another directive's link function. So in your example your outer div would need to be another directive and when defining that controller you would add your update code in the outer directive's link function. See the documentation here under 'Creating Directives that Communicate'