Closed natete closed 7 years ago
Thanks for the PR! With the current version 0.0.11, there's an "ng-scrollbars-update" https://github.com/iominh/ng-scrollbars/tree/0.0.11#updating-scrollbars, http://iominh.github.io/ng-scrollbars/18_update_scrollbars.html that would be somewhat similar to what you're trying to achieve I think? So, it would be something like the following:
app.controller('mainCtrl', function ($scope, $timeout) {
$timeout(function() {
$scope.updateScrollbar('scrollTo', 10);
});
});
<div class="container" ng-scrollbars ng-scrollbars-update=updateScrollbar ng-controller="mainCtrl">
<h1>Title</h1>
<p>A bunch of content</p>
</div>
With this it also exposes the other functions like "destroy", "delete", "stop", "disable".
However, I like where you're going since your approach would require less code. But instead of "scrollTo" do you think it'll make sense to call it "initialScrollTo" to separate it from the ng-scrollbars-update runtime functionality since this scrollTo only occurs at the initial render?
Also thanks for your https://github.com/iominh/ng-scrollbars/issues/47 issue! I think we'll likely bump this PR to 0.0.12 if things sound good to you
Thank you for the quick response!!
Actually ng-scrollbars-update works for me. Sorry I didn't get it at first sight. My implementation works both for initial scroll and to scroll wherever you want at any given time (not only at the initial render). You can keep it as a shorthand for scrollTo or just close the PR.
No worries and thanks for your contribution! Ah, I didn't know that you could pass a function into your scrollTo - that's very nice!
I'll see if I can add your change in an upcoming release (might change it to 0.1.0) but will also change the existing ng-scrollbars-update functionality as I've found it odd having to do a timeout before being able to invoke the function. I think having the scope.$watch may fix that.
Hi @iominh I added a new parameter to your directive
With this parameter the user can set a point (defined as a string, number, array or function, check malihu's documentation here) to scroll to and the directive will handle it using
I find it an interesting feature and I needed in my project. Maybe there's another way to do it but this is the one I came up with.
Thanks! :)