I'm using AngularJS's ui-router
and ngAnimate
to create the classic sliding view in mobile.
I found that at the beginning of the transition when both view exist on the page, if the targeted view is out of the view port, it will jump to that view position first, which give us the funny effect like this:
Is there anyway to avoid this?
Well, usually Angular uses $anchorscroll to scroll to a new view. That can be disabled by calling .value('$anchorScroll', angular.noop)
on your module, like this:
var app = angular.module('app', [
'ui.router',
'ngAnimate'
]).value('$anchorScroll', angular.noop);
However, UI-Router uses its own. I disabled that by telling UI-Router to use the (now disabled) $anchorScroll
: $uiViewScrollProvider.useAnchorScroll();