在后退导航中保存滚动位置:Cordova iOS

时间:2015-08-18 15:52:23

标签: jquery ios angularjs cordova

使用的框架和Libs:Cordova,AngularJS

如何按后退按钮保持滚动位置?

我最初将位置存储在服务对象中:

var page_data  = {
  page : $location.path,
  scrollpos : scrollpos // page.scrollTop()
};

然后当我返回页面时,我滚动到最后保存的滚动位置:

$scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {

  $('html,body').animate({ scrollTop:  page_data.scrollpos},"fast");

  //tried $(page_ele).scrollTop(page_data.scrollpos) but that didn't work iOS
});

如果我浏览几个子级别的页面,我会将page_data对象推入堆栈并根据需要弹出()。

这很有效,但由于渲染速度慢,不是100%的时间,你们能提供更好,更强大的解决方案吗?

0 个答案:

没有答案
相关问题