滚屏加载

Posted Lonely existence, lonely burni

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了滚屏加载相关的知识,希望对你有一定的参考价值。

滚屏加载

另外一种可行的性能解决方案就是滚屏加载,又称”Endless Scrolling,“ “unpagination”,这是用于大量数据集显示的时候,
又不想表格分页,所以一般放在页面最底部,当滚动屏幕到达页面底部的时候,就会尝试加载一个序列的数据集,追加在页面底部。
在Angular社区有开源组件ngInfiniteScroll http:
//binarymuse.github.io/ngInfiniteScroll/index.html实现滚屏加载。下面是官方Demo: HTML: <div ng-app=‘myApp‘ ng-controller=‘DemoController‘> <div infinite-scroll=‘reddit.nextPage()‘ infinite-scroll-disabled=‘reddit.busy‘ infinite-scroll-distance=‘1‘> <div ng-repeat=‘item in reddit.items‘> <span class=‘score‘>{{item.score}}</span> <span class=‘title‘> <a ng-href=‘{{item.url}}‘ target=‘_blank‘>{{item.title}}</a> </span> <small>by {{item.author}} - <a ng-href=‘http://reddit.com{{item.permalink}}‘ target=‘_blank‘>{{item.num_comments}} comments</a> </small> <div style=‘clear: both;‘></div> </div> <div ng-show=‘reddit.busy‘>Loading data...</div> </div> </div> javascript var myApp = angular.module(‘myApp‘, [‘infinite-scroll‘]); myApp.controller(‘DemoController‘, [‘$scope‘, ‘Reddit‘, function($scope, Reddit) { $scope.reddit = new Reddit(); }]); // Reddit constructor function to encapsulate HTTP and pagination logic myApp.factory(‘Reddit‘, [‘$http‘, function($http) { var Reddit = function() { this.items = []; this.busy = false; this.after = ‘‘; }; Reddit.prototype.nextPage = function() { if (this.busy) return; this.busy = true; var url = ‘http://api.reddit.com/hot?after=‘ + this.after + ‘&jsonp=JSON_CALLBACK‘; $http.jsonp(url).success(function(data) { var items = data.data.children; for (var i = 0; i < items.length; i++) { this.items.push(items[i].data); } this.after = ‘t3_‘ + this.items[this.items.length - 1].id; this.busy = false; }.bind(this)); }; return Reddit; }]);

 

以上是关于滚屏加载的主要内容,如果未能解决你的问题,请参考以下文章

滚屏异步加载图片

文字通知滚屏效果

一种通用的jquery动画滚屏方案

c_cpp 加载源图像固定用法(代码片段,不全)

分享前端开发常用代码片段

iview修改table组件实现循环向上滚屏