-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathui-grid.infiniteScroll.min.js
2 lines (2 loc) · 4.7 KB
/
ui-grid.infiniteScroll.min.js
1
2
/*! For license information please see ui-grid.infiniteScroll.min.js.LICENSE.txt */
(()=>{var i={470:()=>{!function(){"use strict";var i=angular.module("ui.grid.infiniteScroll",["ui.grid"]);i.service("uiGridInfiniteScrollService",["gridUtil","$compile","$rootScope","uiGridConstants","ScrollEvent","$q",function(i,o,n,e,r,l){var t={initializeGrid:function(i,o){if(t.defaultGridOptions(i.options),i.options.enableInfiniteScroll){i.infiniteScroll={dataLoading:!1},t.setScrollDirections(i,i.options.infiniteScrollUp,i.options.infiniteScrollDown),i.api.core.on.scrollEnd(o,t.handleScroll);var n={events:{infiniteScroll:{needLoadMoreData:function(i,o){},needLoadMoreDataTop:function(i,o){}}},methods:{infiniteScroll:{dataLoaded:function(o,n){return t.setScrollDirections(i,o,n),t.adjustScroll(i).then((function(){i.infiniteScroll.dataLoading=!1}))},resetScroll:function(o,n){t.setScrollDirections(i,o,n),t.adjustInfiniteScrollPosition(i,0)},saveScrollPercentage:function(){i.infiniteScroll.prevScrollTop=i.renderContainers.body.prevScrollTop,i.infiniteScroll.previousVisibleRows=i.getVisibleRowCount()},dataRemovedTop:function(o,n){t.dataRemovedTop(i,o,n)},dataRemovedBottom:function(o,n){t.dataRemovedBottom(i,o,n)},setScrollDirections:function(o,n){t.setScrollDirections(i,o,n)}}}};i.api.registerEventsFromObject(n.events),i.api.registerMethodsFromObject(n.methods)}},defaultGridOptions:function(i){i.enableInfiniteScroll=!1!==i.enableInfiniteScroll,i.infiniteScrollRowsFromEnd=i.infiniteScrollRowsFromEnd||20,i.infiniteScrollUp=!0===i.infiniteScrollUp,i.infiniteScrollDown=!1!==i.infiniteScrollDown},setScrollDirections:function(i,o,n){i.infiniteScroll.scrollUp=!0===o,i.suppressParentScrollUp=!0===o,i.infiniteScroll.scrollDown=!1!==n,i.suppressParentScrollDown=!1!==n},handleScroll:function(i){if(!(i.grid.infiniteScroll&&i.grid.infiniteScroll.dataLoading||"ui.grid.adjustInfiniteScrollPosition"===i.source)&&i.y)if(0===i.y.percentage)i.grid.scrollDirection=e.scrollDirection.UP,t.loadData(i.grid);else if(1===i.y.percentage)i.grid.scrollDirection=e.scrollDirection.DOWN,t.loadData(i.grid);else{var o=i.grid.options.infiniteScrollRowsFromEnd/i.grid.renderContainers.body.visibleRowCache.length;i.grid.scrollDirection===e.scrollDirection.UP?i.y.percentage<=o&&t.loadData(i.grid):i.grid.scrollDirection===e.scrollDirection.DOWN&&1-i.y.percentage<=o&&t.loadData(i.grid)}},loadData:function(i){i.infiniteScroll.previousVisibleRows=i.renderContainers.body.visibleRowCache.length,i.infiniteScroll.direction=i.scrollDirection,delete i.infiniteScroll.prevScrollTop,i.scrollDirection===e.scrollDirection.UP&&i.infiniteScroll.scrollUp?(i.infiniteScroll.dataLoading=!0,i.api.infiniteScroll.raise.needLoadMoreDataTop()):i.scrollDirection===e.scrollDirection.DOWN&&i.infiniteScroll.scrollDown&&(i.infiniteScroll.dataLoading=!0,i.api.infiniteScroll.raise.needLoadMoreData())},adjustScroll:function(i){var o=l.defer();return n.$applyAsync((function(){var r,l,c,s;r=i.getViewportHeight()+i.headerHeight-i.renderContainers.body.headerHeight-i.scrollbarHeight,l=i.options.rowHeight,void 0===i.infiniteScroll.direction&&t.adjustInfiniteScrollPosition(i,0);var a=l*(c=i.getVisibleRowCount());i.infiniteScroll.scrollDown&&r>a&&i.api.infiniteScroll.raise.needLoadMoreData(),i.infiniteScroll.direction===e.scrollDirection.UP&&(s=(i.infiniteScroll.prevScrollTop||0)+(c-i.infiniteScroll.previousVisibleRows)*l,t.adjustInfiniteScrollPosition(i,s),n.$applyAsync((function(){o.resolve()}))),i.infiniteScroll.direction===e.scrollDirection.DOWN&&(s=i.infiniteScroll.prevScrollTop||i.infiniteScroll.previousVisibleRows*l-r,t.adjustInfiniteScrollPosition(i,s),n.$applyAsync((function(){o.resolve()})))}),0),o.promise},adjustInfiniteScrollPosition:function(i,o){var n=new r(i,null,null,"ui.grid.adjustInfiniteScrollPosition"),e=i.getVisibleRowCount(),l=i.getViewportHeight()+i.headerHeight-i.renderContainers.body.headerHeight-i.scrollbarHeight,t=e*i.options.rowHeight-l;0===o&&i.infiniteScroll.scrollUp?n.y={pixels:1}:n.y={percentage:o/t},i.scrollContainers("",n)},dataRemovedTop:function(i,o,n){var e,r,l,c;t.setScrollDirections(i,o,n),e=i.renderContainers.body.visibleRowCache.length,r=i.infiniteScroll.prevScrollTop,c=i.options.rowHeight,l=r-(i.infiniteScroll.previousVisibleRows-e)*c,t.adjustInfiniteScrollPosition(i,l)},dataRemovedBottom:function(i,o,n){var e;t.setScrollDirections(i,o,n),e=i.infiniteScroll.prevScrollTop,t.adjustInfiniteScrollPosition(i,e)}};return t}]),i.directive("uiGridInfiniteScroll",["uiGridInfiniteScrollService",function(i){return{priority:-200,scope:!1,require:"^uiGrid",compile:function(){return{pre:function(o,n,e,r){i.initializeGrid(r.grid,o)},post:function(i,o,n){}}}}}])}()}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var l=o[e]={exports:{}};return i[e](l,l.exports,n),l.exports}n(470)})();