Scroll position after changing view - AngularJS
I notice an issue it may happens specially because the way I include my views.
I have a sideMenu with some links when tapping on of the links it goes to a router that load a template file using the normal $routeProvider.when('/link', {templateUrl: '/templates/link.html', controller: 'LinkCtrl'}); inside an <ng-view></ng-view> directive.
Everything work fines expect if for example I accessed link1 and scrolled down then opened the side menu and tapped link2 the view opened scrolled a little bit, I think it happens because the scroll plugin store the current position on the ng-view element itself.
I thought of current workaround but it doesn't work as expected. Add scroll="false" attribute on <ng-view> and then inside the template file find the first tag e.g <div> ad scroll="true".
You did a great job with the new scroll implementation it works better, and I hope you would be able to fix any related bugs.
I have similar problems. When I scroll down to the third or fourth card and click them, go to the card page(change view), the position is not top, I have to scroll up to see then content
I had a similar problem. Is there a way we could add a scrollToTop function to the scroller?
I added the following to listen to Angular $viewContentLoader event and then using the new ScrollDelegate service in the main controller.
/* When View Content Loaded */
$scope.$on('$viewContentLoaded', function() {
// Scroll to Top
// Set ture for animation which isn't needed in my case
ScrollDelegate.scrollTop(false);
});
Don't forget you need to inject the ScrollDelegate before you use it in your controller, another way could be by firing the scroll.scrollTop event.
$scope.$broadcast('scroll.scrollTop')
Mentioned by @mlynch on the forums here
But I think it make sense that the framework do it on itself.
Hi @JonathanHindi, sorry for the late response.
Is this bug still valid in v0.9.23?
No It was fixed a while ago. So I will close.
@JonathanHindi
I added the following to listen to Angular $viewContentLoader
it doesn't work when all templates are pre-cached in JS. And this is a good practice, so please consider to find some more universal solution.
I'm suffering this glitch right now.
Until now i've been using next to avoid the scroll problem:
$rootScope.$on("$viewContentLoaded", function () {
$anchorScroll();
});
But this makes scroll is always on top, which is a little bit annoying when user wants to go back and keep surfing from the point he was.
@rubenjimenez try attribute overflow-scroll="true" - it solved my issue (and not one).
@rubenjimenez Would you be able to explain where exactly I would put that code, and how I would insert it into the existing code? Thanks in advance for any help you can provide.