I\'ve just upgraded to ui-router 0.2.8
from 0.2.0
and I\'ve noticed that when the state changes, the scroll position jumps to the top of te child <
Another approach is to decorate the default $uiViewScroll
service, effectively overriding the default behaviour.
app.config(function ($provide) {
$provide.decorator('$uiViewScroll', function ($delegate) {
return function (uiViewElement) {
// var top = uiViewElement.getBoundingClientRect().top;
// window.scrollTo(0, (top - 30));
// Or some other custom behaviour...
};
});
});
And as Hubrus mentioned, for any
you do not wish this to apply for, simply add autoscroll="false"
. I haven't taken a good look into the actual scrolling implementation, I just figured I'd mention the decorator way (it's alot of fun) as an alternative. I'm sure you can work out the exact scrolling behaviour.