ionic瀑布流

来源:互联网 发布:常用数据库管理系统 编辑:程序博客网 时间:2024/05/29 02:31

首先使用这个插件:
https://github.com/zedwang/angular-waterfall

更改部分代码,获得兼容性

if (scope.$last === true) {                        angular.element(element).ready(function() {                            var img = element.find("img")[0];                            var oImage = new Image();                          if (oImage.complete) {                            //$timeout.cancel();                            //$timeout(function(){                            scope.$emit("waterfall:repeatFinished");                            //},500);                          }else {                            oImage.onload = function () {                              scope.$emit("waterfall:repeatFinished");                            };                          }                          oImage.src = img.src;                        });                    }
  $rootScope.$on("waterfall:repeatFinished",function(){                        $timeout.cancel();                      $timeout(function(){                        waterfall(scope.minCols);                      },500)                    });

如果不需要点击按钮加载更多功能,则下拉刷新和上拉加载依旧使用ionic指令,不过要注意上拉加载的触发需要在数据变更后加一段时间的延迟

0 0
原创粉丝点击