单页面跳转添加返回和跳转动画(仿app) 只对单页面和跳转有用,我用的是angualr,有不会的可以私信问我。

时间:2017-09-05 18:28:15   收藏:0   阅读:314

var pageManager = {

_pageIndex: 1,

init:function() {

var self = this;

$scope.$on(‘$locationChangeStart‘, function() {

var state = history.state || {};

console.log(state._pageIndex)

console.log(self._pageIndex)

if(state._pageIndex <= self._pageIndex) {

console.log(‘返回‘)

    //添加动画样式

  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();

原文:http://www.cnblogs.com/zyzhao/p/7479792.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!