Advertisement
Guest User

Untitled

a guest
May 28th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.65 KB | None | 0 0
  1. doEnsureBufferZone: function() {
  2.             var me = this,
  3.                 list = me.cmp,
  4.                 store = list.getStore(),
  5.                 scroller = list.getScrollable(),
  6.                 count = store && store.getCount(),
  7.                bufferZone = me.getBufferZone(),
  8.                item, box, y, index;
  9.  
  10.  
  11.             if (!store || !count || !scroller || me.getLoading()) {
  12.                 return;
  13.             }
  14.  
  15.  
  16.             index = Math.min(Math.max(0, count - bufferZone), count - 1);
  17.             item = list.mapToItem(store.getAt(index));
  18.  
  19.  
  20.             // OLD code
  21.             // box = item && item.element.getBox();
  22.  
  23.  
  24.             // NEW code starts
  25.             if (item.element) {
  26.                 box = item && item.element.getBox();
  27.             } else {
  28.                 if (item.el) {
  29.                     box = item && item.el.getBox();
  30.                 } else {
  31.                     return;
  32.                 }
  33.             }
  34.             // NEW Code ends
  35.             if (!box) {
  36.                 return;
  37.             }
  38.  
  39.  
  40.             // if bufferZone is 0, loading the next page should happen when reaching the end
  41.             // of the list (the bottom of the last item), else, if bufferZone is greater than
  42.             // 0, loading the next page should happen when the first row of pixels of the
  43.             // leading buffer zone item appears in the view.
  44.             y = bufferZone > 0 ? box.top + 1 : box.bottom;
  45.             if (y > scroller.getElement().getBox().bottom) {
  46.                 return;
  47.             }
  48.  
  49.  
  50.             me.loadNextPage();
  51.         },
  52. 24 Jan 2018, 9:23 AM #2
  53. elkentzo yaxidaxilstawskitheposeidon
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement