zoukankan      html  css  js  c++  java
  • 滚屏加载

    滚屏加载
    
    另外一种可行的性能解决方案就是滚屏加载,又称”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; }]);
  • 相关阅读:
    记一次在黑盒环境下使用网络设备(华为)寻找主机
    mips交叉编译zlib
    Python 爬虫 之LOL皮肤图片抓取
    gitlab 新建项目 并将本地项目上传
    flask项目目录结构
    SQLALCHEM 初始化数据库
    python连接access数据库查询
    .Net Core 3.1 -- APISIX2.6 微服务网关入门
    SqlServer Agent代理无法启动(启动后自动关闭)的解决方法
    Centos7安装配置DNS服务器
  • 原文地址:https://www.cnblogs.com/sxz2008/p/6581002.html
Copyright © 2011-2022 走看看