var pageManager = {動畫
_pageIndex: 1,this
init:function() {spa
var self = this;it
$scope.$on('$locationChangeStart', function() {io
var state = history.state || {};console
console.log(state._pageIndex)function
console.log(self._pageIndex)class
if(state._pageIndex <= self._pageIndex) {樣式
console.log('返回')margin
//添加動畫樣式
self._back();
} else {
console.log('跳轉')
//添加動畫樣式
self._go();
}
if(history.state) {
this._pageIndex = history.state._pageIndex;
}
this._pageIndex--;
return this;
});
},
_go: function (config) {
this._pageIndex ++;
history.replaceState && history.replaceState({_pageIndex: this._pageIndex}, '', location.href);
return this;
},
_back: function (config) {
this._pageIndex --;
return this;
},
}
.init();