-
Notifications
You must be signed in to change notification settings - Fork 77
/
ui-grid.infinite-scroll.min.js
6 lines (6 loc) · 4.59 KB
/
ui-grid.infinite-scroll.min.js
1
2
3
4
5
6
/*!
* ui-grid - v4.12.7 - 2024-04-12
* http://ui-grid.info/
* Copyright (c) 2024 ; License: MIT
*/
!function(){"use strict";var i=angular.module("ui.grid.infiniteScroll",["ui.grid"]);i.service("uiGridInfiniteScrollService",["gridUtil","$compile","$rootScope","uiGridConstants","ScrollEvent","$q",function(i,o,t,c,r,n){var s={initializeGrid:function(n,i){s.defaultGridOptions(n.options),n.options.enableInfiniteScroll&&(n.infiniteScroll={dataLoading:!1},s.setScrollDirections(n,n.options.infiniteScrollUp,n.options.infiniteScrollDown),n.api.core.on.scrollEnd(i,s.handleScroll),i={infiniteScroll:{dataLoaded:function(i,o){return s.setScrollDirections(n,i,o),s.adjustScroll(n).then(function(){n.infiniteScroll.dataLoading=!1})},resetScroll:function(i,o){s.setScrollDirections(n,i,o),s.adjustInfiniteScrollPosition(n,0)},saveScrollPercentage:function(){n.infiniteScroll.prevScrollTop=n.renderContainers.body.prevScrollTop,n.infiniteScroll.previousVisibleRows=n.getVisibleRowCount()},dataRemovedTop:function(i,o){s.dataRemovedTop(n,i,o)},dataRemovedBottom:function(i,o){s.dataRemovedBottom(n,i,o)},setScrollDirections:function(i,o){s.setScrollDirections(n,i,o)}}},n.api.registerEventsFromObject({infiniteScroll:{needLoadMoreData:function(i,o){},needLoadMoreDataTop:function(i,o){}}}),n.api.registerMethodsFromObject(i))},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){var o;i.grid.infiniteScroll&&i.grid.infiniteScroll.dataLoading||"ui.grid.adjustInfiniteScrollPosition"===i.source||i.y&&(0===i.y.percentage?(i.grid.scrollDirection=c.scrollDirection.UP,s.loadData(i.grid)):1===i.y.percentage?(i.grid.scrollDirection=c.scrollDirection.DOWN,s.loadData(i.grid)):(o=i.grid.options.infiniteScrollRowsFromEnd/i.grid.renderContainers.body.visibleRowCache.length,i.grid.scrollDirection===c.scrollDirection.UP?i.y.percentage<=o&&s.loadData(i.grid):i.grid.scrollDirection===c.scrollDirection.DOWN&&1-i.y.percentage<=o&&s.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===c.scrollDirection.UP&&i.infiniteScroll.scrollUp?(i.infiniteScroll.dataLoading=!0,i.api.infiniteScroll.raise.needLoadMoreDataTop()):i.scrollDirection!==c.scrollDirection.DOWN||!i.infiniteScroll.scrollDown||i.cellNav&&i.cellNav.lastRowCol&&i.cellNav.lastRowCol.row.index===i.infiniteScroll.previousVisibleRows-1||(i.infiniteScroll.dataLoading=!0,i.api.infiniteScroll.raise.needLoadMoreData())},adjustScroll:function(l){var r=n.defer();return t.$applyAsync(function(){var i,o=l.getViewportHeight()+l.headerHeight-l.renderContainers.body.headerHeight-l.scrollbarHeight,n=l.options.rowHeight,e=(void 0===l.infiniteScroll.direction&&s.adjustInfiniteScrollPosition(l,0),l.getVisibleRowCount());l.infiniteScroll.scrollDown&&n*e<o&&l.api.infiniteScroll.raise.needLoadMoreData(),l.infiniteScroll.direction===c.scrollDirection.UP&&(i=(l.infiniteScroll.prevScrollTop||0)+(e-l.infiniteScroll.previousVisibleRows)*n,s.adjustInfiniteScrollPosition(l,i),t.$applyAsync(function(){r.resolve()})),l.infiniteScroll.direction===c.scrollDirection.DOWN&&(i=l.infiniteScroll.prevScrollTop||l.infiniteScroll.previousVisibleRows*n-o,s.adjustInfiniteScrollPosition(l,i),t.$applyAsync(function(){r.resolve()}))},0),r.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,e=e*i.options.rowHeight-l;0===o&&i.infiniteScroll.scrollUp?n.y={pixels:1}:n.y={percentage:o/e},i.scrollContainers("",n)},dataRemovedTop:function(i,o,n){var e;s.setScrollDirections(i,o,n),o=i.renderContainers.body.visibleRowCache.length,n=i.infiniteScroll.prevScrollTop,e=i.options.rowHeight,n=n-(i.infiniteScroll.previousVisibleRows-o)*e,s.adjustInfiniteScrollPosition(i,n)},dataRemovedBottom:function(i,o,n){s.setScrollDirections(i,o,n),o=i.infiniteScroll.prevScrollTop,s.adjustInfiniteScrollPosition(i,o)}};return s}]),i.directive("uiGridInfiniteScroll",["uiGridInfiniteScrollService",function(l){return{priority:-200,scope:!1,require:"^uiGrid",compile:function(){return{pre:function(i,o,n,e){l.initializeGrid(e.grid,i)},post:function(i,o,n){}}}}}])}();