diff --git a/dist/ui-scroll-grid.js b/dist/ui-scroll-grid.js index f69f8807..5998a5a5 100644 --- a/dist/ui-scroll-grid.js +++ b/dist/ui-scroll-grid.js @@ -1,7 +1,7 @@ /*! * angular-ui-scroll * https://github.com/angular-ui/ui-scroll - * Version: 1.7.3 -- 2019-05-27T16:57:07.461Z + * Version: 1.7.4 -- 2019-06-19T10:49:07.005Z * License: MIT */ /******/ (function(modules) { // webpackBootstrap diff --git a/dist/ui-scroll.js b/dist/ui-scroll.js index 6a791810..55f97859 100644 --- a/dist/ui-scroll.js +++ b/dist/ui-scroll.js @@ -1,7 +1,7 @@ /*! * angular-ui-scroll * https://github.com/angular-ui/ui-scroll - * Version: 1.7.3 -- 2019-05-27T16:57:07.461Z + * Version: 1.7.4 -- 2019-06-19T10:49:07.005Z * License: MIT */ /******/ (function(modules) { // webpackBootstrap @@ -1250,7 +1250,8 @@ function () { angular.module('ui.scroll', []).constant('JQLiteExtras', jqLiteExtras_JQLiteExtras).run(['JQLiteExtras', function (JQLiteExtras) { - !window.jQuery ? new JQLiteExtras().registerFor(angular.element) : null; + var elt = angular.element; + !(window.jQuery && elt.fn && elt.fn.jquery) ? new JQLiteExtras().registerFor(elt) : null; ElementRoutines.addCSSRules(); }]).directive('uiScrollViewport', function () { return { diff --git a/dist/ui-scroll.js.map b/dist/ui-scroll.js.map index ee87c1d0..a5d4f592 100644 --- a/dist/ui-scroll.js.map +++ b/dist/ui-scroll.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/modules/jqLiteExtras.js","webpack:///./src/modules/elementRoutines.js","webpack:///./src/modules/buffer.js","webpack:///./src/modules/padding.js","webpack:///./src/modules/viewport.js","webpack:///./src/modules/adapter.js","webpack:///./src/ui-scroll.js"],"names":["JQLiteExtras","element","convertToPx","css","getStyle","isWindow","angular","prototype","name","value","self","elem","nodeType","style","call","obj","document","location","alert","setInterval","scrollTo","direction","top","left","method","prop","preserve","isValueDefined","documentElement","window","getComputedStyle","parseFloat","currentStyle","result","rs","rsLeft","core_pnum","source","rnumnonpx","RegExp","test","runtimeStyle","pixelLeft","getMeasurements","measure","base","borderA","borderB","computedMarginA","computedMarginB","computedStyle","dirA","dirB","marginA","marginB","paddingA","paddingB","height","width","padding","border","margin","offsetWidth","offsetHeight","getWidthHeight","measurements","outer","outerfull","forEach","before","newElem","children","i","j","parent","ref","contents","prepend","length","after","Error","outerHTML","isNumber","outerHeight","option","outerWidth","offset","docElem","win","box","doc","ownerDocument","arguments","undefined","getBoundingClientRect","defaultView","parentWindow","pageYOffset","scrollTop","clientTop","pageXOffset","scrollLeft","clientLeft","key","hideClassToken","ElementRoutines","selector","rules","sheet","styleSheets","index","cssRules","err","insertRule","addRule","$injector","$q","$animate","has","get","isAngularVersionLessThen1_3","version","major","minor","wrapper","addClass","removeClass","newElement","previousElement","remove","scope","$destroy","insertElement","deferred","defer","enter","resolve","promise","removeElement","leave","then","ScrollBuffer","elementRoutines","bufferSize","startIndex","buffer","Object","create","Array","extend","size","reset","eof","bof","first","next","minIndex","maxIndex","minIndexUser","maxIndexUser","append","items","item","insert","Math","max","reverse","min","operation","isTop","op","splice","push","unshift","arg1","arg2","indexOf","_op","getAbsMinIndex","incrementMinIndex","decrementMaxIndex","removeElementAnimated","getAbsMaxIndex","effectiveHeight","elements","Number","MAX_VALUE","bottom","NEGATIVE_INFINITY","offsetParent","CacheProto","$index","sort","a","b","argument","_isTop","Cache","instance","apply","setPrototypeOf","getOwnPropertyNames","methodName","generateElement","template","Node","ELEMENT_NODE","tagName","toLowerCase","table","find","Padding","cache","Viewport","viewportController","$rootScope","topPadding","bottomPadding","viewport","container","bufferPadding","getScope","createPaddingElements","applyContainerStyle","bottomDataPos","scrollHeight","topDataPos","bottomVisiblePos","topVisiblePos","e","sibling","insertElementAnimated","shouldLoadBottom","clipBottom","overage","overageHeight","itemHeight","emptySpaceHeight","add","adjustPaddings","shouldLoadTop","clipTop","visibleItemsHeight","reduce","summ","topPaddingHeight","topCount","bottomPaddingHeight","bottomCount","totalHeight","averageItemHeight","adjustTopPadding","adjustBottomPadding","topPaddingHeightAdd","bottomPaddingHeightAdd","onAfterMinIndexSet","topPaddingHeightOld","diff","onAfterPrepend","updates","prepended","paddingHeight","resetTopPadding","clear","resetBottomPadding","removeCacheItem","removeItem","Adapter","$scope","$parse","$attr","doAdjust","reload","isLoading","disabled","viewportScope","startScope","$parent","publicContext","assignAdapter","adapter","generatePublicContext","adapterAttr","replace","adapterOnScope","assign","error","message","publicMethods","bind","publicProps","property","attr","defineProperty","set","newItems","applyUpdatesFunc","applyUpdatesIndex","cb","slice","applyUpdate","_index","isArray","position","some","newItem","rowTop","topHeight","topDone","bottomDone","itemTop","isEOF","module","constant","run","jQuery","registerFor","addCSSRules","directive","restrict","controller","child","console","$timeout","$interval","require","transclude","priority","terminal","link","controllers","linker","match","uiScroll","parseNumber","defaultValue","isFloat","floor","isNaN","parseNumericAttr","BUFFER_MIN","BUFFER_DEFAULT","PADDING_MIN","PADDING_DEFAULT","START_INDEX_DEFAULT","MAX_VIEWPORT_DELAY","VIEWPORT_POLLING_INTERVAL","datasource","itemName","datasourceName","ridActual","pending","isDatasourceValid","toString","onRenderHandlers","onRenderHandlersRunner","handler","persistDatasourceIndex","propName","getter","filter","id","defineDatasourceIndex","propUserName","descriptor","getOwnPropertyDescriptor","fetchNext","success","count","fetchPrevious","initialize","tryCount","timer","cancel","clone","$on","unbindEvents","unbind","wheelHandler","isInvalid","rid","$$destroyed","bindEvents","resizeAndScrollHandler","isElementVisible","visibilityWatcher","unregisterVisibilityWatcher","insertWrapperContent","insertAfter","createElement","$watch","hideElement","promises","transform","tdInitializer","uiScrollTdInitializer","linking","onLink","updateDOM","toBePrepended","toBeRemoved","inserted","concat","removed","animated","updatePaddings","all","enqueueFetch","loading","fetch","processUpdates","$$phase","$digest","w","showElement","calculateProperties","doAdjustAfterFetch","shift","event","yMax","clientHeight","preventDefault"],"mappings":";;;;;;;AAAA;AACA;;AAEA;AACA;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MAAM,CAAC+I,OAAR,IAAmB/I,MAAM,CAACgJ,OAAP,EAAnB;AACD;AACF;AACF;;AAED,aAASlC,YAAT,CAAsBwC,KAAtB,EAA6B;AAC3B,UAAI,CAAC1I,OAAO,CAACN,QAAb,EAAuB;AACrB,YAAMhL,SAAS,GAAGwH,QAAQ,CAAC,CAAD,CAAR,CAAYxH,SAA9B;AACA,YAAMiU,IAAI,GAAGzM,QAAQ,CAAC,CAAD,CAAR,CAAYO,YAAZ,GAA2BP,QAAQ,CAAC,CAAD,CAAR,CAAY0M,YAApD;;AAEA,YAAKlU,SAAS,KAAK,CAAd,IAAmB,CAAC+C,MAAM,CAACQ,GAA5B,IAAqCvD,SAAS,KAAKiU,IAAd,IAAsB,CAAClR,MAAM,CAACO,GAAvE,EAA6E;AAC3E0Q,eAAK,CAACG,cAAN;AACD;AACF;AACF;AACF;AAEF,CA1doB,CA/BzB,E","file":"ui-scroll.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","/*!\r\n globals: angular, window\r\n List of used element methods available in JQuery but not in JQuery Lite\r\n element.before(elem)\r\n element.height()\r\n element.outerHeight(true)\r\n element.height(value) = only for Top/Bottom padding elements\r\n element.scrollTop()\r\n element.scrollTop(value)\r\n */\r\n\r\nexport default class JQLiteExtras {\r\n\r\n registerFor(element) {\r\n let convertToPx, css, getStyle, isWindow;\r\n // angular implementation blows up if elem is the window\r\n css = angular.element.prototype.css;\r\n\r\n element.prototype.css = function (name, value) {\r\n let self = this;\r\n let elem = self[0];\r\n if (!(!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style)) {\r\n return css.call(self, name, value);\r\n }\r\n };\r\n\r\n // as defined in angularjs v1.0.5\r\n isWindow = (obj) => obj && obj.document && obj.location && obj.alert && obj.setInterval;\r\n\r\n function scrollTo(self, direction, value) {\r\n let elem = self[0];\r\n let [method, prop, preserve] = {\r\n top: [\r\n 'scrollTop',\r\n 'pageYOffset',\r\n 'scrollLeft'\r\n ],\r\n left: [\r\n 'scrollLeft',\r\n 'pageXOffset',\r\n 'scrollTop'\r\n ]\r\n }[direction];\r\n\r\n const isValueDefined = typeof value !== 'undefined';\r\n if (isWindow(elem)) {\r\n if (isValueDefined) {\r\n return elem.scrollTo(self[preserve].call(self), value);\r\n }\r\n return (prop in elem) ? elem[prop] : elem.document.documentElement[method];\r\n } else {\r\n if (isValueDefined) {\r\n elem[method] = value;\r\n }\r\n return elem[method];\r\n }\r\n }\r\n\r\n if (window.getComputedStyle) {\r\n getStyle = (elem) => window.getComputedStyle(elem, null);\r\n convertToPx = (elem, value) => parseFloat(value);\r\n } else {\r\n getStyle = (elem) => elem.currentStyle;\r\n convertToPx = (elem, value) => {\r\n let left, result, rs, rsLeft, style;\r\n let core_pnum = /[+-]?(?:\\d*\\.|)\\d+(?:[eE][+-]?\\d+|)/.source;\r\n let rnumnonpx = new RegExp('^(' + core_pnum + ')(?!px)[a-z%]+$', 'i');\r\n\r\n if (!rnumnonpx.test(value)) {\r\n return parseFloat(value);\r\n }\r\n\r\n // ported from JQuery\r\n style = elem.style;\r\n left = style.left;\r\n rs = elem.runtimeStyle;\r\n rsLeft = rs && rs.left;\r\n if (rs) {\r\n rs.left = style.left;\r\n }\r\n // put in the new values to get a computed style out\r\n style.left = value;\r\n result = style.pixelLeft;\r\n style.left = left;\r\n if (rsLeft) {\r\n rs.left = rsLeft;\r\n }\r\n return result;\r\n };\r\n }\r\n\r\n function getMeasurements(elem, measure) {\r\n let base, borderA, borderB, computedMarginA, computedMarginB, computedStyle, dirA, dirB, marginA, marginB, paddingA, paddingB;\r\n\r\n if (isWindow(elem)) {\r\n base = document.documentElement[{height: 'clientHeight', width: 'clientWidth'}[measure]];\r\n\r\n return {\r\n base: base,\r\n padding: 0,\r\n border: 0,\r\n margin: 0\r\n };\r\n }\r\n\r\n // Start with offset property\r\n [\r\n base,\r\n dirA,\r\n dirB\r\n ] = {\r\n width: [\r\n elem.offsetWidth,\r\n 'Left',\r\n 'Right'\r\n ],\r\n height: [\r\n elem.offsetHeight,\r\n 'Top',\r\n 'Bottom'\r\n ]\r\n }[measure];\r\n\r\n computedStyle = getStyle(elem);\r\n paddingA = convertToPx(elem, computedStyle['padding' + dirA]) || 0;\r\n paddingB = convertToPx(elem, computedStyle['padding' + dirB]) || 0;\r\n borderA = convertToPx(elem, computedStyle['border' + dirA + 'Width']) || 0;\r\n borderB = convertToPx(elem, computedStyle['border' + dirB + 'Width']) || 0;\r\n computedMarginA = computedStyle['margin' + dirA];\r\n computedMarginB = computedStyle['margin' + dirB];\r\n\r\n // I do not care for width for now, so this hack is irrelevant\r\n // if ( !supportsPercentMargin )\r\n // computedMarginA = hackPercentMargin( elem, computedStyle, computedMarginA )\r\n // computedMarginB = hackPercentMargin( elem, computedStyle, computedMarginB )\r\n marginA = convertToPx(elem, computedMarginA) || 0;\r\n marginB = convertToPx(elem, computedMarginB) || 0;\r\n\r\n return {\r\n base: base,\r\n padding: paddingA + paddingB,\r\n border: borderA + borderB,\r\n margin: marginA + marginB\r\n };\r\n }\r\n\r\n function getWidthHeight(elem, direction, measure) {\r\n let computedStyle, result;\r\n\r\n let measurements = getMeasurements(elem, direction);\r\n\r\n if (measurements.base > 0) {\r\n return {\r\n base: measurements.base - measurements.padding - measurements.border,\r\n outer: measurements.base,\r\n outerfull: measurements.base + measurements.margin\r\n }[measure];\r\n }\r\n\r\n // Fall back to computed then uncomputed css if necessary\r\n computedStyle = getStyle(elem);\r\n result = computedStyle[direction];\r\n\r\n if (result < 0 || result === null) {\r\n result = elem.style[direction] || 0;\r\n }\r\n\r\n // Normalize \"\", auto, and prepare for extra\r\n result = parseFloat(result) || 0;\r\n\r\n return {\r\n base: result - measurements.padding - measurements.border,\r\n outer: result,\r\n outerfull: result + measurements.padding + measurements.border + measurements.margin\r\n }[measure];\r\n }\r\n\r\n // define missing methods\r\n return angular.forEach({\r\n before(newElem) {\r\n var children, elem, i, j, parent, ref, self;\r\n self = this;\r\n elem = self[0];\r\n parent = self.parent();\r\n children = parent.contents();\r\n if (children[0] === elem) {\r\n return parent.prepend(newElem);\r\n } else {\r\n for (i = j = 1, ref = children.length - 1; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {\r\n if (children[i] === elem) {\r\n angular.element(children[i - 1]).after(newElem);\r\n return;\r\n }\r\n }\r\n throw new Error('invalid DOM structure ' + elem.outerHTML);\r\n }\r\n },\r\n height (value){\r\n var self;\r\n self = this;\r\n if (typeof value !== 'undefined') {\r\n if (angular.isNumber(value)) {\r\n value = value + 'px';\r\n }\r\n return css.call(self, 'height', value);\r\n } else {\r\n return getWidthHeight(this[0], 'height', 'base');\r\n }\r\n },\r\n outerHeight(option) {\r\n return getWidthHeight(this[0], 'height', option ? 'outerfull' : 'outer');\r\n },\r\n outerWidth(option) {\r\n return getWidthHeight(this[0], 'width', option ? 'outerfull' : 'outer');\r\n },\r\n\r\n /*\r\n The offset setter method is not implemented\r\n */\r\n offset(value) {\r\n let docElem, win;\r\n let self = this;\r\n let box = {\r\n top: 0,\r\n left: 0\r\n };\r\n let elem = self[0];\r\n let doc = elem && elem.ownerDocument;\r\n\r\n if (arguments.length) {\r\n if (value === undefined) {\r\n return self;\r\n }\r\n // TODO: implement setter\r\n throw new Error('offset setter method is not implemented');\r\n }\r\n\r\n if (!doc) {\r\n return;\r\n }\r\n\r\n docElem = doc.documentElement;\r\n\r\n // TODO: Make sure it's not a disconnected DOM node\r\n\r\n if (elem.getBoundingClientRect != null) {\r\n box = elem.getBoundingClientRect();\r\n }\r\n\r\n win = doc.defaultView || doc.parentWindow;\r\n\r\n return {\r\n top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),\r\n left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)\r\n };\r\n },\r\n scrollTop(value) {\r\n return scrollTo(this, 'top', value);\r\n },\r\n scrollLeft(value) {\r\n return scrollTo(this, 'left', value);\r\n }\r\n }, (value, key) => {\r\n if (!element.prototype[key]) {\r\n return element.prototype[key] = value;\r\n }\r\n });\r\n }\r\n\r\n}\r\n","const hideClassToken = 'ng-ui-scroll-hide';\r\n\r\nexport default class ElementRoutines {\r\n\r\n static addCSSRules() {\r\n const selector = '.' + hideClassToken;\r\n const rules = 'display: none';\r\n const sheet = document.styleSheets[0];\r\n let index;\r\n try {\r\n index = sheet.cssRules.length;\r\n } catch (err) {\r\n index = 0;\r\n }\r\n if('insertRule' in sheet) {\r\n sheet.insertRule(selector + '{' + rules + '}', index);\r\n }\r\n else if('addRule' in sheet) {\r\n sheet.addRule(selector, rules, index);\r\n }\r\n }\r\n\r\n constructor($injector, $q) {\r\n this.$animate = ($injector.has && $injector.has('$animate')) ? $injector.get('$animate') : null;\r\n this.isAngularVersionLessThen1_3 = angular.version.major === 1 && angular.version.minor < 3;\r\n this.$q = $q;\r\n }\r\n\r\n hideElement(wrapper) {\r\n wrapper.element.addClass(hideClassToken);\r\n }\r\n\r\n showElement(wrapper) {\r\n wrapper.element.removeClass(hideClassToken);\r\n }\r\n\r\n insertElement(newElement, previousElement) {\r\n previousElement.after(newElement);\r\n return [];\r\n }\r\n\r\n removeElement(wrapper) {\r\n wrapper.element.remove();\r\n wrapper.scope.$destroy();\r\n return [];\r\n }\r\n\r\n insertElementAnimated(newElement, previousElement) {\r\n if (!this.$animate) {\r\n return this.insertElement(newElement, previousElement);\r\n }\r\n\r\n if (this.isAngularVersionLessThen1_3) {\r\n const deferred = this.$q.defer();\r\n // no need for parent - previous element is never null\r\n this.$animate.enter(newElement, null, previousElement, () => deferred.resolve());\r\n\r\n return [deferred.promise];\r\n }\r\n\r\n // no need for parent - previous element is never null\r\n return [this.$animate.enter(newElement, null, previousElement)];\r\n }\r\n\r\n removeElementAnimated(wrapper) {\r\n if (!this.$animate) {\r\n return this.removeElement(wrapper);\r\n }\r\n\r\n if (this.isAngularVersionLessThen1_3) {\r\n const deferred = this.$q.defer();\r\n this.$animate.leave(wrapper.element, () => {\r\n wrapper.scope.$destroy();\r\n return deferred.resolve();\r\n });\r\n\r\n return [deferred.promise];\r\n }\r\n\r\n return [(this.$animate.leave(wrapper.element)).then(() => wrapper.scope.$destroy())];\r\n }\r\n}","export default function ScrollBuffer(elementRoutines, bufferSize, startIndex) {\r\n const buffer = Object.create(Array.prototype);\r\n\r\n angular.extend(buffer, {\r\n size: bufferSize,\r\n\r\n reset(startIndex) {\r\n buffer.remove(0, buffer.length);\r\n buffer.eof = false;\r\n buffer.bof = false;\r\n buffer.first = startIndex;\r\n buffer.next = startIndex;\r\n buffer.minIndex = startIndex;\r\n buffer.maxIndex = startIndex;\r\n buffer.minIndexUser = null;\r\n buffer.maxIndexUser = null;\r\n },\r\n\r\n append(items) {\r\n items.forEach((item) => {\r\n ++buffer.next;\r\n buffer.insert('append', item);\r\n });\r\n buffer.maxIndex = buffer.eof ? buffer.next - 1 : Math.max(buffer.next - 1, buffer.maxIndex);\r\n },\r\n\r\n prepend(items) {\r\n items.reverse().forEach((item) => {\r\n --buffer.first;\r\n buffer.insert('prepend', item);\r\n });\r\n buffer.minIndex = buffer.bof ? buffer.minIndex = buffer.first : Math.min(buffer.first, buffer.minIndex);\r\n },\r\n\r\n /**\r\n * inserts wrapped element in the buffer\r\n * the first argument is either operation keyword (see below) or a number for operation 'insert'\r\n * for insert the number is the index for the buffer element the new one have to be inserted after\r\n * operations: 'append', 'prepend', 'insert', 'remove', 'update', 'none'\r\n */\r\n insert(operation, item, isTop) {\r\n const wrapper = {\r\n item: item\r\n };\r\n\r\n if (operation % 1 === 0) {// it is an insert\r\n wrapper.op = 'insert';\r\n buffer.splice(operation, 0, wrapper);\r\n if(isTop) {\r\n buffer.first--;\r\n }\r\n else {\r\n buffer.next++;\r\n }\r\n } else {\r\n wrapper.op = operation;\r\n switch (operation) {\r\n case 'append':\r\n buffer.push(wrapper);\r\n break;\r\n case 'prepend':\r\n buffer.unshift(wrapper);\r\n break;\r\n }\r\n }\r\n },\r\n\r\n // removes elements from buffer\r\n remove(arg1, arg2) {\r\n if (angular.isNumber(arg1)) {\r\n // removes items from arg1 (including) through arg2 (excluding)\r\n for (let i = arg1; i < arg2; i++) {\r\n elementRoutines.removeElement(buffer[i]);\r\n }\r\n return buffer.splice(arg1, arg2 - arg1);\r\n }\r\n // removes single item(wrapper) from the buffer\r\n buffer.splice(buffer.indexOf(arg1), 1);\r\n if(arg1._op === 'isTop' && buffer.first === this.getAbsMinIndex()) {\r\n this.incrementMinIndex();\r\n }\r\n else {\r\n this.decrementMaxIndex();\r\n }\r\n if(arg1._op === 'isTop') {\r\n buffer.first++;\r\n }\r\n else {\r\n buffer.next--;\r\n }\r\n if(!buffer.length) {\r\n buffer.first = 1;\r\n buffer.next = 1;\r\n }\r\n\r\n return elementRoutines.removeElementAnimated(arg1);\r\n },\r\n\r\n incrementMinIndex() {\r\n if(buffer.minIndexUser !== null) {\r\n if(buffer.minIndex > buffer.minIndexUser) {\r\n buffer.minIndexUser++;\r\n return;\r\n }\r\n if(buffer.minIndex === buffer.minIndexUser) {\r\n buffer.minIndexUser++;\r\n }\r\n }\r\n buffer.minIndex++;\r\n },\r\n\r\n decrementMaxIndex() {\r\n if(buffer.maxIndexUser !== null && buffer.maxIndex <= buffer.maxIndexUser) {\r\n buffer.maxIndexUser--;\r\n }\r\n buffer.maxIndex--;\r\n },\r\n\r\n getAbsMinIndex() {\r\n if(buffer.minIndexUser !== null) {\r\n return Math.min(buffer.minIndexUser, buffer.minIndex);\r\n }\r\n return buffer.minIndex;\r\n },\r\n\r\n getAbsMaxIndex() {\r\n if(buffer.maxIndexUser !== null) {\r\n return Math.max(buffer.maxIndexUser, buffer.maxIndex);\r\n }\r\n return buffer.maxIndex;\r\n },\r\n\r\n effectiveHeight(elements) {\r\n if (!elements.length) {\r\n return 0;\r\n }\r\n let top = Number.MAX_VALUE;\r\n let bottom = Number.NEGATIVE_INFINITY;\r\n elements.forEach((wrapper) => {\r\n if (wrapper.element[0].offsetParent) {\r\n // element style is not display:none\r\n top = Math.min(top, wrapper.element.offset().top);\r\n bottom = Math.max(bottom, wrapper.element.offset().top + wrapper.element.outerHeight(true));\r\n }\r\n });\r\n return Math.max(0, bottom - top);\r\n }\r\n\r\n });\r\n\r\n buffer.reset(startIndex);\r\n\r\n return buffer;\r\n}\r\n","// Can't just extend the Array, due to Babel does not support built-in classes extending\r\n// This solution was taken from https://stackoverflow.com/questions/46897414/es6-class-extends-array-workaround-for-es5-babel-transpile\r\nclass CacheProto {\r\n add(item) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index === item.scope.$index) {\r\n this[i].height = item.element.outerHeight();\r\n return;\r\n }\r\n }\r\n this.push({\r\n index: item.scope.$index,\r\n height: item.element.outerHeight()\r\n });\r\n this.sort((a, b) => ((a.index < b.index) ? -1 : ((a.index > b.index) ? 1 : 0)));\r\n }\r\n\r\n remove(argument, _isTop) {\r\n const index = argument % 1 === 0 ? argument : argument.scope.$index;\r\n const isTop = argument % 1 === 0 ? _isTop : argument._op === 'isTop';\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index === index) {\r\n this.splice(i, 1);\r\n break;\r\n }\r\n }\r\n if(!isTop) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index > index) {\r\n this[i].index--;\r\n }\r\n }\r\n }\r\n }\r\n\r\n clear() {\r\n this.length = 0;\r\n }\r\n}\r\n\r\nfunction Cache() {\r\n const instance = [];\r\n instance.push.apply(instance, arguments);\r\n Object.setPrototypeOf(instance, Cache.prototype);\r\n return instance;\r\n}\r\nCache.prototype = Object.create(Array.prototype);\r\nObject.getOwnPropertyNames(CacheProto.prototype).forEach(methodName =>\r\n Cache.prototype[methodName] = CacheProto.prototype[methodName]\r\n);\r\n\r\nfunction generateElement(template) {\r\n if(template.nodeType !== Node.ELEMENT_NODE) {\r\n throw new Error('ui-scroll directive requires an Element node for templating the view');\r\n }\r\n let element;\r\n switch (template.tagName.toLowerCase()) {\r\n case 'dl':\r\n throw new Error(`ui-scroll directive does not support <${template.tagName}> as a repeating tag: ${template.outerHTML}`);\r\n case 'tr':\r\n let table = angular.element('
');\r\n element = table.find('tr');\r\n break;\r\n case 'li':\r\n element = angular.element('
  • ');\r\n break;\r\n default:\r\n element = angular.element('
    ');\r\n }\r\n return element;\r\n}\r\n\r\nclass Padding {\r\n constructor(template) {\r\n this.element = generateElement(template);\r\n this.cache = new Cache();\r\n }\r\n\r\n height() {\r\n return this.element.height.apply(this.element, arguments);\r\n }\r\n}\r\n\r\nexport default Padding;","import Padding from './padding';\r\n\r\nexport default function Viewport(elementRoutines, buffer, element, viewportController, $rootScope, padding) {\r\n let topPadding = null;\r\n let bottomPadding = null;\r\n const viewport = viewportController && viewportController.viewport ? viewportController.viewport : angular.element(window);\r\n const container = viewportController && viewportController.container ? viewportController.container : undefined;\r\n const scope = viewportController && viewportController.scope ? viewportController.scope : $rootScope;\r\n\r\n viewport.css({\r\n 'overflow-anchor': 'none',\r\n 'overflow-y': 'auto',\r\n 'display': 'block'\r\n });\r\n\r\n function bufferPadding() {\r\n return viewport.outerHeight() * padding; // some extra space to initiate preload\r\n }\r\n\r\n angular.extend(viewport, {\r\n getScope() {\r\n return scope;\r\n },\r\n\r\n createPaddingElements(template) {\r\n topPadding = new Padding(template);\r\n bottomPadding = new Padding(template);\r\n element.before(topPadding.element);\r\n element.after(bottomPadding.element);\r\n topPadding.height(0);\r\n bottomPadding.height(0);\r\n },\r\n\r\n applyContainerStyle() {\r\n if (!container) {\r\n return true;\r\n }\r\n if(container !== viewport) {\r\n viewport.css('height', window.getComputedStyle(container[0]).height);\r\n }\r\n return viewport.height() > 0;\r\n },\r\n\r\n bottomDataPos() {\r\n let scrollHeight = viewport[0].scrollHeight;\r\n scrollHeight = scrollHeight != null ? scrollHeight : viewport[0].document.documentElement.scrollHeight;\r\n return scrollHeight - bottomPadding.height();\r\n },\r\n\r\n topDataPos() {\r\n return topPadding.height();\r\n },\r\n\r\n bottomVisiblePos() {\r\n return viewport.scrollTop() + viewport.outerHeight();\r\n },\r\n\r\n topVisiblePos() {\r\n return viewport.scrollTop();\r\n },\r\n\r\n insertElement(e, sibling) {\r\n return elementRoutines.insertElement(e, sibling || topPadding.element);\r\n },\r\n\r\n insertElementAnimated(e, sibling) {\r\n return elementRoutines.insertElementAnimated(e, sibling || topPadding.element);\r\n },\r\n\r\n shouldLoadBottom() {\r\n return !buffer.eof && viewport.bottomDataPos() < viewport.bottomVisiblePos() + bufferPadding();\r\n },\r\n\r\n clipBottom() {\r\n // clip the invisible items off the bottom\r\n let overage = 0;\r\n let overageHeight = 0;\r\n let itemHeight = 0;\r\n let emptySpaceHeight = viewport.bottomDataPos() - viewport.bottomVisiblePos() - bufferPadding();\r\n\r\n for (let i = buffer.length - 1; i >= 0; i--) {\r\n itemHeight = buffer[i].element.outerHeight(true);\r\n if (overageHeight + itemHeight > emptySpaceHeight) {\r\n break;\r\n }\r\n bottomPadding.cache.add(buffer[i]);\r\n overageHeight += itemHeight;\r\n overage++;\r\n }\r\n\r\n if (overage > 0) {\r\n buffer.eof = false;\r\n buffer.remove(buffer.length - overage, buffer.length);\r\n buffer.next -= overage;\r\n viewport.adjustPaddings();\r\n }\r\n },\r\n\r\n shouldLoadTop() {\r\n return !buffer.bof && (viewport.topDataPos() > viewport.topVisiblePos() - bufferPadding());\r\n },\r\n\r\n clipTop() {\r\n // clip the invisible items off the top\r\n let overage = 0;\r\n let overageHeight = 0;\r\n let itemHeight = 0;\r\n let emptySpaceHeight = viewport.topVisiblePos() - viewport.topDataPos() - bufferPadding();\r\n\r\n for (let i = 0; i < buffer.length; i++) {\r\n itemHeight = buffer[i].element.outerHeight(true);\r\n if (overageHeight + itemHeight > emptySpaceHeight) {\r\n break;\r\n }\r\n topPadding.cache.add(buffer[i]);\r\n overageHeight += itemHeight;\r\n overage++;\r\n }\r\n\r\n if (overage > 0) {\r\n // we need to adjust top padding element before items are removed from top\r\n // to avoid strange behaviour of scroll bar during remove top items when we are at the very bottom\r\n topPadding.height(topPadding.height() + overageHeight);\r\n buffer.bof = false;\r\n buffer.remove(0, overage);\r\n buffer.first += overage;\r\n }\r\n },\r\n\r\n adjustPaddings() {\r\n if (!buffer.length) {\r\n return;\r\n }\r\n\r\n // precise heights calculation based on items that are in buffer or that were in buffer once\r\n const visibleItemsHeight = buffer.reduce((summ, item) => summ + item.element.outerHeight(true), 0);\r\n\r\n let topPaddingHeight = 0, topCount = 0;\r\n topPadding.cache.forEach(item => {\r\n if(item.index < buffer.first) {\r\n topPaddingHeight += item.height;\r\n topCount++;\r\n }\r\n });\r\n\r\n let bottomPaddingHeight = 0, bottomCount = 0;\r\n bottomPadding.cache.forEach(item => {\r\n if(item.index >= buffer.next) {\r\n bottomPaddingHeight += item.height;\r\n bottomCount++;\r\n }\r\n });\r\n\r\n const totalHeight = visibleItemsHeight + topPaddingHeight + bottomPaddingHeight;\r\n const averageItemHeight = totalHeight / (topCount + bottomCount + buffer.length);\r\n\r\n // average heights calculation, items that have never been reached\r\n let adjustTopPadding = buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser;\r\n let adjustBottomPadding = buffer.maxIndexUser !== null && buffer.maxIndex < buffer.maxIndexUser;\r\n let topPaddingHeightAdd = adjustTopPadding ? (buffer.minIndex - buffer.minIndexUser) * averageItemHeight : 0;\r\n let bottomPaddingHeightAdd = adjustBottomPadding ? (buffer.maxIndexUser - buffer.maxIndex) * averageItemHeight : 0;\r\n\r\n // paddings combine adjustment\r\n topPadding.height(topPaddingHeight + topPaddingHeightAdd);\r\n bottomPadding.height(bottomPaddingHeight + bottomPaddingHeightAdd);\r\n },\r\n\r\n onAfterMinIndexSet(topPaddingHeightOld) {\r\n // additional scrollTop adjustment in case of datasource.minIndex external set\r\n if (buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser) {\r\n let diff = topPadding.height() - topPaddingHeightOld;\r\n viewport.scrollTop(viewport.scrollTop() + diff);\r\n while((diff -= viewport.scrollTop()) > 0) {\r\n bottomPadding.height(bottomPadding.height() + diff);\r\n viewport.scrollTop(viewport.scrollTop() + diff);\r\n }\r\n }\r\n },\r\n\r\n onAfterPrepend(updates) {\r\n if (!updates.prepended.length)\r\n return;\r\n const height = buffer.effectiveHeight(updates.prepended);\r\n const paddingHeight = topPadding.height() - height;\r\n if (paddingHeight >= 0) {\r\n topPadding.height(paddingHeight);\r\n }\r\n else {\r\n topPadding.height(0);\r\n viewport.scrollTop(viewport.scrollTop() - paddingHeight);\r\n }\r\n },\r\n\r\n resetTopPadding() {\r\n topPadding.height(0);\r\n topPadding.cache.clear();\r\n },\r\n\r\n resetBottomPadding() {\r\n bottomPadding.height(0);\r\n bottomPadding.cache.clear();\r\n },\r\n\r\n removeCacheItem(item, isTop) {\r\n topPadding.cache.remove(item, isTop);\r\n bottomPadding.cache.remove(item, isTop);\r\n },\r\n\r\n removeItem(item) {\r\n this.removeCacheItem(item);\r\n return buffer.remove(item);\r\n }\r\n });\r\n\r\n return viewport;\r\n}\r\n","class Adapter {\r\n\r\n constructor($scope, $parse, $attr, viewport, buffer, doAdjust, reload) {\r\n this.$parse = $parse;\r\n this.$attr = $attr;\r\n this.viewport = viewport;\r\n this.buffer = buffer;\r\n\r\n this.doAdjust = doAdjust;\r\n this.reload = reload;\r\n\r\n this.isLoading = false;\r\n this.disabled = false;\r\n\r\n const viewportScope = viewport.getScope();\r\n this.startScope = viewportScope.$parent ? viewportScope : $scope;\r\n\r\n this.publicContext = {};\r\n this.assignAdapter($attr.adapter);\r\n this.generatePublicContext();\r\n }\r\n\r\n assignAdapter(adapterAttr) {\r\n if (!adapterAttr || !(adapterAttr = adapterAttr.replace(/^\\s+|\\s+$/gm, ''))) {\r\n return;\r\n }\r\n let adapterOnScope;\r\n\r\n try {\r\n this.$parse(adapterAttr).assign(this.startScope, {});\r\n adapterOnScope = this.$parse(adapterAttr)(this.startScope);\r\n }\r\n catch (error) {\r\n error.message = `Angular ui-scroll Adapter assignment exception.\\n` +\r\n `Can't parse \"${adapterAttr}\" expression.\\n` +\r\n error.message;\r\n throw error;\r\n }\r\n\r\n angular.extend(adapterOnScope, this.publicContext);\r\n this.publicContext = adapterOnScope;\r\n }\r\n\r\n generatePublicContext() {\r\n // these methods will be accessible out of ui-scroll via user defined adapter\r\n const publicMethods = ['reload', 'applyUpdates', 'append', 'prepend', 'isBOF', 'isEOF', 'isEmpty'];\r\n for (let i = publicMethods.length - 1; i >= 0; i--) {\r\n this.publicContext[publicMethods[i]] = this[publicMethods[i]].bind(this);\r\n }\r\n\r\n // these read-only props will be accessible out of ui-scroll via user defined adapter\r\n const publicProps = ['isLoading', 'topVisible', 'topVisibleElement', 'topVisibleScope', 'bottomVisible', 'bottomVisibleElement', 'bottomVisibleScope'];\r\n for (let i = publicProps.length - 1; i >= 0; i--) {\r\n let property, attr = this.$attr[publicProps[i]];\r\n Object.defineProperty(this, publicProps[i], {\r\n get: () => property,\r\n set: (value) => {\r\n property = value;\r\n this.publicContext[publicProps[i]] = value;\r\n if (attr) {\r\n this.$parse(attr).assign(this.startScope, value);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // non-read-only public property\r\n Object.defineProperty(this.publicContext, 'disabled', {\r\n get: () => this.disabled,\r\n set: (value) => (!(this.disabled = value)) ? this.doAdjust() : null\r\n });\r\n }\r\n\r\n loading(value) {\r\n this.isLoading = value;\r\n }\r\n\r\n isBOF() {\r\n return this.buffer.bof;\r\n }\r\n\r\n isEOF() {\r\n return this.buffer.eof;\r\n }\r\n\r\n isEmpty() {\r\n return !this.buffer.length;\r\n }\r\n\r\n append(newItems) {\r\n this.buffer.append(newItems);\r\n this.doAdjust();\r\n this.viewport.clipTop();\r\n this.viewport.clipBottom();\r\n }\r\n\r\n prepend(newItems) {\r\n this.buffer.prepend(newItems);\r\n this.doAdjust();\r\n this.viewport.clipTop();\r\n this.viewport.clipBottom();\r\n }\r\n\r\n applyUpdates(arg1, arg2) {\r\n if (typeof arg1 === 'function') {\r\n this.applyUpdatesFunc(arg1);\r\n } else {\r\n this.applyUpdatesIndex(arg1, arg2);\r\n }\r\n this.doAdjust();\r\n }\r\n\r\n applyUpdatesFunc(cb) {\r\n this.buffer.slice(0).forEach((wrapper) => {\r\n // we need to do it on the buffer clone, because buffer content\r\n // may change as we iterate through\r\n this.applyUpdate(wrapper, cb(wrapper.item, wrapper.scope, wrapper.element));\r\n });\r\n }\r\n\r\n applyUpdatesIndex(index, newItems) {\r\n if (index % 1 !== 0) {\r\n throw new Error('applyUpdates - ' + index + ' is not a valid index (should be an integer)');\r\n }\r\n const _index = index - this.buffer.first;\r\n\r\n // apply updates only within buffer\r\n if (_index >= 0 && _index < this.buffer.length) {\r\n this.applyUpdate(this.buffer[_index], newItems);\r\n }\r\n // out-of-buffer case: deletion may affect Paddings\r\n else if(index >= this.buffer.getAbsMinIndex() && index <= this.buffer.getAbsMaxIndex()) {\r\n if(angular.isArray(newItems) && !newItems.length) {\r\n this.viewport.removeCacheItem(index, index === this.buffer.minIndex);\r\n if(index === this.buffer.getAbsMinIndex()) {\r\n this.buffer.incrementMinIndex();\r\n }\r\n else {\r\n this.buffer.decrementMaxIndex();\r\n }\r\n }\r\n }\r\n }\r\n\r\n applyUpdate(wrapper, newItems) {\r\n if (!angular.isArray(newItems)) {\r\n return;\r\n }\r\n let position = this.buffer.indexOf(wrapper);\r\n if (!newItems.reverse().some(newItem => newItem === wrapper.item)) {\r\n wrapper.op = 'remove';\r\n if(position === 0 && !newItems.length) {\r\n wrapper._op = 'isTop'; // to catch \"first\" edge case on remove\r\n }\r\n }\r\n newItems.forEach((newItem) => {\r\n if (newItem === wrapper.item) {\r\n position--;\r\n } else {\r\n // 3 parameter (isTop) is to catch \"first\" edge case on insert\r\n this.buffer.insert(position + 1, newItem, position === -1);\r\n }\r\n });\r\n }\r\n\r\n calculateProperties() {\r\n let rowTop = null, topHeight = 0;\r\n let topDone = false, bottomDone = false;\r\n const length = this.buffer.length;\r\n\r\n for (let i = 0; i < length; i++) {\r\n const item = this.buffer[i];\r\n const itemTop = item.element.offset().top;\r\n\r\n if (rowTop !== itemTop) { // a new row condition\r\n const itemHeight = item.element.outerHeight(true);\r\n const top = this.viewport.topDataPos() + topHeight + itemHeight;\r\n\r\n if (!topDone && top > this.viewport.topVisiblePos()) {\r\n topDone = true;\r\n this['topVisible'] = item.item;\r\n this['topVisibleElement'] = item.element;\r\n this['topVisibleScope'] = item.scope;\r\n }\r\n if (!bottomDone && (top >= this.viewport.bottomVisiblePos() || (i === length - 1 && this.isEOF()))) {\r\n bottomDone = true;\r\n this['bottomVisible'] = item.item;\r\n this['bottomVisibleElement'] = item.element;\r\n this['bottomVisibleScope'] = item.scope;\r\n }\r\n topHeight += itemHeight;\r\n }\r\n rowTop = itemTop;\r\n\r\n if (topDone && bottomDone) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n}\r\n\r\nexport default Adapter;\r\n","import JQLiteExtras from './modules/jqLiteExtras';\nimport ElementRoutines from './modules/elementRoutines.js';\nimport ScrollBuffer from './modules/buffer.js';\nimport Viewport from './modules/viewport.js';\nimport Adapter from './modules/adapter.js';\n\nangular.module('ui.scroll', [])\n\n .constant('JQLiteExtras', JQLiteExtras)\n .run(['JQLiteExtras', (JQLiteExtras) => {\n !window.jQuery ? (new JQLiteExtras()).registerFor(angular.element) : null;\n ElementRoutines.addCSSRules();\n }])\n\n .directive('uiScrollViewport', function () {\n return {\n restrict: 'A',\n controller: [\n '$scope',\n '$element',\n function (scope, element) {\n this.container = element;\n this.viewport = element;\n this.scope = scope;\n\n angular.forEach(element.children(), child => {\n if (child.tagName.toLowerCase() === 'tbody') {\n this.viewport = angular.element(child);\n }\n });\n\n return this;\n }\n ]\n };\n })\n\n .directive('uiScroll', [\n '$log',\n '$injector',\n '$rootScope',\n '$timeout',\n '$interval',\n '$q',\n '$parse',\n function (console, $injector, $rootScope, $timeout, $interval, $q, $parse) {\n\n return {\n require: ['?^uiScrollViewport'],\n restrict: 'A',\n transclude: 'element',\n priority: 1000,\n terminal: true,\n link: link\n };\n\n function link($scope, element, $attr, controllers, linker) {\n const match = $attr.uiScroll.match(/^\\s*(\\w+)\\s+in\\s+([(\\w|\\$)\\.]+)\\s*$/);\n if (!match) {\n throw new Error('Expected uiScroll in form of \\'_item_ in _datasource_\\' but got \\'' + $attr.uiScroll + '\\'');\n }\n\n function parseNumber(value, defaultValue, isFloat) {\n if (!isFloat) {\n value = value === null ? defaultValue : Math.floor(value);\n }\n return isNaN(value) ? defaultValue : value;\n }\n\n function parseNumericAttr(value, defaultValue, isFloat) {\n const result = $parse(value)($scope);\n return parseNumber(result, defaultValue, isFloat);\n }\n\n const BUFFER_MIN = 3;\n const BUFFER_DEFAULT = 10;\n const PADDING_MIN = 0.3;\n const PADDING_DEFAULT = 0.5;\n const START_INDEX_DEFAULT = 1;\n const MAX_VIEWPORT_DELAY = 500;\n const VIEWPORT_POLLING_INTERVAL = 50;\n\n let datasource = null;\n const itemName = match[1];\n const datasourceName = match[2];\n const viewportController = controllers[0];\n const bufferSize = Math.max(BUFFER_MIN, parseNumericAttr($attr.bufferSize, BUFFER_DEFAULT));\n const padding = Math.max(PADDING_MIN, parseNumericAttr($attr.padding, PADDING_DEFAULT, true));\n let startIndex = parseNumericAttr($attr.startIndex, START_INDEX_DEFAULT);\n let ridActual = 0; // current data revision id\n let pending = [];\n\n const elementRoutines = new ElementRoutines($injector, $q);\n const buffer = new ScrollBuffer(elementRoutines, bufferSize, startIndex);\n const viewport = new Viewport(elementRoutines, buffer, element, viewportController, $rootScope, padding);\n const adapter = new Adapter($scope, $parse, $attr, viewport, buffer, doAdjust, reload);\n\n if (viewportController) {\n viewportController.adapter = adapter;\n }\n\n const isDatasourceValid = () =>\n Object.prototype.toString.call(datasource) === '[object Object]' && typeof datasource.get === 'function';\n\n datasource = $parse(datasourceName)($scope); // try to get datasource on scope\n if (!isDatasourceValid()) {\n datasource = $injector.get(datasourceName); // try to inject datasource as service\n if (!isDatasourceValid()) {\n throw new Error(datasourceName + ' is not a valid datasource');\n }\n }\n\n let onRenderHandlers = [];\n function onRenderHandlersRunner() {\n onRenderHandlers.forEach(handler => handler.run());\n onRenderHandlers = [];\n }\n function persistDatasourceIndex(datasource, propName) {\n let getter;\n // need to postpone min/maxIndexUser processing if the view is empty\n if(angular.isNumber(datasource[propName])) {\n getter = datasource[propName];\n if(angular.isNumber(getter)) {\n onRenderHandlers = onRenderHandlers.filter(handler => handler.id !== propName);\n onRenderHandlers.push({\n id: propName,\n run: () => datasource[propName] = getter\n });\n }\n }\n }\n\n function defineDatasourceIndex(datasource, propName, propUserName) {\n const descriptor = Object.getOwnPropertyDescriptor(datasource, propName);\n if (descriptor && (descriptor.set || descriptor.get)) {\n return;\n }\n let getter;\n persistDatasourceIndex(datasource, propName);\n Object.defineProperty(datasource, propName, {\n set: (value) => {\n getter = value;\n if(pending.length && !buffer.length) {\n persistDatasourceIndex(datasource, propName);\n return;\n }\n buffer[propUserName] = value;\n const topPaddingHeightOld = viewport.topDataPos();\n viewport.adjustPaddings();\n if (propName === 'minIndex') {\n viewport.onAfterMinIndexSet(topPaddingHeightOld);\n }\n },\n get: () => getter\n });\n }\n\n defineDatasourceIndex(datasource, 'minIndex', 'minIndexUser');\n defineDatasourceIndex(datasource, 'maxIndex', 'maxIndexUser');\n\n const fetchNext = (datasource.get.length !== 2) ?\n (success) => datasource.get(buffer.next, bufferSize, success) :\n (success) => {\n datasource.get({\n index: buffer.next,\n append: buffer.length ? buffer[buffer.length - 1].item : void 0,\n count: bufferSize\n }, success);\n };\n\n const fetchPrevious = (datasource.get.length !== 2) ?\n (success) => datasource.get(buffer.first - bufferSize, bufferSize, success) :\n (success) => {\n datasource.get({\n index: buffer.first - bufferSize,\n prepend: buffer.length ? buffer[0].item : void 0,\n count: bufferSize\n }, success);\n };\n\n const initialize = () => {\n let tryCount = 0;\n if(!viewport.applyContainerStyle()) {\n const timer = $interval(() => {\n tryCount++;\n if(viewport.applyContainerStyle()) {\n $interval.cancel(timer);\n doAdjust();\n }\n if(tryCount * VIEWPORT_POLLING_INTERVAL >= MAX_VIEWPORT_DELAY) {\n $interval.cancel(timer);\n throw Error(`ui-scroll directive requires a viewport with non-zero height in ${MAX_VIEWPORT_DELAY}ms`);\n }\n }, VIEWPORT_POLLING_INTERVAL);\n }\n else {\n doAdjust();\n }\n };\n\n /**\n * Build padding elements\n *\n * Calling linker is the only way I found to get access to the tag name of the template\n * to prevent the directive scope from pollution a new scope is created and destroyed\n * right after the builder creation is completed\n */\n linker((clone, scope) => {\n viewport.createPaddingElements(clone[0]);\n // we do not include the clone in the DOM. It means that the nested directives will not\n // be able to reach the parent directives, but in this case it is intentional because we\n // created the clone to access the template tag name\n scope.$destroy();\n clone.remove();\n });\n\n $scope.$on('$destroy', () => {\n unbindEvents();\n viewport.unbind('mousewheel', wheelHandler);\n });\n\n viewport.bind('mousewheel', wheelHandler);\n\n initialize();\n\n /* Private function definitions */\n\n function isInvalid(rid) {\n return (rid && rid !== ridActual) || $scope.$$destroyed;\n }\n\n function bindEvents() {\n viewport.bind('resize', resizeAndScrollHandler);\n viewport.bind('scroll', resizeAndScrollHandler);\n }\n\n function unbindEvents() {\n viewport.unbind('resize', resizeAndScrollHandler);\n viewport.unbind('scroll', resizeAndScrollHandler);\n }\n\n function reload() {\n viewport.resetTopPadding();\n viewport.resetBottomPadding();\n if (arguments.length) {\n startIndex = parseNumber(arguments[0], START_INDEX_DEFAULT, false);\n }\n buffer.reset(startIndex);\n persistDatasourceIndex(datasource, 'minIndex');\n persistDatasourceIndex(datasource, 'maxIndex');\n doAdjust();\n }\n\n function isElementVisible(wrapper) {\n return wrapper.element.height() && wrapper.element[0].offsetParent;\n }\n\n function visibilityWatcher(wrapper) {\n if (isElementVisible(wrapper)) {\n buffer.forEach((item) => {\n if (typeof item.unregisterVisibilityWatcher === 'function') {\n item.unregisterVisibilityWatcher();\n delete item.unregisterVisibilityWatcher;\n }\n });\n if (!pending.length) {\n $timeout(() => doAdjust());\n }\n }\n }\n\n function insertWrapperContent(wrapper, insertAfter) {\n createElement(wrapper, insertAfter, viewport.insertElement);\n if (!isElementVisible(wrapper)) {\n wrapper.unregisterVisibilityWatcher = wrapper.scope.$watch(() => visibilityWatcher(wrapper));\n }\n elementRoutines.hideElement(wrapper); // hide inserted elements before data binding\n }\n\n function createElement(wrapper, insertAfter, insertElement) {\n let promises = null;\n const sibling = (insertAfter > 0) ? buffer[insertAfter - 1].element : undefined;\n linker((clone, scope) => {\n promises = insertElement(clone, sibling);\n wrapper.element = clone;\n wrapper.scope = scope;\n scope[itemName] = wrapper.item;\n });\n // ui-scroll-grid apply\n if (adapter.transform) {\n const tdInitializer = wrapper.scope.uiScrollTdInitializer;\n if (tdInitializer && tdInitializer.linking) {\n adapter.transform(wrapper.scope, wrapper.element);\n } else {\n wrapper.scope.uiScrollTdInitializer = {\n onLink: () => adapter.transform(wrapper.scope, wrapper.element),\n scope: wrapper.scope\n };\n }\n }\n return promises;\n }\n\n function updateDOM() {\n let promises = [];\n const toBePrepended = [];\n const toBeRemoved = [];\n const inserted = [];\n\n buffer.forEach((wrapper, i) => {\n switch (wrapper.op) {\n case 'prepend':\n toBePrepended.unshift(wrapper);\n break;\n case 'append':\n insertWrapperContent(wrapper, i);\n wrapper.op = 'none';\n inserted.push(wrapper);\n break;\n case 'insert':\n promises = promises.concat(createElement(wrapper, i, viewport.insertElementAnimated));\n wrapper.op = 'none';\n inserted.push(wrapper);\n break;\n case 'remove':\n toBeRemoved.push(wrapper);\n }\n });\n\n toBeRemoved.forEach((wrapper) => promises = promises.concat(viewport.removeItem(wrapper)));\n\n if (toBePrepended.length)\n toBePrepended.forEach((wrapper) => {\n insertWrapperContent(wrapper);\n wrapper.op = 'none';\n });\n\n buffer.forEach((item, i) => item.scope.$index = buffer.first + i);\n\n return {\n prepended: toBePrepended,\n removed: toBeRemoved,\n inserted: inserted,\n animated: promises\n };\n\n }\n\n function updatePaddings(rid, updates) {\n // schedule another doAdjust after animation completion\n if (updates.animated.length) {\n $q.all(updates.animated).then(() => {\n viewport.adjustPaddings();\n doAdjust(rid);\n });\n } else {\n viewport.adjustPaddings();\n }\n }\n\n function enqueueFetch(rid, updates) {\n if (viewport.shouldLoadBottom()) {\n if (!updates || buffer.effectiveHeight(updates.inserted) > 0) {\n // this means that at least one item appended in the last batch has height > 0\n if (pending.push(true) === 1) {\n adapter.loading(true);\n fetch(rid);\n }\n }\n } else if (viewport.shouldLoadTop()) {\n if ((!updates || buffer.effectiveHeight(updates.prepended) > 0) || pending[0]) {\n // this means that at least one item appended in the last batch has height > 0\n // pending[0] = true means that previous fetch was appending. We need to force at least one prepend\n // BTW there will always be at least 1 element in the pending array because bottom is fetched first\n if (pending.push(false) === 1) {\n adapter.loading(true);\n fetch(rid);\n }\n }\n }\n }\n\n function processUpdates() {\n const updates = updateDOM();\n\n // We need the item bindings to be processed before we can do adjustments\n !$scope.$$phase && !$rootScope.$$phase && $scope.$digest();\n\n updates.inserted.forEach(w => elementRoutines.showElement(w));\n updates.prepended.forEach(w => elementRoutines.showElement(w));\n return updates;\n }\n\n function doAdjust(rid) {\n if (!rid) { // dismiss pending requests\n pending = [];\n rid = ++ridActual;\n }\n\n const updates = processUpdates();\n\n if (isInvalid(rid)) {\n return;\n }\n\n updatePaddings(rid, updates);\n enqueueFetch(rid);\n\n if (!pending.length) {\n adapter.calculateProperties();\n }\n }\n\n function doAdjustAfterFetch(rid) {\n const updates = processUpdates();\n\n viewport.onAfterPrepend(updates);\n\n if (isInvalid(rid)) {\n return;\n }\n\n updatePaddings(rid, updates);\n onRenderHandlersRunner();\n enqueueFetch(rid, updates);\n pending.shift();\n\n if (pending.length)\n fetch(rid);\n else {\n adapter.loading(false);\n bindEvents();\n adapter.calculateProperties();\n }\n }\n\n function fetch(rid) {\n if (pending[0]) {// scrolling down\n if (buffer.length && !viewport.shouldLoadBottom()) {\n doAdjustAfterFetch(rid);\n } else {\n fetchNext((result) => {\n if (isInvalid(rid)) {\n return;\n }\n\n if (result.length < bufferSize) {\n buffer.eof = true;\n }\n\n if (result.length > 0) {\n viewport.clipTop();\n buffer.append(result);\n }\n\n doAdjustAfterFetch(rid);\n });\n }\n } else { // scrolling up\n if (buffer.length && !viewport.shouldLoadTop()) {\n doAdjustAfterFetch(rid);\n } else {\n fetchPrevious((result) => {\n if (isInvalid(rid)) {\n return;\n }\n\n if (result.length < bufferSize) {\n buffer.bof = true;\n // log 'bof is reached'\n }\n\n if (result.length > 0) {\n if (buffer.length) {\n viewport.clipBottom();\n }\n buffer.prepend(result);\n }\n\n doAdjustAfterFetch(rid);\n });\n }\n }\n }\n\n function resizeAndScrollHandler() {\n if (!$rootScope.$$phase && !adapter.isLoading && !adapter.disabled) {\n\n enqueueFetch(ridActual);\n\n if (pending.length) {\n unbindEvents();\n } else {\n adapter.calculateProperties();\n !$scope.$$phase && $scope.$digest();\n }\n }\n }\n\n function wheelHandler(event) {\n if (!adapter.disabled) {\n const scrollTop = viewport[0].scrollTop;\n const yMax = viewport[0].scrollHeight - viewport[0].clientHeight;\n\n if ((scrollTop === 0 && !buffer.bof) || (scrollTop === yMax && !buffer.eof)) {\n event.preventDefault();\n }\n }\n }\n }\n\n }\n ]);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/modules/jqLiteExtras.js","webpack:///./src/modules/elementRoutines.js","webpack:///./src/modules/buffer.js","webpack:///./src/modules/padding.js","webpack:///./src/modules/viewport.js","webpack:///./src/modules/adapter.js","webpack:///./src/ui-scroll.js"],"names":["JQLiteExtras","element","convertToPx","css","getStyle","isWindow","angular","prototype","name","value","self","elem","nodeType","style","call","obj","document","location","alert","setInterval","scrollTo","direction","top","left","method","prop","preserve","isValueDefined","documentElement","window","getComputedStyle","parseFloat","currentStyle","result","rs","rsLeft","core_pnum","source","rnumnonpx","RegExp","test","runtimeStyle","pixelLeft","getMeasurements","measure","base","borderA","borderB","computedMarginA","computedMarginB","computedStyle","dirA","dirB","marginA","marginB","paddingA","paddingB","height","width","padding","border","margin","offsetWidth","offsetHeight","getWidthHeight","measurements","outer","outerfull","forEach","before","newElem","children","i","j","parent","ref","contents","prepend","length","after","Error","outerHTML","isNumber","outerHeight","option","outerWidth","offset","docElem","win","box","doc","ownerDocument","arguments","undefined","getBoundingClientRect","defaultView","parentWindow","pageYOffset","scrollTop","clientTop","pageXOffset","scrollLeft","clientLeft","key","hideClassToken","ElementRoutines","selector","rules","sheet","styleSheets","index","cssRules","err","insertRule","addRule","$injector","$q","$animate","has","get","isAngularVersionLessThen1_3","version","major","minor","wrapper","addClass","removeClass","newElement","previousElement","remove","scope","$destroy","insertElement","deferred","defer","enter","resolve","promise","removeElement","leave","then","ScrollBuffer","elementRoutines","bufferSize","startIndex","buffer","Object","create","Array","extend","size","reset","eof","bof","first","next","minIndex","maxIndex","minIndexUser","maxIndexUser","append","items","item","insert","Math","max","reverse","min","operation","isTop","op","splice","push","unshift","arg1","arg2","indexOf","_op","getAbsMinIndex","incrementMinIndex","decrementMaxIndex","removeElementAnimated","getAbsMaxIndex","effectiveHeight","elements","Number","MAX_VALUE","bottom","NEGATIVE_INFINITY","offsetParent","CacheProto","$index","sort","a","b","argument","_isTop","Cache","instance","apply","setPrototypeOf","getOwnPropertyNames","methodName","generateElement","template","Node","ELEMENT_NODE","tagName","toLowerCase","table","find","Padding","cache","Viewport","viewportController","$rootScope","topPadding","bottomPadding","viewport","container","bufferPadding","getScope","createPaddingElements","applyContainerStyle","bottomDataPos","scrollHeight","topDataPos","bottomVisiblePos","topVisiblePos","e","sibling","insertElementAnimated","shouldLoadBottom","clipBottom","overage","overageHeight","itemHeight","emptySpaceHeight","add","adjustPaddings","shouldLoadTop","clipTop","visibleItemsHeight","reduce","summ","topPaddingHeight","topCount","bottomPaddingHeight","bottomCount","totalHeight","averageItemHeight","adjustTopPadding","adjustBottomPadding","topPaddingHeightAdd","bottomPaddingHeightAdd","onAfterMinIndexSet","topPaddingHeightOld","diff","onAfterPrepend","updates","prepended","paddingHeight","resetTopPadding","clear","resetBottomPadding","removeCacheItem","removeItem","Adapter","$scope","$parse","$attr","doAdjust","reload","isLoading","disabled","viewportScope","startScope","$parent","publicContext","assignAdapter","adapter","generatePublicContext","adapterAttr","replace","adapterOnScope","assign","error","message","publicMethods","bind","publicProps","property","attr","defineProperty","set","newItems","applyUpdatesFunc","applyUpdatesIndex","cb","slice","applyUpdate","_index","isArray","position","some","newItem","rowTop","topHeight","topDone","bottomDone","itemTop","isEOF","module","constant","run","elt","jQuery","fn","jquery","registerFor","addCSSRules","directive","restrict","controller","child","console","$timeout","$interval","require","transclude","priority","terminal","link","controllers","linker","match","uiScroll","parseNumber","defaultValue","isFloat","floor","isNaN","parseNumericAttr","BUFFER_MIN","BUFFER_DEFAULT","PADDING_MIN","PADDING_DEFAULT","START_INDEX_DEFAULT","MAX_VIEWPORT_DELAY","VIEWPORT_POLLING_INTERVAL","datasource","itemName","datasourceName","ridActual","pending","isDatasourceValid","toString","onRenderHandlers","onRenderHandlersRunner","handler","persistDatasourceIndex","propName","getter","filter","id","defineDatasourceIndex","propUserName","descriptor","getOwnPropertyDescriptor","fetchNext","success","count","fetchPrevious","initialize","tryCount","timer","cancel","clone","$on","unbindEvents","unbind","wheelHandler","isInvalid","rid","$$destroyed","bindEvents","resizeAndScrollHandler","isElementVisible","visibilityWatcher","unregisterVisibilityWatcher","insertWrapperContent","insertAfter","createElement","$watch","hideElement","promises","transform","tdInitializer","uiScrollTdInitializer","linking","onLink","updateDOM","toBePrepended","toBeRemoved","inserted","concat","removed","animated","updatePaddings","all","enqueueFetch","loading","fetch","processUpdates","$$phase","$digest","w","showElement","calculateProperties","doAdjustAfterFetch","shift","event","yMax","clientHeight","preventDefault"],"mappings":";;;;;;;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AClFA;;;;;;;;;;IAWqBA,yB;;;;;;;;;gCAEPC,O,EAAS;AACnB,UAAIC,WAAJ,EAAiBC,GAAjB,EAAsBC,QAAtB,EAAgCC,QAAhC,CADmB,CAEnB;;AACAF,SAAG,GAAGG,OAAO,CAACL,OAAR,CAAgBM,SAAhB,CAA0BJ,GAAhC;;AAEAF,aAAO,CAACM,SAAR,CAAkBJ,GAAlB,GAAwB,UAAUK,IAAV,EAAgBC,KAAhB,EAAuB;AAC7C,YAAIC,IAAI,GAAG,IAAX;AACA,YAAIC,IAAI,GAAGD,IAAI,CAAC,CAAD,CAAf;;AACA,YAAI,EAAE,CAACC,IAAD,IAASA,IAAI,CAACC,QAAL,KAAkB,CAA3B,IAAgCD,IAAI,CAACC,QAAL,KAAkB,CAAlD,IAAuD,CAACD,IAAI,CAACE,KAA/D,CAAJ,EAA2E;AACzE,iBAAOV,GAAG,CAACW,IAAJ,CAASJ,IAAT,EAAeF,IAAf,EAAqBC,KAArB,CAAP;AACD;AACF,OAND,CALmB,CAanB;;;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AElEwI,oBAAY,CAACzD,SAAD,CAAZ;;AAEA,YAAIC,OAAO,CAACpR,MAAZ,EAAoB;AAClB6S,sBAAY;AACb,SAFD,MAEO;AACLnG,iBAAO,CAAC0I,mBAAR;AACA,WAACtJ,MAAM,CAACkJ,OAAR,IAAmBlJ,MAAM,CAACmJ,OAAP,EAAnB;AACD;AACF;AACF;;AAED,aAASlC,YAAT,CAAsBwC,KAAtB,EAA6B;AAC3B,UAAI,CAAC7I,OAAO,CAACN,QAAb,EAAuB;AACrB,YAAMhL,SAAS,GAAGwH,QAAQ,CAAC,CAAD,CAAR,CAAYxH,SAA9B;AACA,YAAMoU,IAAI,GAAG5M,QAAQ,CAAC,CAAD,CAAR,CAAYO,YAAZ,GAA2BP,QAAQ,CAAC,CAAD,CAAR,CAAY6M,YAApD;;AAEA,YAAKrU,SAAS,KAAK,CAAd,IAAmB,CAAC+C,MAAM,CAACQ,GAA5B,IAAqCvD,SAAS,KAAKoU,IAAd,IAAsB,CAACrR,MAAM,CAACO,GAAvE,EAA6E;AAC3E6Q,eAAK,CAACG,cAAN;AACD;AACF;AACF;AACF;AAEF,CA1doB,CAhCzB,E","file":"ui-scroll.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","/*!\r\n globals: angular, window\r\n List of used element methods available in JQuery but not in JQuery Lite\r\n element.before(elem)\r\n element.height()\r\n element.outerHeight(true)\r\n element.height(value) = only for Top/Bottom padding elements\r\n element.scrollTop()\r\n element.scrollTop(value)\r\n */\r\n\r\nexport default class JQLiteExtras {\r\n\r\n registerFor(element) {\r\n let convertToPx, css, getStyle, isWindow;\r\n // angular implementation blows up if elem is the window\r\n css = angular.element.prototype.css;\r\n\r\n element.prototype.css = function (name, value) {\r\n let self = this;\r\n let elem = self[0];\r\n if (!(!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style)) {\r\n return css.call(self, name, value);\r\n }\r\n };\r\n\r\n // as defined in angularjs v1.0.5\r\n isWindow = (obj) => obj && obj.document && obj.location && obj.alert && obj.setInterval;\r\n\r\n function scrollTo(self, direction, value) {\r\n let elem = self[0];\r\n let [method, prop, preserve] = {\r\n top: [\r\n 'scrollTop',\r\n 'pageYOffset',\r\n 'scrollLeft'\r\n ],\r\n left: [\r\n 'scrollLeft',\r\n 'pageXOffset',\r\n 'scrollTop'\r\n ]\r\n }[direction];\r\n\r\n const isValueDefined = typeof value !== 'undefined';\r\n if (isWindow(elem)) {\r\n if (isValueDefined) {\r\n return elem.scrollTo(self[preserve].call(self), value);\r\n }\r\n return (prop in elem) ? elem[prop] : elem.document.documentElement[method];\r\n } else {\r\n if (isValueDefined) {\r\n elem[method] = value;\r\n }\r\n return elem[method];\r\n }\r\n }\r\n\r\n if (window.getComputedStyle) {\r\n getStyle = (elem) => window.getComputedStyle(elem, null);\r\n convertToPx = (elem, value) => parseFloat(value);\r\n } else {\r\n getStyle = (elem) => elem.currentStyle;\r\n convertToPx = (elem, value) => {\r\n let left, result, rs, rsLeft, style;\r\n let core_pnum = /[+-]?(?:\\d*\\.|)\\d+(?:[eE][+-]?\\d+|)/.source;\r\n let rnumnonpx = new RegExp('^(' + core_pnum + ')(?!px)[a-z%]+$', 'i');\r\n\r\n if (!rnumnonpx.test(value)) {\r\n return parseFloat(value);\r\n }\r\n\r\n // ported from JQuery\r\n style = elem.style;\r\n left = style.left;\r\n rs = elem.runtimeStyle;\r\n rsLeft = rs && rs.left;\r\n if (rs) {\r\n rs.left = style.left;\r\n }\r\n // put in the new values to get a computed style out\r\n style.left = value;\r\n result = style.pixelLeft;\r\n style.left = left;\r\n if (rsLeft) {\r\n rs.left = rsLeft;\r\n }\r\n return result;\r\n };\r\n }\r\n\r\n function getMeasurements(elem, measure) {\r\n let base, borderA, borderB, computedMarginA, computedMarginB, computedStyle, dirA, dirB, marginA, marginB, paddingA, paddingB;\r\n\r\n if (isWindow(elem)) {\r\n base = document.documentElement[{height: 'clientHeight', width: 'clientWidth'}[measure]];\r\n\r\n return {\r\n base: base,\r\n padding: 0,\r\n border: 0,\r\n margin: 0\r\n };\r\n }\r\n\r\n // Start with offset property\r\n [\r\n base,\r\n dirA,\r\n dirB\r\n ] = {\r\n width: [\r\n elem.offsetWidth,\r\n 'Left',\r\n 'Right'\r\n ],\r\n height: [\r\n elem.offsetHeight,\r\n 'Top',\r\n 'Bottom'\r\n ]\r\n }[measure];\r\n\r\n computedStyle = getStyle(elem);\r\n paddingA = convertToPx(elem, computedStyle['padding' + dirA]) || 0;\r\n paddingB = convertToPx(elem, computedStyle['padding' + dirB]) || 0;\r\n borderA = convertToPx(elem, computedStyle['border' + dirA + 'Width']) || 0;\r\n borderB = convertToPx(elem, computedStyle['border' + dirB + 'Width']) || 0;\r\n computedMarginA = computedStyle['margin' + dirA];\r\n computedMarginB = computedStyle['margin' + dirB];\r\n\r\n // I do not care for width for now, so this hack is irrelevant\r\n // if ( !supportsPercentMargin )\r\n // computedMarginA = hackPercentMargin( elem, computedStyle, computedMarginA )\r\n // computedMarginB = hackPercentMargin( elem, computedStyle, computedMarginB )\r\n marginA = convertToPx(elem, computedMarginA) || 0;\r\n marginB = convertToPx(elem, computedMarginB) || 0;\r\n\r\n return {\r\n base: base,\r\n padding: paddingA + paddingB,\r\n border: borderA + borderB,\r\n margin: marginA + marginB\r\n };\r\n }\r\n\r\n function getWidthHeight(elem, direction, measure) {\r\n let computedStyle, result;\r\n\r\n let measurements = getMeasurements(elem, direction);\r\n\r\n if (measurements.base > 0) {\r\n return {\r\n base: measurements.base - measurements.padding - measurements.border,\r\n outer: measurements.base,\r\n outerfull: measurements.base + measurements.margin\r\n }[measure];\r\n }\r\n\r\n // Fall back to computed then uncomputed css if necessary\r\n computedStyle = getStyle(elem);\r\n result = computedStyle[direction];\r\n\r\n if (result < 0 || result === null) {\r\n result = elem.style[direction] || 0;\r\n }\r\n\r\n // Normalize \"\", auto, and prepare for extra\r\n result = parseFloat(result) || 0;\r\n\r\n return {\r\n base: result - measurements.padding - measurements.border,\r\n outer: result,\r\n outerfull: result + measurements.padding + measurements.border + measurements.margin\r\n }[measure];\r\n }\r\n\r\n // define missing methods\r\n return angular.forEach({\r\n before(newElem) {\r\n var children, elem, i, j, parent, ref, self;\r\n self = this;\r\n elem = self[0];\r\n parent = self.parent();\r\n children = parent.contents();\r\n if (children[0] === elem) {\r\n return parent.prepend(newElem);\r\n } else {\r\n for (i = j = 1, ref = children.length - 1; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {\r\n if (children[i] === elem) {\r\n angular.element(children[i - 1]).after(newElem);\r\n return;\r\n }\r\n }\r\n throw new Error('invalid DOM structure ' + elem.outerHTML);\r\n }\r\n },\r\n height (value){\r\n var self;\r\n self = this;\r\n if (typeof value !== 'undefined') {\r\n if (angular.isNumber(value)) {\r\n value = value + 'px';\r\n }\r\n return css.call(self, 'height', value);\r\n } else {\r\n return getWidthHeight(this[0], 'height', 'base');\r\n }\r\n },\r\n outerHeight(option) {\r\n return getWidthHeight(this[0], 'height', option ? 'outerfull' : 'outer');\r\n },\r\n outerWidth(option) {\r\n return getWidthHeight(this[0], 'width', option ? 'outerfull' : 'outer');\r\n },\r\n\r\n /*\r\n The offset setter method is not implemented\r\n */\r\n offset(value) {\r\n let docElem, win;\r\n let self = this;\r\n let box = {\r\n top: 0,\r\n left: 0\r\n };\r\n let elem = self[0];\r\n let doc = elem && elem.ownerDocument;\r\n\r\n if (arguments.length) {\r\n if (value === undefined) {\r\n return self;\r\n }\r\n // TODO: implement setter\r\n throw new Error('offset setter method is not implemented');\r\n }\r\n\r\n if (!doc) {\r\n return;\r\n }\r\n\r\n docElem = doc.documentElement;\r\n\r\n // TODO: Make sure it's not a disconnected DOM node\r\n\r\n if (elem.getBoundingClientRect != null) {\r\n box = elem.getBoundingClientRect();\r\n }\r\n\r\n win = doc.defaultView || doc.parentWindow;\r\n\r\n return {\r\n top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),\r\n left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)\r\n };\r\n },\r\n scrollTop(value) {\r\n return scrollTo(this, 'top', value);\r\n },\r\n scrollLeft(value) {\r\n return scrollTo(this, 'left', value);\r\n }\r\n }, (value, key) => {\r\n if (!element.prototype[key]) {\r\n return element.prototype[key] = value;\r\n }\r\n });\r\n }\r\n\r\n}\r\n","const hideClassToken = 'ng-ui-scroll-hide';\r\n\r\nexport default class ElementRoutines {\r\n\r\n static addCSSRules() {\r\n const selector = '.' + hideClassToken;\r\n const rules = 'display: none';\r\n const sheet = document.styleSheets[0];\r\n let index;\r\n try {\r\n index = sheet.cssRules.length;\r\n } catch (err) {\r\n index = 0;\r\n }\r\n if('insertRule' in sheet) {\r\n sheet.insertRule(selector + '{' + rules + '}', index);\r\n }\r\n else if('addRule' in sheet) {\r\n sheet.addRule(selector, rules, index);\r\n }\r\n }\r\n\r\n constructor($injector, $q) {\r\n this.$animate = ($injector.has && $injector.has('$animate')) ? $injector.get('$animate') : null;\r\n this.isAngularVersionLessThen1_3 = angular.version.major === 1 && angular.version.minor < 3;\r\n this.$q = $q;\r\n }\r\n\r\n hideElement(wrapper) {\r\n wrapper.element.addClass(hideClassToken);\r\n }\r\n\r\n showElement(wrapper) {\r\n wrapper.element.removeClass(hideClassToken);\r\n }\r\n\r\n insertElement(newElement, previousElement) {\r\n previousElement.after(newElement);\r\n return [];\r\n }\r\n\r\n removeElement(wrapper) {\r\n wrapper.element.remove();\r\n wrapper.scope.$destroy();\r\n return [];\r\n }\r\n\r\n insertElementAnimated(newElement, previousElement) {\r\n if (!this.$animate) {\r\n return this.insertElement(newElement, previousElement);\r\n }\r\n\r\n if (this.isAngularVersionLessThen1_3) {\r\n const deferred = this.$q.defer();\r\n // no need for parent - previous element is never null\r\n this.$animate.enter(newElement, null, previousElement, () => deferred.resolve());\r\n\r\n return [deferred.promise];\r\n }\r\n\r\n // no need for parent - previous element is never null\r\n return [this.$animate.enter(newElement, null, previousElement)];\r\n }\r\n\r\n removeElementAnimated(wrapper) {\r\n if (!this.$animate) {\r\n return this.removeElement(wrapper);\r\n }\r\n\r\n if (this.isAngularVersionLessThen1_3) {\r\n const deferred = this.$q.defer();\r\n this.$animate.leave(wrapper.element, () => {\r\n wrapper.scope.$destroy();\r\n return deferred.resolve();\r\n });\r\n\r\n return [deferred.promise];\r\n }\r\n\r\n return [(this.$animate.leave(wrapper.element)).then(() => wrapper.scope.$destroy())];\r\n }\r\n}","export default function ScrollBuffer(elementRoutines, bufferSize, startIndex) {\r\n const buffer = Object.create(Array.prototype);\r\n\r\n angular.extend(buffer, {\r\n size: bufferSize,\r\n\r\n reset(startIndex) {\r\n buffer.remove(0, buffer.length);\r\n buffer.eof = false;\r\n buffer.bof = false;\r\n buffer.first = startIndex;\r\n buffer.next = startIndex;\r\n buffer.minIndex = startIndex;\r\n buffer.maxIndex = startIndex;\r\n buffer.minIndexUser = null;\r\n buffer.maxIndexUser = null;\r\n },\r\n\r\n append(items) {\r\n items.forEach((item) => {\r\n ++buffer.next;\r\n buffer.insert('append', item);\r\n });\r\n buffer.maxIndex = buffer.eof ? buffer.next - 1 : Math.max(buffer.next - 1, buffer.maxIndex);\r\n },\r\n\r\n prepend(items) {\r\n items.reverse().forEach((item) => {\r\n --buffer.first;\r\n buffer.insert('prepend', item);\r\n });\r\n buffer.minIndex = buffer.bof ? buffer.minIndex = buffer.first : Math.min(buffer.first, buffer.minIndex);\r\n },\r\n\r\n /**\r\n * inserts wrapped element in the buffer\r\n * the first argument is either operation keyword (see below) or a number for operation 'insert'\r\n * for insert the number is the index for the buffer element the new one have to be inserted after\r\n * operations: 'append', 'prepend', 'insert', 'remove', 'update', 'none'\r\n */\r\n insert(operation, item, isTop) {\r\n const wrapper = {\r\n item: item\r\n };\r\n\r\n if (operation % 1 === 0) {// it is an insert\r\n wrapper.op = 'insert';\r\n buffer.splice(operation, 0, wrapper);\r\n if(isTop) {\r\n buffer.first--;\r\n }\r\n else {\r\n buffer.next++;\r\n }\r\n } else {\r\n wrapper.op = operation;\r\n switch (operation) {\r\n case 'append':\r\n buffer.push(wrapper);\r\n break;\r\n case 'prepend':\r\n buffer.unshift(wrapper);\r\n break;\r\n }\r\n }\r\n },\r\n\r\n // removes elements from buffer\r\n remove(arg1, arg2) {\r\n if (angular.isNumber(arg1)) {\r\n // removes items from arg1 (including) through arg2 (excluding)\r\n for (let i = arg1; i < arg2; i++) {\r\n elementRoutines.removeElement(buffer[i]);\r\n }\r\n return buffer.splice(arg1, arg2 - arg1);\r\n }\r\n // removes single item(wrapper) from the buffer\r\n buffer.splice(buffer.indexOf(arg1), 1);\r\n if(arg1._op === 'isTop' && buffer.first === this.getAbsMinIndex()) {\r\n this.incrementMinIndex();\r\n }\r\n else {\r\n this.decrementMaxIndex();\r\n }\r\n if(arg1._op === 'isTop') {\r\n buffer.first++;\r\n }\r\n else {\r\n buffer.next--;\r\n }\r\n if(!buffer.length) {\r\n buffer.first = 1;\r\n buffer.next = 1;\r\n }\r\n\r\n return elementRoutines.removeElementAnimated(arg1);\r\n },\r\n\r\n incrementMinIndex() {\r\n if(buffer.minIndexUser !== null) {\r\n if(buffer.minIndex > buffer.minIndexUser) {\r\n buffer.minIndexUser++;\r\n return;\r\n }\r\n if(buffer.minIndex === buffer.minIndexUser) {\r\n buffer.minIndexUser++;\r\n }\r\n }\r\n buffer.minIndex++;\r\n },\r\n\r\n decrementMaxIndex() {\r\n if(buffer.maxIndexUser !== null && buffer.maxIndex <= buffer.maxIndexUser) {\r\n buffer.maxIndexUser--;\r\n }\r\n buffer.maxIndex--;\r\n },\r\n\r\n getAbsMinIndex() {\r\n if(buffer.minIndexUser !== null) {\r\n return Math.min(buffer.minIndexUser, buffer.minIndex);\r\n }\r\n return buffer.minIndex;\r\n },\r\n\r\n getAbsMaxIndex() {\r\n if(buffer.maxIndexUser !== null) {\r\n return Math.max(buffer.maxIndexUser, buffer.maxIndex);\r\n }\r\n return buffer.maxIndex;\r\n },\r\n\r\n effectiveHeight(elements) {\r\n if (!elements.length) {\r\n return 0;\r\n }\r\n let top = Number.MAX_VALUE;\r\n let bottom = Number.NEGATIVE_INFINITY;\r\n elements.forEach((wrapper) => {\r\n if (wrapper.element[0].offsetParent) {\r\n // element style is not display:none\r\n top = Math.min(top, wrapper.element.offset().top);\r\n bottom = Math.max(bottom, wrapper.element.offset().top + wrapper.element.outerHeight(true));\r\n }\r\n });\r\n return Math.max(0, bottom - top);\r\n }\r\n\r\n });\r\n\r\n buffer.reset(startIndex);\r\n\r\n return buffer;\r\n}\r\n","// Can't just extend the Array, due to Babel does not support built-in classes extending\r\n// This solution was taken from https://stackoverflow.com/questions/46897414/es6-class-extends-array-workaround-for-es5-babel-transpile\r\nclass CacheProto {\r\n add(item) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index === item.scope.$index) {\r\n this[i].height = item.element.outerHeight();\r\n return;\r\n }\r\n }\r\n this.push({\r\n index: item.scope.$index,\r\n height: item.element.outerHeight()\r\n });\r\n this.sort((a, b) => ((a.index < b.index) ? -1 : ((a.index > b.index) ? 1 : 0)));\r\n }\r\n\r\n remove(argument, _isTop) {\r\n const index = argument % 1 === 0 ? argument : argument.scope.$index;\r\n const isTop = argument % 1 === 0 ? _isTop : argument._op === 'isTop';\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index === index) {\r\n this.splice(i, 1);\r\n break;\r\n }\r\n }\r\n if(!isTop) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index > index) {\r\n this[i].index--;\r\n }\r\n }\r\n }\r\n }\r\n\r\n clear() {\r\n this.length = 0;\r\n }\r\n}\r\n\r\nfunction Cache() {\r\n const instance = [];\r\n instance.push.apply(instance, arguments);\r\n Object.setPrototypeOf(instance, Cache.prototype);\r\n return instance;\r\n}\r\nCache.prototype = Object.create(Array.prototype);\r\nObject.getOwnPropertyNames(CacheProto.prototype).forEach(methodName =>\r\n Cache.prototype[methodName] = CacheProto.prototype[methodName]\r\n);\r\n\r\nfunction generateElement(template) {\r\n if(template.nodeType !== Node.ELEMENT_NODE) {\r\n throw new Error('ui-scroll directive requires an Element node for templating the view');\r\n }\r\n let element;\r\n switch (template.tagName.toLowerCase()) {\r\n case 'dl':\r\n throw new Error(`ui-scroll directive does not support <${template.tagName}> as a repeating tag: ${template.outerHTML}`);\r\n case 'tr':\r\n let table = angular.element('
    ');\r\n element = table.find('tr');\r\n break;\r\n case 'li':\r\n element = angular.element('
  • ');\r\n break;\r\n default:\r\n element = angular.element('
    ');\r\n }\r\n return element;\r\n}\r\n\r\nclass Padding {\r\n constructor(template) {\r\n this.element = generateElement(template);\r\n this.cache = new Cache();\r\n }\r\n\r\n height() {\r\n return this.element.height.apply(this.element, arguments);\r\n }\r\n}\r\n\r\nexport default Padding;","import Padding from './padding';\r\n\r\nexport default function Viewport(elementRoutines, buffer, element, viewportController, $rootScope, padding) {\r\n let topPadding = null;\r\n let bottomPadding = null;\r\n const viewport = viewportController && viewportController.viewport ? viewportController.viewport : angular.element(window);\r\n const container = viewportController && viewportController.container ? viewportController.container : undefined;\r\n const scope = viewportController && viewportController.scope ? viewportController.scope : $rootScope;\r\n\r\n viewport.css({\r\n 'overflow-anchor': 'none',\r\n 'overflow-y': 'auto',\r\n 'display': 'block'\r\n });\r\n\r\n function bufferPadding() {\r\n return viewport.outerHeight() * padding; // some extra space to initiate preload\r\n }\r\n\r\n angular.extend(viewport, {\r\n getScope() {\r\n return scope;\r\n },\r\n\r\n createPaddingElements(template) {\r\n topPadding = new Padding(template);\r\n bottomPadding = new Padding(template);\r\n element.before(topPadding.element);\r\n element.after(bottomPadding.element);\r\n topPadding.height(0);\r\n bottomPadding.height(0);\r\n },\r\n\r\n applyContainerStyle() {\r\n if (!container) {\r\n return true;\r\n }\r\n if(container !== viewport) {\r\n viewport.css('height', window.getComputedStyle(container[0]).height);\r\n }\r\n return viewport.height() > 0;\r\n },\r\n\r\n bottomDataPos() {\r\n let scrollHeight = viewport[0].scrollHeight;\r\n scrollHeight = scrollHeight != null ? scrollHeight : viewport[0].document.documentElement.scrollHeight;\r\n return scrollHeight - bottomPadding.height();\r\n },\r\n\r\n topDataPos() {\r\n return topPadding.height();\r\n },\r\n\r\n bottomVisiblePos() {\r\n return viewport.scrollTop() + viewport.outerHeight();\r\n },\r\n\r\n topVisiblePos() {\r\n return viewport.scrollTop();\r\n },\r\n\r\n insertElement(e, sibling) {\r\n return elementRoutines.insertElement(e, sibling || topPadding.element);\r\n },\r\n\r\n insertElementAnimated(e, sibling) {\r\n return elementRoutines.insertElementAnimated(e, sibling || topPadding.element);\r\n },\r\n\r\n shouldLoadBottom() {\r\n return !buffer.eof && viewport.bottomDataPos() < viewport.bottomVisiblePos() + bufferPadding();\r\n },\r\n\r\n clipBottom() {\r\n // clip the invisible items off the bottom\r\n let overage = 0;\r\n let overageHeight = 0;\r\n let itemHeight = 0;\r\n let emptySpaceHeight = viewport.bottomDataPos() - viewport.bottomVisiblePos() - bufferPadding();\r\n\r\n for (let i = buffer.length - 1; i >= 0; i--) {\r\n itemHeight = buffer[i].element.outerHeight(true);\r\n if (overageHeight + itemHeight > emptySpaceHeight) {\r\n break;\r\n }\r\n bottomPadding.cache.add(buffer[i]);\r\n overageHeight += itemHeight;\r\n overage++;\r\n }\r\n\r\n if (overage > 0) {\r\n buffer.eof = false;\r\n buffer.remove(buffer.length - overage, buffer.length);\r\n buffer.next -= overage;\r\n viewport.adjustPaddings();\r\n }\r\n },\r\n\r\n shouldLoadTop() {\r\n return !buffer.bof && (viewport.topDataPos() > viewport.topVisiblePos() - bufferPadding());\r\n },\r\n\r\n clipTop() {\r\n // clip the invisible items off the top\r\n let overage = 0;\r\n let overageHeight = 0;\r\n let itemHeight = 0;\r\n let emptySpaceHeight = viewport.topVisiblePos() - viewport.topDataPos() - bufferPadding();\r\n\r\n for (let i = 0; i < buffer.length; i++) {\r\n itemHeight = buffer[i].element.outerHeight(true);\r\n if (overageHeight + itemHeight > emptySpaceHeight) {\r\n break;\r\n }\r\n topPadding.cache.add(buffer[i]);\r\n overageHeight += itemHeight;\r\n overage++;\r\n }\r\n\r\n if (overage > 0) {\r\n // we need to adjust top padding element before items are removed from top\r\n // to avoid strange behaviour of scroll bar during remove top items when we are at the very bottom\r\n topPadding.height(topPadding.height() + overageHeight);\r\n buffer.bof = false;\r\n buffer.remove(0, overage);\r\n buffer.first += overage;\r\n }\r\n },\r\n\r\n adjustPaddings() {\r\n if (!buffer.length) {\r\n return;\r\n }\r\n\r\n // precise heights calculation based on items that are in buffer or that were in buffer once\r\n const visibleItemsHeight = buffer.reduce((summ, item) => summ + item.element.outerHeight(true), 0);\r\n\r\n let topPaddingHeight = 0, topCount = 0;\r\n topPadding.cache.forEach(item => {\r\n if(item.index < buffer.first) {\r\n topPaddingHeight += item.height;\r\n topCount++;\r\n }\r\n });\r\n\r\n let bottomPaddingHeight = 0, bottomCount = 0;\r\n bottomPadding.cache.forEach(item => {\r\n if(item.index >= buffer.next) {\r\n bottomPaddingHeight += item.height;\r\n bottomCount++;\r\n }\r\n });\r\n\r\n const totalHeight = visibleItemsHeight + topPaddingHeight + bottomPaddingHeight;\r\n const averageItemHeight = totalHeight / (topCount + bottomCount + buffer.length);\r\n\r\n // average heights calculation, items that have never been reached\r\n let adjustTopPadding = buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser;\r\n let adjustBottomPadding = buffer.maxIndexUser !== null && buffer.maxIndex < buffer.maxIndexUser;\r\n let topPaddingHeightAdd = adjustTopPadding ? (buffer.minIndex - buffer.minIndexUser) * averageItemHeight : 0;\r\n let bottomPaddingHeightAdd = adjustBottomPadding ? (buffer.maxIndexUser - buffer.maxIndex) * averageItemHeight : 0;\r\n\r\n // paddings combine adjustment\r\n topPadding.height(topPaddingHeight + topPaddingHeightAdd);\r\n bottomPadding.height(bottomPaddingHeight + bottomPaddingHeightAdd);\r\n },\r\n\r\n onAfterMinIndexSet(topPaddingHeightOld) {\r\n // additional scrollTop adjustment in case of datasource.minIndex external set\r\n if (buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser) {\r\n let diff = topPadding.height() - topPaddingHeightOld;\r\n viewport.scrollTop(viewport.scrollTop() + diff);\r\n while((diff -= viewport.scrollTop()) > 0) {\r\n bottomPadding.height(bottomPadding.height() + diff);\r\n viewport.scrollTop(viewport.scrollTop() + diff);\r\n }\r\n }\r\n },\r\n\r\n onAfterPrepend(updates) {\r\n if (!updates.prepended.length)\r\n return;\r\n const height = buffer.effectiveHeight(updates.prepended);\r\n const paddingHeight = topPadding.height() - height;\r\n if (paddingHeight >= 0) {\r\n topPadding.height(paddingHeight);\r\n }\r\n else {\r\n topPadding.height(0);\r\n viewport.scrollTop(viewport.scrollTop() - paddingHeight);\r\n }\r\n },\r\n\r\n resetTopPadding() {\r\n topPadding.height(0);\r\n topPadding.cache.clear();\r\n },\r\n\r\n resetBottomPadding() {\r\n bottomPadding.height(0);\r\n bottomPadding.cache.clear();\r\n },\r\n\r\n removeCacheItem(item, isTop) {\r\n topPadding.cache.remove(item, isTop);\r\n bottomPadding.cache.remove(item, isTop);\r\n },\r\n\r\n removeItem(item) {\r\n this.removeCacheItem(item);\r\n return buffer.remove(item);\r\n }\r\n });\r\n\r\n return viewport;\r\n}\r\n","class Adapter {\r\n\r\n constructor($scope, $parse, $attr, viewport, buffer, doAdjust, reload) {\r\n this.$parse = $parse;\r\n this.$attr = $attr;\r\n this.viewport = viewport;\r\n this.buffer = buffer;\r\n\r\n this.doAdjust = doAdjust;\r\n this.reload = reload;\r\n\r\n this.isLoading = false;\r\n this.disabled = false;\r\n\r\n const viewportScope = viewport.getScope();\r\n this.startScope = viewportScope.$parent ? viewportScope : $scope;\r\n\r\n this.publicContext = {};\r\n this.assignAdapter($attr.adapter);\r\n this.generatePublicContext();\r\n }\r\n\r\n assignAdapter(adapterAttr) {\r\n if (!adapterAttr || !(adapterAttr = adapterAttr.replace(/^\\s+|\\s+$/gm, ''))) {\r\n return;\r\n }\r\n let adapterOnScope;\r\n\r\n try {\r\n this.$parse(adapterAttr).assign(this.startScope, {});\r\n adapterOnScope = this.$parse(adapterAttr)(this.startScope);\r\n }\r\n catch (error) {\r\n error.message = `Angular ui-scroll Adapter assignment exception.\\n` +\r\n `Can't parse \"${adapterAttr}\" expression.\\n` +\r\n error.message;\r\n throw error;\r\n }\r\n\r\n angular.extend(adapterOnScope, this.publicContext);\r\n this.publicContext = adapterOnScope;\r\n }\r\n\r\n generatePublicContext() {\r\n // these methods will be accessible out of ui-scroll via user defined adapter\r\n const publicMethods = ['reload', 'applyUpdates', 'append', 'prepend', 'isBOF', 'isEOF', 'isEmpty'];\r\n for (let i = publicMethods.length - 1; i >= 0; i--) {\r\n this.publicContext[publicMethods[i]] = this[publicMethods[i]].bind(this);\r\n }\r\n\r\n // these read-only props will be accessible out of ui-scroll via user defined adapter\r\n const publicProps = ['isLoading', 'topVisible', 'topVisibleElement', 'topVisibleScope', 'bottomVisible', 'bottomVisibleElement', 'bottomVisibleScope'];\r\n for (let i = publicProps.length - 1; i >= 0; i--) {\r\n let property, attr = this.$attr[publicProps[i]];\r\n Object.defineProperty(this, publicProps[i], {\r\n get: () => property,\r\n set: (value) => {\r\n property = value;\r\n this.publicContext[publicProps[i]] = value;\r\n if (attr) {\r\n this.$parse(attr).assign(this.startScope, value);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // non-read-only public property\r\n Object.defineProperty(this.publicContext, 'disabled', {\r\n get: () => this.disabled,\r\n set: (value) => (!(this.disabled = value)) ? this.doAdjust() : null\r\n });\r\n }\r\n\r\n loading(value) {\r\n this.isLoading = value;\r\n }\r\n\r\n isBOF() {\r\n return this.buffer.bof;\r\n }\r\n\r\n isEOF() {\r\n return this.buffer.eof;\r\n }\r\n\r\n isEmpty() {\r\n return !this.buffer.length;\r\n }\r\n\r\n append(newItems) {\r\n this.buffer.append(newItems);\r\n this.doAdjust();\r\n this.viewport.clipTop();\r\n this.viewport.clipBottom();\r\n }\r\n\r\n prepend(newItems) {\r\n this.buffer.prepend(newItems);\r\n this.doAdjust();\r\n this.viewport.clipTop();\r\n this.viewport.clipBottom();\r\n }\r\n\r\n applyUpdates(arg1, arg2) {\r\n if (typeof arg1 === 'function') {\r\n this.applyUpdatesFunc(arg1);\r\n } else {\r\n this.applyUpdatesIndex(arg1, arg2);\r\n }\r\n this.doAdjust();\r\n }\r\n\r\n applyUpdatesFunc(cb) {\r\n this.buffer.slice(0).forEach((wrapper) => {\r\n // we need to do it on the buffer clone, because buffer content\r\n // may change as we iterate through\r\n this.applyUpdate(wrapper, cb(wrapper.item, wrapper.scope, wrapper.element));\r\n });\r\n }\r\n\r\n applyUpdatesIndex(index, newItems) {\r\n if (index % 1 !== 0) {\r\n throw new Error('applyUpdates - ' + index + ' is not a valid index (should be an integer)');\r\n }\r\n const _index = index - this.buffer.first;\r\n\r\n // apply updates only within buffer\r\n if (_index >= 0 && _index < this.buffer.length) {\r\n this.applyUpdate(this.buffer[_index], newItems);\r\n }\r\n // out-of-buffer case: deletion may affect Paddings\r\n else if(index >= this.buffer.getAbsMinIndex() && index <= this.buffer.getAbsMaxIndex()) {\r\n if(angular.isArray(newItems) && !newItems.length) {\r\n this.viewport.removeCacheItem(index, index === this.buffer.minIndex);\r\n if(index === this.buffer.getAbsMinIndex()) {\r\n this.buffer.incrementMinIndex();\r\n }\r\n else {\r\n this.buffer.decrementMaxIndex();\r\n }\r\n }\r\n }\r\n }\r\n\r\n applyUpdate(wrapper, newItems) {\r\n if (!angular.isArray(newItems)) {\r\n return;\r\n }\r\n let position = this.buffer.indexOf(wrapper);\r\n if (!newItems.reverse().some(newItem => newItem === wrapper.item)) {\r\n wrapper.op = 'remove';\r\n if(position === 0 && !newItems.length) {\r\n wrapper._op = 'isTop'; // to catch \"first\" edge case on remove\r\n }\r\n }\r\n newItems.forEach((newItem) => {\r\n if (newItem === wrapper.item) {\r\n position--;\r\n } else {\r\n // 3 parameter (isTop) is to catch \"first\" edge case on insert\r\n this.buffer.insert(position + 1, newItem, position === -1);\r\n }\r\n });\r\n }\r\n\r\n calculateProperties() {\r\n let rowTop = null, topHeight = 0;\r\n let topDone = false, bottomDone = false;\r\n const length = this.buffer.length;\r\n\r\n for (let i = 0; i < length; i++) {\r\n const item = this.buffer[i];\r\n const itemTop = item.element.offset().top;\r\n\r\n if (rowTop !== itemTop) { // a new row condition\r\n const itemHeight = item.element.outerHeight(true);\r\n const top = this.viewport.topDataPos() + topHeight + itemHeight;\r\n\r\n if (!topDone && top > this.viewport.topVisiblePos()) {\r\n topDone = true;\r\n this['topVisible'] = item.item;\r\n this['topVisibleElement'] = item.element;\r\n this['topVisibleScope'] = item.scope;\r\n }\r\n if (!bottomDone && (top >= this.viewport.bottomVisiblePos() || (i === length - 1 && this.isEOF()))) {\r\n bottomDone = true;\r\n this['bottomVisible'] = item.item;\r\n this['bottomVisibleElement'] = item.element;\r\n this['bottomVisibleScope'] = item.scope;\r\n }\r\n topHeight += itemHeight;\r\n }\r\n rowTop = itemTop;\r\n\r\n if (topDone && bottomDone) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n}\r\n\r\nexport default Adapter;\r\n","import JQLiteExtras from './modules/jqLiteExtras';\nimport ElementRoutines from './modules/elementRoutines.js';\nimport ScrollBuffer from './modules/buffer.js';\nimport Viewport from './modules/viewport.js';\nimport Adapter from './modules/adapter.js';\n\nangular.module('ui.scroll', [])\n\n .constant('JQLiteExtras', JQLiteExtras)\n .run(['JQLiteExtras', (JQLiteExtras) => {\n const elt = angular.element;\n !(window.jQuery && elt.fn && elt.fn.jquery) ? (new JQLiteExtras()).registerFor(elt) : null;\n ElementRoutines.addCSSRules();\n }])\n\n .directive('uiScrollViewport', function () {\n return {\n restrict: 'A',\n controller: [\n '$scope',\n '$element',\n function (scope, element) {\n this.container = element;\n this.viewport = element;\n this.scope = scope;\n\n angular.forEach(element.children(), child => {\n if (child.tagName.toLowerCase() === 'tbody') {\n this.viewport = angular.element(child);\n }\n });\n\n return this;\n }\n ]\n };\n })\n\n .directive('uiScroll', [\n '$log',\n '$injector',\n '$rootScope',\n '$timeout',\n '$interval',\n '$q',\n '$parse',\n function (console, $injector, $rootScope, $timeout, $interval, $q, $parse) {\n\n return {\n require: ['?^uiScrollViewport'],\n restrict: 'A',\n transclude: 'element',\n priority: 1000,\n terminal: true,\n link: link\n };\n\n function link($scope, element, $attr, controllers, linker) {\n const match = $attr.uiScroll.match(/^\\s*(\\w+)\\s+in\\s+([(\\w|\\$)\\.]+)\\s*$/);\n if (!match) {\n throw new Error('Expected uiScroll in form of \\'_item_ in _datasource_\\' but got \\'' + $attr.uiScroll + '\\'');\n }\n\n function parseNumber(value, defaultValue, isFloat) {\n if (!isFloat) {\n value = value === null ? defaultValue : Math.floor(value);\n }\n return isNaN(value) ? defaultValue : value;\n }\n\n function parseNumericAttr(value, defaultValue, isFloat) {\n const result = $parse(value)($scope);\n return parseNumber(result, defaultValue, isFloat);\n }\n\n const BUFFER_MIN = 3;\n const BUFFER_DEFAULT = 10;\n const PADDING_MIN = 0.3;\n const PADDING_DEFAULT = 0.5;\n const START_INDEX_DEFAULT = 1;\n const MAX_VIEWPORT_DELAY = 500;\n const VIEWPORT_POLLING_INTERVAL = 50;\n\n let datasource = null;\n const itemName = match[1];\n const datasourceName = match[2];\n const viewportController = controllers[0];\n const bufferSize = Math.max(BUFFER_MIN, parseNumericAttr($attr.bufferSize, BUFFER_DEFAULT));\n const padding = Math.max(PADDING_MIN, parseNumericAttr($attr.padding, PADDING_DEFAULT, true));\n let startIndex = parseNumericAttr($attr.startIndex, START_INDEX_DEFAULT);\n let ridActual = 0; // current data revision id\n let pending = [];\n\n const elementRoutines = new ElementRoutines($injector, $q);\n const buffer = new ScrollBuffer(elementRoutines, bufferSize, startIndex);\n const viewport = new Viewport(elementRoutines, buffer, element, viewportController, $rootScope, padding);\n const adapter = new Adapter($scope, $parse, $attr, viewport, buffer, doAdjust, reload);\n\n if (viewportController) {\n viewportController.adapter = adapter;\n }\n\n const isDatasourceValid = () =>\n Object.prototype.toString.call(datasource) === '[object Object]' && typeof datasource.get === 'function';\n\n datasource = $parse(datasourceName)($scope); // try to get datasource on scope\n if (!isDatasourceValid()) {\n datasource = $injector.get(datasourceName); // try to inject datasource as service\n if (!isDatasourceValid()) {\n throw new Error(datasourceName + ' is not a valid datasource');\n }\n }\n\n let onRenderHandlers = [];\n function onRenderHandlersRunner() {\n onRenderHandlers.forEach(handler => handler.run());\n onRenderHandlers = [];\n }\n function persistDatasourceIndex(datasource, propName) {\n let getter;\n // need to postpone min/maxIndexUser processing if the view is empty\n if(angular.isNumber(datasource[propName])) {\n getter = datasource[propName];\n if(angular.isNumber(getter)) {\n onRenderHandlers = onRenderHandlers.filter(handler => handler.id !== propName);\n onRenderHandlers.push({\n id: propName,\n run: () => datasource[propName] = getter\n });\n }\n }\n }\n\n function defineDatasourceIndex(datasource, propName, propUserName) {\n const descriptor = Object.getOwnPropertyDescriptor(datasource, propName);\n if (descriptor && (descriptor.set || descriptor.get)) {\n return;\n }\n let getter;\n persistDatasourceIndex(datasource, propName);\n Object.defineProperty(datasource, propName, {\n set: (value) => {\n getter = value;\n if(pending.length && !buffer.length) {\n persistDatasourceIndex(datasource, propName);\n return;\n }\n buffer[propUserName] = value;\n const topPaddingHeightOld = viewport.topDataPos();\n viewport.adjustPaddings();\n if (propName === 'minIndex') {\n viewport.onAfterMinIndexSet(topPaddingHeightOld);\n }\n },\n get: () => getter\n });\n }\n\n defineDatasourceIndex(datasource, 'minIndex', 'minIndexUser');\n defineDatasourceIndex(datasource, 'maxIndex', 'maxIndexUser');\n\n const fetchNext = (datasource.get.length !== 2) ?\n (success) => datasource.get(buffer.next, bufferSize, success) :\n (success) => {\n datasource.get({\n index: buffer.next,\n append: buffer.length ? buffer[buffer.length - 1].item : void 0,\n count: bufferSize\n }, success);\n };\n\n const fetchPrevious = (datasource.get.length !== 2) ?\n (success) => datasource.get(buffer.first - bufferSize, bufferSize, success) :\n (success) => {\n datasource.get({\n index: buffer.first - bufferSize,\n prepend: buffer.length ? buffer[0].item : void 0,\n count: bufferSize\n }, success);\n };\n\n const initialize = () => {\n let tryCount = 0;\n if(!viewport.applyContainerStyle()) {\n const timer = $interval(() => {\n tryCount++;\n if(viewport.applyContainerStyle()) {\n $interval.cancel(timer);\n doAdjust();\n }\n if(tryCount * VIEWPORT_POLLING_INTERVAL >= MAX_VIEWPORT_DELAY) {\n $interval.cancel(timer);\n throw Error(`ui-scroll directive requires a viewport with non-zero height in ${MAX_VIEWPORT_DELAY}ms`);\n }\n }, VIEWPORT_POLLING_INTERVAL);\n }\n else {\n doAdjust();\n }\n };\n\n /**\n * Build padding elements\n *\n * Calling linker is the only way I found to get access to the tag name of the template\n * to prevent the directive scope from pollution a new scope is created and destroyed\n * right after the builder creation is completed\n */\n linker((clone, scope) => {\n viewport.createPaddingElements(clone[0]);\n // we do not include the clone in the DOM. It means that the nested directives will not\n // be able to reach the parent directives, but in this case it is intentional because we\n // created the clone to access the template tag name\n scope.$destroy();\n clone.remove();\n });\n\n $scope.$on('$destroy', () => {\n unbindEvents();\n viewport.unbind('mousewheel', wheelHandler);\n });\n\n viewport.bind('mousewheel', wheelHandler);\n\n initialize();\n\n /* Private function definitions */\n\n function isInvalid(rid) {\n return (rid && rid !== ridActual) || $scope.$$destroyed;\n }\n\n function bindEvents() {\n viewport.bind('resize', resizeAndScrollHandler);\n viewport.bind('scroll', resizeAndScrollHandler);\n }\n\n function unbindEvents() {\n viewport.unbind('resize', resizeAndScrollHandler);\n viewport.unbind('scroll', resizeAndScrollHandler);\n }\n\n function reload() {\n viewport.resetTopPadding();\n viewport.resetBottomPadding();\n if (arguments.length) {\n startIndex = parseNumber(arguments[0], START_INDEX_DEFAULT, false);\n }\n buffer.reset(startIndex);\n persistDatasourceIndex(datasource, 'minIndex');\n persistDatasourceIndex(datasource, 'maxIndex');\n doAdjust();\n }\n\n function isElementVisible(wrapper) {\n return wrapper.element.height() && wrapper.element[0].offsetParent;\n }\n\n function visibilityWatcher(wrapper) {\n if (isElementVisible(wrapper)) {\n buffer.forEach((item) => {\n if (typeof item.unregisterVisibilityWatcher === 'function') {\n item.unregisterVisibilityWatcher();\n delete item.unregisterVisibilityWatcher;\n }\n });\n if (!pending.length) {\n $timeout(() => doAdjust());\n }\n }\n }\n\n function insertWrapperContent(wrapper, insertAfter) {\n createElement(wrapper, insertAfter, viewport.insertElement);\n if (!isElementVisible(wrapper)) {\n wrapper.unregisterVisibilityWatcher = wrapper.scope.$watch(() => visibilityWatcher(wrapper));\n }\n elementRoutines.hideElement(wrapper); // hide inserted elements before data binding\n }\n\n function createElement(wrapper, insertAfter, insertElement) {\n let promises = null;\n const sibling = (insertAfter > 0) ? buffer[insertAfter - 1].element : undefined;\n linker((clone, scope) => {\n promises = insertElement(clone, sibling);\n wrapper.element = clone;\n wrapper.scope = scope;\n scope[itemName] = wrapper.item;\n });\n // ui-scroll-grid apply\n if (adapter.transform) {\n const tdInitializer = wrapper.scope.uiScrollTdInitializer;\n if (tdInitializer && tdInitializer.linking) {\n adapter.transform(wrapper.scope, wrapper.element);\n } else {\n wrapper.scope.uiScrollTdInitializer = {\n onLink: () => adapter.transform(wrapper.scope, wrapper.element),\n scope: wrapper.scope\n };\n }\n }\n return promises;\n }\n\n function updateDOM() {\n let promises = [];\n const toBePrepended = [];\n const toBeRemoved = [];\n const inserted = [];\n\n buffer.forEach((wrapper, i) => {\n switch (wrapper.op) {\n case 'prepend':\n toBePrepended.unshift(wrapper);\n break;\n case 'append':\n insertWrapperContent(wrapper, i);\n wrapper.op = 'none';\n inserted.push(wrapper);\n break;\n case 'insert':\n promises = promises.concat(createElement(wrapper, i, viewport.insertElementAnimated));\n wrapper.op = 'none';\n inserted.push(wrapper);\n break;\n case 'remove':\n toBeRemoved.push(wrapper);\n }\n });\n\n toBeRemoved.forEach((wrapper) => promises = promises.concat(viewport.removeItem(wrapper)));\n\n if (toBePrepended.length)\n toBePrepended.forEach((wrapper) => {\n insertWrapperContent(wrapper);\n wrapper.op = 'none';\n });\n\n buffer.forEach((item, i) => item.scope.$index = buffer.first + i);\n\n return {\n prepended: toBePrepended,\n removed: toBeRemoved,\n inserted: inserted,\n animated: promises\n };\n\n }\n\n function updatePaddings(rid, updates) {\n // schedule another doAdjust after animation completion\n if (updates.animated.length) {\n $q.all(updates.animated).then(() => {\n viewport.adjustPaddings();\n doAdjust(rid);\n });\n } else {\n viewport.adjustPaddings();\n }\n }\n\n function enqueueFetch(rid, updates) {\n if (viewport.shouldLoadBottom()) {\n if (!updates || buffer.effectiveHeight(updates.inserted) > 0) {\n // this means that at least one item appended in the last batch has height > 0\n if (pending.push(true) === 1) {\n adapter.loading(true);\n fetch(rid);\n }\n }\n } else if (viewport.shouldLoadTop()) {\n if ((!updates || buffer.effectiveHeight(updates.prepended) > 0) || pending[0]) {\n // this means that at least one item appended in the last batch has height > 0\n // pending[0] = true means that previous fetch was appending. We need to force at least one prepend\n // BTW there will always be at least 1 element in the pending array because bottom is fetched first\n if (pending.push(false) === 1) {\n adapter.loading(true);\n fetch(rid);\n }\n }\n }\n }\n\n function processUpdates() {\n const updates = updateDOM();\n\n // We need the item bindings to be processed before we can do adjustments\n !$scope.$$phase && !$rootScope.$$phase && $scope.$digest();\n\n updates.inserted.forEach(w => elementRoutines.showElement(w));\n updates.prepended.forEach(w => elementRoutines.showElement(w));\n return updates;\n }\n\n function doAdjust(rid) {\n if (!rid) { // dismiss pending requests\n pending = [];\n rid = ++ridActual;\n }\n\n const updates = processUpdates();\n\n if (isInvalid(rid)) {\n return;\n }\n\n updatePaddings(rid, updates);\n enqueueFetch(rid);\n\n if (!pending.length) {\n adapter.calculateProperties();\n }\n }\n\n function doAdjustAfterFetch(rid) {\n const updates = processUpdates();\n\n viewport.onAfterPrepend(updates);\n\n if (isInvalid(rid)) {\n return;\n }\n\n updatePaddings(rid, updates);\n onRenderHandlersRunner();\n enqueueFetch(rid, updates);\n pending.shift();\n\n if (pending.length)\n fetch(rid);\n else {\n adapter.loading(false);\n bindEvents();\n adapter.calculateProperties();\n }\n }\n\n function fetch(rid) {\n if (pending[0]) {// scrolling down\n if (buffer.length && !viewport.shouldLoadBottom()) {\n doAdjustAfterFetch(rid);\n } else {\n fetchNext((result) => {\n if (isInvalid(rid)) {\n return;\n }\n\n if (result.length < bufferSize) {\n buffer.eof = true;\n }\n\n if (result.length > 0) {\n viewport.clipTop();\n buffer.append(result);\n }\n\n doAdjustAfterFetch(rid);\n });\n }\n } else { // scrolling up\n if (buffer.length && !viewport.shouldLoadTop()) {\n doAdjustAfterFetch(rid);\n } else {\n fetchPrevious((result) => {\n if (isInvalid(rid)) {\n return;\n }\n\n if (result.length < bufferSize) {\n buffer.bof = true;\n // log 'bof is reached'\n }\n\n if (result.length > 0) {\n if (buffer.length) {\n viewport.clipBottom();\n }\n buffer.prepend(result);\n }\n\n doAdjustAfterFetch(rid);\n });\n }\n }\n }\n\n function resizeAndScrollHandler() {\n if (!$rootScope.$$phase && !adapter.isLoading && !adapter.disabled) {\n\n enqueueFetch(ridActual);\n\n if (pending.length) {\n unbindEvents();\n } else {\n adapter.calculateProperties();\n !$scope.$$phase && $scope.$digest();\n }\n }\n }\n\n function wheelHandler(event) {\n if (!adapter.disabled) {\n const scrollTop = viewport[0].scrollTop;\n const yMax = viewport[0].scrollHeight - viewport[0].clientHeight;\n\n if ((scrollTop === 0 && !buffer.bof) || (scrollTop === yMax && !buffer.eof)) {\n event.preventDefault();\n }\n }\n }\n }\n\n }\n ]);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/ui-scroll.min.js b/dist/ui-scroll.min.js index b6b5d46e..5f5bb746 100644 --- a/dist/ui-scroll.min.js +++ b/dist/ui-scroll.min.js @@ -1,2 +1,2 @@ -!function(n){var r={};function i(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.m=n,i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=1)}([,function(e,t,n){"use strict";function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function i(e,t){for(var n=0;ni.minIndexUser)return void i.minIndexUser++;i.minIndex===i.minIndexUser&&i.minIndexUser++}i.minIndex++},decrementMaxIndex:function(){null!==i.maxIndexUser&&i.maxIndex<=i.maxIndexUser&&i.maxIndexUser--,i.maxIndex--},getAbsMinIndex:function(){return null!==i.minIndexUser?Math.min(i.minIndexUser,i.minIndex):i.minIndex},getAbsMaxIndex:function(){return null!==i.maxIndexUser?Math.max(i.maxIndexUser,i.maxIndex):i.maxIndex},effectiveHeight:function(e){if(!e.length)return 0;var t=Number.MAX_VALUE,n=Number.NEGATIVE_INFINITY;return e.forEach(function(e){e.element[0].offsetParent&&(t=Math.min(t,e.element.offset().top),n=Math.max(n,e.element.offset().top+e.element.outerHeight(!0)))}),Math.max(0,n-t)}}),i.reset(t),i}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;nt.index?1:0})}},{key:"remove",value:function(e,t){for(var n=e%1==0?e:e.scope.$index,r=e%1==0?t:"isTop"===e._op,i=this.length-1;0<=i;i--)if(this[i].index===n){this.splice(i,1);break}if(!r)for(var o=this.length-1;0<=o;o--)this[o].index>n&&this[o].index--}},{key:"clear",value:function(){this.length=0}}]),e}();function d(){var e=[];return e.push.apply(e,arguments),Object.setPrototypeOf(e,d.prototype),e}d.prototype=Object.create(Array.prototype),Object.getOwnPropertyNames(f.prototype).forEach(function(e){return d.prototype[e]=f.prototype[e]});var h=function(){function t(e){u(this,t),this.element=function(e){if(e.nodeType!==Node.ELEMENT_NODE)throw new Error("ui-scroll directive requires an Element node for templating the view");var t;switch(e.tagName.toLowerCase()){case"dl":throw new Error("ui-scroll directive does not support <".concat(e.tagName,"> as a repeating tag: ").concat(e.outerHTML));case"tr":t=angular.element("
    ").find("tr");break;case"li":t=angular.element("
  • ");break;default:t=angular.element("
    ")}return t}(e),this.cache=new d}return c(t,[{key:"height",value:function(){return this.element.height.apply(this.element,arguments)}}]),t}();function X(n,c,t,e,r,i){var f=null,d=null,o=e&&e.viewport?e.viewport:angular.element(window),a=e&&e.container?e.container:void 0,s=e&&e.scope?e.scope:r;function u(){return o.outerHeight()*i}return o.css({"overflow-anchor":"none","overflow-y":"auto",display:"block"}),angular.extend(o,{getScope:function(){return s},createPaddingElements:function(e){f=new h(e),d=new h(e),t.before(f.element),t.after(d.element),f.height(0),d.height(0)},applyContainerStyle:function(){return!a||(a!==o&&o.css("height",window.getComputedStyle(a[0]).height),0o.topVisiblePos()-u()},clipTop:function(){for(var e=0,t=0,n=0,r=o.topVisiblePos()-o.topDataPos()-u(),i=0;i=c.next&&(r+=e.height,i++)});var o=(e+t+r)/(n+i+c.length),a=null!==c.minIndexUser&&c.minIndex>c.minIndexUser,s=null!==c.maxIndexUser&&c.maxIndexc.minIndexUser){var t=f.height()-e;for(o.scrollTop(o.scrollTop()+t);0<(t-=o.scrollTop());)d.height(d.height()+t),o.scrollTop(o.scrollTop()+t)}},onAfterPrepend:function(e){if(e.prepended.length){var t=c.effectiveHeight(e.prepended),n=f.height()-t;0<=n?f.height(n):(f.height(0),o.scrollTop(o.scrollTop()-n))}},resetTopPadding:function(){f.height(0),f.cache.clear()},resetBottomPadding:function(){d.height(0),d.cache.clear()},removeCacheItem:function(e,t){f.cache.remove(e,t),d.cache.remove(e,t)},removeItem:function(e){return this.removeCacheItem(e),c.remove(e)}}),o}function p(e,t){for(var n=0;n=this.buffer.getAbsMinIndex()&&e<=this.buffer.getAbsMaxIndex()&&angular.isArray(t)&&!t.length&&(this.viewport.removeCacheItem(e,e===this.buffer.minIndex),e===this.buffer.getAbsMinIndex()?this.buffer.incrementMinIndex():this.buffer.decrementMaxIndex())}},{key:"applyUpdate",value:function(t,e){var n=this;if(angular.isArray(e)){var r=this.buffer.indexOf(t);e.reverse().some(function(e){return e===t.item})||(t.op="remove",0!==r||e.length||(t._op="isTop")),e.forEach(function(e){e===t.item?r--:n.buffer.insert(r+1,e,-1===r)})}}},{key:"calculateProperties",value:function(){for(var e=null,t=0,n=!1,r=!1,i=this.buffer.length,o=0;othis.viewport.topVisiblePos()&&(n=!0,this.topVisible=a.item,this.topVisibleElement=a.element,this.topVisibleScope=a.scope),!r&&(l>=this.viewport.bottomVisiblePos()||o===i-1&&this.isEOF())&&(r=!0,this.bottomVisible=a.item,this.bottomVisibleElement=a.element,this.bottomVisibleScope=a.scope),t+=u}if(e=s,n&&r)break}}}])&&p(e.prototype,t),n&&p(e,n),u}();angular.module("ui.scroll",[]).constant("JQLiteExtras",r).run(["JQLiteExtras",function(e){!window.jQuery&&(new e).registerFor(angular.element),q.addCSSRules()}]).directive("uiScrollViewport",function(){return{restrict:"A",controller:["$scope","$element",function(e,t){var n=this;return this.container=t,this.viewport=t,this.scope=e,angular.forEach(t.children(),function(e){"tbody"===e.tagName.toLowerCase()&&(n.viewport=angular.element(e))}),this}]}}).directive("uiScroll",["$log","$injector","$rootScope","$timeout","$interval","$q","$parse",function(e,B,D,F,R,W,z){return{require:["?^uiScrollViewport"],restrict:"A",transclude:"element",priority:1e3,terminal:!0,link:function(i,e,t,n,a){var r=t.uiScroll.match(/^\s*(\w+)\s+in\s+([(\w|\$)\.]+)\s*$/);if(!r)throw new Error("Expected uiScroll in form of '_item_ in _datasource_' but got '"+t.uiScroll+"'");function o(e,t,n){return n||(e=null===e?t:Math.floor(e)),isNaN(e)?t:e}function s(e,t,n){var r=z(e)(i);return o(r,t,n)}var u=null,l=r[1],c=r[2],f=n[0],d=Math.max(3,s(t.bufferSize,10)),h=Math.max(.3,s(t.padding,.5,!0)),p=s(t.startIndex,1),m=0,g=[],v=new q(B,W),b=new Q(v,d,p),x=new X(v,b,e,f,D,h),y=new Y(i,z,t,x,b,C,function(){x.resetTopPadding(),x.resetBottomPadding(),arguments.length&&(p=o(arguments[0],1,!1));b.reset(p),E(u,"minIndex"),E(u,"maxIndex"),C()});f&&(f.adapter=y);var w=function(){return"[object Object]"===Object.prototype.toString.call(u)&&"function"==typeof u.get};if(u=z(c)(i),!w()&&(u=B.get(c),!w()))throw new Error(c+" is not a valid datasource");var I=[];function E(e,t){var n;angular.isNumber(e[t])&&(n=e[t],angular.isNumber(n)&&(I=I.filter(function(e){return e.id!==t})).push({id:t,run:function(){return e[t]=n}}))}function $(n,r,i){var o,e=Object.getOwnPropertyDescriptor(n,r);e&&(e.set||e.get)||(E(n,r),Object.defineProperty(n,r,{set:function(e){if(o=e,!g.length||b.length){b[i]=e;var t=x.topDataPos();x.adjustPaddings(),"minIndex"===r&&x.onAfterMinIndexSet(t)}else E(n,r)},get:function(){return o}}))}$(u,"minIndex","minIndexUser"),$(u,"maxIndex","maxIndexUser");var P=2!==u.get.length?function(e){return u.get(b.next,d,e)}:function(e){u.get({index:b.next,append:b.length?b[b.length-1].item:void 0,count:d},e)},T=2!==u.get.length?function(e){return u.get(b.first-d,d,e)}:function(e){u.get({index:b.first-d,prepend:b.length?b[0].item:void 0,count:d},e)};function S(e){return e&&e!==m||i.$$destroyed}function k(){x.unbind("resize",_),x.unbind("scroll",_)}function A(e){return e.element.height()&&e.element[0].offsetParent}function O(e,t){j(e,t,x.insertElement),A(e)||(e.unregisterVisibilityWatcher=e.scope.$watch(function(){A(e)&&(b.forEach(function(e){"function"==typeof e.unregisterVisibilityWatcher&&(e.unregisterVisibilityWatcher(),delete e.unregisterVisibilityWatcher)}),g.length||F(function(){return C()}))})),v.hideElement(e)}function j(n,e,r){var i=null,o=0i.minIndexUser)return void i.minIndexUser++;i.minIndex===i.minIndexUser&&i.minIndexUser++}i.minIndex++},decrementMaxIndex:function(){null!==i.maxIndexUser&&i.maxIndex<=i.maxIndexUser&&i.maxIndexUser--,i.maxIndex--},getAbsMinIndex:function(){return null!==i.minIndexUser?Math.min(i.minIndexUser,i.minIndex):i.minIndex},getAbsMaxIndex:function(){return null!==i.maxIndexUser?Math.max(i.maxIndexUser,i.maxIndex):i.maxIndex},effectiveHeight:function(e){if(!e.length)return 0;var t=Number.MAX_VALUE,n=Number.NEGATIVE_INFINITY;return e.forEach(function(e){e.element[0].offsetParent&&(t=Math.min(t,e.element.offset().top),n=Math.max(n,e.element.offset().top+e.element.outerHeight(!0)))}),Math.max(0,n-t)}}),i.reset(t),i}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;nt.index?1:0})}},{key:"remove",value:function(e,t){for(var n=e%1==0?e:e.scope.$index,r=e%1==0?t:"isTop"===e._op,i=this.length-1;0<=i;i--)if(this[i].index===n){this.splice(i,1);break}if(!r)for(var o=this.length-1;0<=o;o--)this[o].index>n&&this[o].index--}},{key:"clear",value:function(){this.length=0}}]),e}();function d(){var e=[];return e.push.apply(e,arguments),Object.setPrototypeOf(e,d.prototype),e}d.prototype=Object.create(Array.prototype),Object.getOwnPropertyNames(f.prototype).forEach(function(e){return d.prototype[e]=f.prototype[e]});var h=function(){function t(e){u(this,t),this.element=function(e){if(e.nodeType!==Node.ELEMENT_NODE)throw new Error("ui-scroll directive requires an Element node for templating the view");var t;switch(e.tagName.toLowerCase()){case"dl":throw new Error("ui-scroll directive does not support <".concat(e.tagName,"> as a repeating tag: ").concat(e.outerHTML));case"tr":t=angular.element("
    ").find("tr");break;case"li":t=angular.element("
  • ");break;default:t=angular.element("
    ")}return t}(e),this.cache=new d}return c(t,[{key:"height",value:function(){return this.element.height.apply(this.element,arguments)}}]),t}();function X(n,c,t,e,r,i){var f=null,d=null,o=e&&e.viewport?e.viewport:angular.element(window),a=e&&e.container?e.container:void 0,s=e&&e.scope?e.scope:r;function u(){return o.outerHeight()*i}return o.css({"overflow-anchor":"none","overflow-y":"auto",display:"block"}),angular.extend(o,{getScope:function(){return s},createPaddingElements:function(e){f=new h(e),d=new h(e),t.before(f.element),t.after(d.element),f.height(0),d.height(0)},applyContainerStyle:function(){return!a||(a!==o&&o.css("height",window.getComputedStyle(a[0]).height),0o.topVisiblePos()-u()},clipTop:function(){for(var e=0,t=0,n=0,r=o.topVisiblePos()-o.topDataPos()-u(),i=0;i=c.next&&(r+=e.height,i++)});var o=(e+t+r)/(n+i+c.length),a=null!==c.minIndexUser&&c.minIndex>c.minIndexUser,s=null!==c.maxIndexUser&&c.maxIndexc.minIndexUser){var t=f.height()-e;for(o.scrollTop(o.scrollTop()+t);0<(t-=o.scrollTop());)d.height(d.height()+t),o.scrollTop(o.scrollTop()+t)}},onAfterPrepend:function(e){if(e.prepended.length){var t=c.effectiveHeight(e.prepended),n=f.height()-t;0<=n?f.height(n):(f.height(0),o.scrollTop(o.scrollTop()-n))}},resetTopPadding:function(){f.height(0),f.cache.clear()},resetBottomPadding:function(){d.height(0),d.cache.clear()},removeCacheItem:function(e,t){f.cache.remove(e,t),d.cache.remove(e,t)},removeItem:function(e){return this.removeCacheItem(e),c.remove(e)}}),o}function p(e,t){for(var n=0;n=this.buffer.getAbsMinIndex()&&e<=this.buffer.getAbsMaxIndex()&&angular.isArray(t)&&!t.length&&(this.viewport.removeCacheItem(e,e===this.buffer.minIndex),e===this.buffer.getAbsMinIndex()?this.buffer.incrementMinIndex():this.buffer.decrementMaxIndex())}},{key:"applyUpdate",value:function(t,e){var n=this;if(angular.isArray(e)){var r=this.buffer.indexOf(t);e.reverse().some(function(e){return e===t.item})||(t.op="remove",0!==r||e.length||(t._op="isTop")),e.forEach(function(e){e===t.item?r--:n.buffer.insert(r+1,e,-1===r)})}}},{key:"calculateProperties",value:function(){for(var e=null,t=0,n=!1,r=!1,i=this.buffer.length,o=0;othis.viewport.topVisiblePos()&&(n=!0,this.topVisible=a.item,this.topVisibleElement=a.element,this.topVisibleScope=a.scope),!r&&(l>=this.viewport.bottomVisiblePos()||o===i-1&&this.isEOF())&&(r=!0,this.bottomVisible=a.item,this.bottomVisibleElement=a.element,this.bottomVisibleScope=a.scope),t+=u}if(e=s,n&&r)break}}}])&&p(e.prototype,t),n&&p(e,n),u}();angular.module("ui.scroll",[]).constant("JQLiteExtras",r).run(["JQLiteExtras",function(e){var t=angular.element;!(window.jQuery&&t.fn&&t.fn.jquery)&&(new e).registerFor(t),z.addCSSRules()}]).directive("uiScrollViewport",function(){return{restrict:"A",controller:["$scope","$element",function(e,t){var n=this;return this.container=t,this.viewport=t,this.scope=e,angular.forEach(t.children(),function(e){"tbody"===e.tagName.toLowerCase()&&(n.viewport=angular.element(e))}),this}]}}).directive("uiScroll",["$log","$injector","$rootScope","$timeout","$interval","$q","$parse",function(e,B,D,F,R,W,q){return{require:["?^uiScrollViewport"],restrict:"A",transclude:"element",priority:1e3,terminal:!0,link:function(i,e,t,n,a){var r=t.uiScroll.match(/^\s*(\w+)\s+in\s+([(\w|\$)\.]+)\s*$/);if(!r)throw new Error("Expected uiScroll in form of '_item_ in _datasource_' but got '"+t.uiScroll+"'");function o(e,t,n){return n||(e=null===e?t:Math.floor(e)),isNaN(e)?t:e}function s(e,t,n){var r=q(e)(i);return o(r,t,n)}var u=null,l=r[1],c=r[2],f=n[0],d=Math.max(3,s(t.bufferSize,10)),h=Math.max(.3,s(t.padding,.5,!0)),p=s(t.startIndex,1),m=0,g=[],v=new z(B,W),b=new Q(v,d,p),x=new X(v,b,e,f,D,h),y=new Y(i,q,t,x,b,C,function(){x.resetTopPadding(),x.resetBottomPadding(),arguments.length&&(p=o(arguments[0],1,!1));b.reset(p),E(u,"minIndex"),E(u,"maxIndex"),C()});f&&(f.adapter=y);var w=function(){return"[object Object]"===Object.prototype.toString.call(u)&&"function"==typeof u.get};if(u=q(c)(i),!w()&&(u=B.get(c),!w()))throw new Error(c+" is not a valid datasource");var I=[];function E(e,t){var n;angular.isNumber(e[t])&&(n=e[t],angular.isNumber(n)&&(I=I.filter(function(e){return e.id!==t})).push({id:t,run:function(){return e[t]=n}}))}function $(n,r,i){var o,e=Object.getOwnPropertyDescriptor(n,r);e&&(e.set||e.get)||(E(n,r),Object.defineProperty(n,r,{set:function(e){if(o=e,!g.length||b.length){b[i]=e;var t=x.topDataPos();x.adjustPaddings(),"minIndex"===r&&x.onAfterMinIndexSet(t)}else E(n,r)},get:function(){return o}}))}$(u,"minIndex","minIndexUser"),$(u,"maxIndex","maxIndexUser");var P=2!==u.get.length?function(e){return u.get(b.next,d,e)}:function(e){u.get({index:b.next,append:b.length?b[b.length-1].item:void 0,count:d},e)},T=2!==u.get.length?function(e){return u.get(b.first-d,d,e)}:function(e){u.get({index:b.first-d,prepend:b.length?b[0].item:void 0,count:d},e)};function S(e){return e&&e!==m||i.$$destroyed}function k(){x.unbind("resize",_),x.unbind("scroll",_)}function A(e){return e.element.height()&&e.element[0].offsetParent}function O(e,t){j(e,t,x.insertElement),A(e)||(e.unregisterVisibilityWatcher=e.scope.$watch(function(){A(e)&&(b.forEach(function(e){"function"==typeof e.unregisterVisibilityWatcher&&(e.unregisterVisibilityWatcher(),delete e.unregisterVisibilityWatcher)}),g.length||F(function(){return C()}))})),v.hideElement(e)}function j(n,e,r){var i=null,o=0 obj && obj.document && obj.location && obj.alert && obj.setInterval;\r\n\r\n function scrollTo(self, direction, value) {\r\n let elem = self[0];\r\n let [method, prop, preserve] = {\r\n top: [\r\n 'scrollTop',\r\n 'pageYOffset',\r\n 'scrollLeft'\r\n ],\r\n left: [\r\n 'scrollLeft',\r\n 'pageXOffset',\r\n 'scrollTop'\r\n ]\r\n }[direction];\r\n\r\n const isValueDefined = typeof value !== 'undefined';\r\n if (isWindow(elem)) {\r\n if (isValueDefined) {\r\n return elem.scrollTo(self[preserve].call(self), value);\r\n }\r\n return (prop in elem) ? elem[prop] : elem.document.documentElement[method];\r\n } else {\r\n if (isValueDefined) {\r\n elem[method] = value;\r\n }\r\n return elem[method];\r\n }\r\n }\r\n\r\n if (window.getComputedStyle) {\r\n getStyle = (elem) => window.getComputedStyle(elem, null);\r\n convertToPx = (elem, value) => parseFloat(value);\r\n } else {\r\n getStyle = (elem) => elem.currentStyle;\r\n convertToPx = (elem, value) => {\r\n let left, result, rs, rsLeft, style;\r\n let core_pnum = /[+-]?(?:\\d*\\.|)\\d+(?:[eE][+-]?\\d+|)/.source;\r\n let rnumnonpx = new RegExp('^(' + core_pnum + ')(?!px)[a-z%]+$', 'i');\r\n\r\n if (!rnumnonpx.test(value)) {\r\n return parseFloat(value);\r\n }\r\n\r\n // ported from JQuery\r\n style = elem.style;\r\n left = style.left;\r\n rs = elem.runtimeStyle;\r\n rsLeft = rs && rs.left;\r\n if (rs) {\r\n rs.left = style.left;\r\n }\r\n // put in the new values to get a computed style out\r\n style.left = value;\r\n result = style.pixelLeft;\r\n style.left = left;\r\n if (rsLeft) {\r\n rs.left = rsLeft;\r\n }\r\n return result;\r\n };\r\n }\r\n\r\n function getMeasurements(elem, measure) {\r\n let base, borderA, borderB, computedMarginA, computedMarginB, computedStyle, dirA, dirB, marginA, marginB, paddingA, paddingB;\r\n\r\n if (isWindow(elem)) {\r\n base = document.documentElement[{height: 'clientHeight', width: 'clientWidth'}[measure]];\r\n\r\n return {\r\n base: base,\r\n padding: 0,\r\n border: 0,\r\n margin: 0\r\n };\r\n }\r\n\r\n // Start with offset property\r\n [\r\n base,\r\n dirA,\r\n dirB\r\n ] = {\r\n width: [\r\n elem.offsetWidth,\r\n 'Left',\r\n 'Right'\r\n ],\r\n height: [\r\n elem.offsetHeight,\r\n 'Top',\r\n 'Bottom'\r\n ]\r\n }[measure];\r\n\r\n computedStyle = getStyle(elem);\r\n paddingA = convertToPx(elem, computedStyle['padding' + dirA]) || 0;\r\n paddingB = convertToPx(elem, computedStyle['padding' + dirB]) || 0;\r\n borderA = convertToPx(elem, computedStyle['border' + dirA + 'Width']) || 0;\r\n borderB = convertToPx(elem, computedStyle['border' + dirB + 'Width']) || 0;\r\n computedMarginA = computedStyle['margin' + dirA];\r\n computedMarginB = computedStyle['margin' + dirB];\r\n\r\n // I do not care for width for now, so this hack is irrelevant\r\n // if ( !supportsPercentMargin )\r\n // computedMarginA = hackPercentMargin( elem, computedStyle, computedMarginA )\r\n // computedMarginB = hackPercentMargin( elem, computedStyle, computedMarginB )\r\n marginA = convertToPx(elem, computedMarginA) || 0;\r\n marginB = convertToPx(elem, computedMarginB) || 0;\r\n\r\n return {\r\n base: base,\r\n padding: paddingA + paddingB,\r\n border: borderA + borderB,\r\n margin: marginA + marginB\r\n };\r\n }\r\n\r\n function getWidthHeight(elem, direction, measure) {\r\n let computedStyle, result;\r\n\r\n let measurements = getMeasurements(elem, direction);\r\n\r\n if (measurements.base > 0) {\r\n return {\r\n base: measurements.base - measurements.padding - measurements.border,\r\n outer: measurements.base,\r\n outerfull: measurements.base + measurements.margin\r\n }[measure];\r\n }\r\n\r\n // Fall back to computed then uncomputed css if necessary\r\n computedStyle = getStyle(elem);\r\n result = computedStyle[direction];\r\n\r\n if (result < 0 || result === null) {\r\n result = elem.style[direction] || 0;\r\n }\r\n\r\n // Normalize \"\", auto, and prepare for extra\r\n result = parseFloat(result) || 0;\r\n\r\n return {\r\n base: result - measurements.padding - measurements.border,\r\n outer: result,\r\n outerfull: result + measurements.padding + measurements.border + measurements.margin\r\n }[measure];\r\n }\r\n\r\n // define missing methods\r\n return angular.forEach({\r\n before(newElem) {\r\n var children, elem, i, j, parent, ref, self;\r\n self = this;\r\n elem = self[0];\r\n parent = self.parent();\r\n children = parent.contents();\r\n if (children[0] === elem) {\r\n return parent.prepend(newElem);\r\n } else {\r\n for (i = j = 1, ref = children.length - 1; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {\r\n if (children[i] === elem) {\r\n angular.element(children[i - 1]).after(newElem);\r\n return;\r\n }\r\n }\r\n throw new Error('invalid DOM structure ' + elem.outerHTML);\r\n }\r\n },\r\n height (value){\r\n var self;\r\n self = this;\r\n if (typeof value !== 'undefined') {\r\n if (angular.isNumber(value)) {\r\n value = value + 'px';\r\n }\r\n return css.call(self, 'height', value);\r\n } else {\r\n return getWidthHeight(this[0], 'height', 'base');\r\n }\r\n },\r\n outerHeight(option) {\r\n return getWidthHeight(this[0], 'height', option ? 'outerfull' : 'outer');\r\n },\r\n outerWidth(option) {\r\n return getWidthHeight(this[0], 'width', option ? 'outerfull' : 'outer');\r\n },\r\n\r\n /*\r\n The offset setter method is not implemented\r\n */\r\n offset(value) {\r\n let docElem, win;\r\n let self = this;\r\n let box = {\r\n top: 0,\r\n left: 0\r\n };\r\n let elem = self[0];\r\n let doc = elem && elem.ownerDocument;\r\n\r\n if (arguments.length) {\r\n if (value === undefined) {\r\n return self;\r\n }\r\n // TODO: implement setter\r\n throw new Error('offset setter method is not implemented');\r\n }\r\n\r\n if (!doc) {\r\n return;\r\n }\r\n\r\n docElem = doc.documentElement;\r\n\r\n // TODO: Make sure it's not a disconnected DOM node\r\n\r\n if (elem.getBoundingClientRect != null) {\r\n box = elem.getBoundingClientRect();\r\n }\r\n\r\n win = doc.defaultView || doc.parentWindow;\r\n\r\n return {\r\n top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),\r\n left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)\r\n };\r\n },\r\n scrollTop(value) {\r\n return scrollTo(this, 'top', value);\r\n },\r\n scrollLeft(value) {\r\n return scrollTo(this, 'left', value);\r\n }\r\n }, (value, key) => {\r\n if (!element.prototype[key]) {\r\n return element.prototype[key] = value;\r\n }\r\n });\r\n }\r\n\r\n}\r\n","const hideClassToken = 'ng-ui-scroll-hide';\r\n\r\nexport default class ElementRoutines {\r\n\r\n static addCSSRules() {\r\n const selector = '.' + hideClassToken;\r\n const rules = 'display: none';\r\n const sheet = document.styleSheets[0];\r\n let index;\r\n try {\r\n index = sheet.cssRules.length;\r\n } catch (err) {\r\n index = 0;\r\n }\r\n if('insertRule' in sheet) {\r\n sheet.insertRule(selector + '{' + rules + '}', index);\r\n }\r\n else if('addRule' in sheet) {\r\n sheet.addRule(selector, rules, index);\r\n }\r\n }\r\n\r\n constructor($injector, $q) {\r\n this.$animate = ($injector.has && $injector.has('$animate')) ? $injector.get('$animate') : null;\r\n this.isAngularVersionLessThen1_3 = angular.version.major === 1 && angular.version.minor < 3;\r\n this.$q = $q;\r\n }\r\n\r\n hideElement(wrapper) {\r\n wrapper.element.addClass(hideClassToken);\r\n }\r\n\r\n showElement(wrapper) {\r\n wrapper.element.removeClass(hideClassToken);\r\n }\r\n\r\n insertElement(newElement, previousElement) {\r\n previousElement.after(newElement);\r\n return [];\r\n }\r\n\r\n removeElement(wrapper) {\r\n wrapper.element.remove();\r\n wrapper.scope.$destroy();\r\n return [];\r\n }\r\n\r\n insertElementAnimated(newElement, previousElement) {\r\n if (!this.$animate) {\r\n return this.insertElement(newElement, previousElement);\r\n }\r\n\r\n if (this.isAngularVersionLessThen1_3) {\r\n const deferred = this.$q.defer();\r\n // no need for parent - previous element is never null\r\n this.$animate.enter(newElement, null, previousElement, () => deferred.resolve());\r\n\r\n return [deferred.promise];\r\n }\r\n\r\n // no need for parent - previous element is never null\r\n return [this.$animate.enter(newElement, null, previousElement)];\r\n }\r\n\r\n removeElementAnimated(wrapper) {\r\n if (!this.$animate) {\r\n return this.removeElement(wrapper);\r\n }\r\n\r\n if (this.isAngularVersionLessThen1_3) {\r\n const deferred = this.$q.defer();\r\n this.$animate.leave(wrapper.element, () => {\r\n wrapper.scope.$destroy();\r\n return deferred.resolve();\r\n });\r\n\r\n return [deferred.promise];\r\n }\r\n\r\n return [(this.$animate.leave(wrapper.element)).then(() => wrapper.scope.$destroy())];\r\n }\r\n}","export default function ScrollBuffer(elementRoutines, bufferSize, startIndex) {\r\n const buffer = Object.create(Array.prototype);\r\n\r\n angular.extend(buffer, {\r\n size: bufferSize,\r\n\r\n reset(startIndex) {\r\n buffer.remove(0, buffer.length);\r\n buffer.eof = false;\r\n buffer.bof = false;\r\n buffer.first = startIndex;\r\n buffer.next = startIndex;\r\n buffer.minIndex = startIndex;\r\n buffer.maxIndex = startIndex;\r\n buffer.minIndexUser = null;\r\n buffer.maxIndexUser = null;\r\n },\r\n\r\n append(items) {\r\n items.forEach((item) => {\r\n ++buffer.next;\r\n buffer.insert('append', item);\r\n });\r\n buffer.maxIndex = buffer.eof ? buffer.next - 1 : Math.max(buffer.next - 1, buffer.maxIndex);\r\n },\r\n\r\n prepend(items) {\r\n items.reverse().forEach((item) => {\r\n --buffer.first;\r\n buffer.insert('prepend', item);\r\n });\r\n buffer.minIndex = buffer.bof ? buffer.minIndex = buffer.first : Math.min(buffer.first, buffer.minIndex);\r\n },\r\n\r\n /**\r\n * inserts wrapped element in the buffer\r\n * the first argument is either operation keyword (see below) or a number for operation 'insert'\r\n * for insert the number is the index for the buffer element the new one have to be inserted after\r\n * operations: 'append', 'prepend', 'insert', 'remove', 'update', 'none'\r\n */\r\n insert(operation, item, isTop) {\r\n const wrapper = {\r\n item: item\r\n };\r\n\r\n if (operation % 1 === 0) {// it is an insert\r\n wrapper.op = 'insert';\r\n buffer.splice(operation, 0, wrapper);\r\n if(isTop) {\r\n buffer.first--;\r\n }\r\n else {\r\n buffer.next++;\r\n }\r\n } else {\r\n wrapper.op = operation;\r\n switch (operation) {\r\n case 'append':\r\n buffer.push(wrapper);\r\n break;\r\n case 'prepend':\r\n buffer.unshift(wrapper);\r\n break;\r\n }\r\n }\r\n },\r\n\r\n // removes elements from buffer\r\n remove(arg1, arg2) {\r\n if (angular.isNumber(arg1)) {\r\n // removes items from arg1 (including) through arg2 (excluding)\r\n for (let i = arg1; i < arg2; i++) {\r\n elementRoutines.removeElement(buffer[i]);\r\n }\r\n return buffer.splice(arg1, arg2 - arg1);\r\n }\r\n // removes single item(wrapper) from the buffer\r\n buffer.splice(buffer.indexOf(arg1), 1);\r\n if(arg1._op === 'isTop' && buffer.first === this.getAbsMinIndex()) {\r\n this.incrementMinIndex();\r\n }\r\n else {\r\n this.decrementMaxIndex();\r\n }\r\n if(arg1._op === 'isTop') {\r\n buffer.first++;\r\n }\r\n else {\r\n buffer.next--;\r\n }\r\n if(!buffer.length) {\r\n buffer.first = 1;\r\n buffer.next = 1;\r\n }\r\n\r\n return elementRoutines.removeElementAnimated(arg1);\r\n },\r\n\r\n incrementMinIndex() {\r\n if(buffer.minIndexUser !== null) {\r\n if(buffer.minIndex > buffer.minIndexUser) {\r\n buffer.minIndexUser++;\r\n return;\r\n }\r\n if(buffer.minIndex === buffer.minIndexUser) {\r\n buffer.minIndexUser++;\r\n }\r\n }\r\n buffer.minIndex++;\r\n },\r\n\r\n decrementMaxIndex() {\r\n if(buffer.maxIndexUser !== null && buffer.maxIndex <= buffer.maxIndexUser) {\r\n buffer.maxIndexUser--;\r\n }\r\n buffer.maxIndex--;\r\n },\r\n\r\n getAbsMinIndex() {\r\n if(buffer.minIndexUser !== null) {\r\n return Math.min(buffer.minIndexUser, buffer.minIndex);\r\n }\r\n return buffer.minIndex;\r\n },\r\n\r\n getAbsMaxIndex() {\r\n if(buffer.maxIndexUser !== null) {\r\n return Math.max(buffer.maxIndexUser, buffer.maxIndex);\r\n }\r\n return buffer.maxIndex;\r\n },\r\n\r\n effectiveHeight(elements) {\r\n if (!elements.length) {\r\n return 0;\r\n }\r\n let top = Number.MAX_VALUE;\r\n let bottom = Number.NEGATIVE_INFINITY;\r\n elements.forEach((wrapper) => {\r\n if (wrapper.element[0].offsetParent) {\r\n // element style is not display:none\r\n top = Math.min(top, wrapper.element.offset().top);\r\n bottom = Math.max(bottom, wrapper.element.offset().top + wrapper.element.outerHeight(true));\r\n }\r\n });\r\n return Math.max(0, bottom - top);\r\n }\r\n\r\n });\r\n\r\n buffer.reset(startIndex);\r\n\r\n return buffer;\r\n}\r\n","// Can't just extend the Array, due to Babel does not support built-in classes extending\r\n// This solution was taken from https://stackoverflow.com/questions/46897414/es6-class-extends-array-workaround-for-es5-babel-transpile\r\nclass CacheProto {\r\n add(item) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index === item.scope.$index) {\r\n this[i].height = item.element.outerHeight();\r\n return;\r\n }\r\n }\r\n this.push({\r\n index: item.scope.$index,\r\n height: item.element.outerHeight()\r\n });\r\n this.sort((a, b) => ((a.index < b.index) ? -1 : ((a.index > b.index) ? 1 : 0)));\r\n }\r\n\r\n remove(argument, _isTop) {\r\n const index = argument % 1 === 0 ? argument : argument.scope.$index;\r\n const isTop = argument % 1 === 0 ? _isTop : argument._op === 'isTop';\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index === index) {\r\n this.splice(i, 1);\r\n break;\r\n }\r\n }\r\n if(!isTop) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index > index) {\r\n this[i].index--;\r\n }\r\n }\r\n }\r\n }\r\n\r\n clear() {\r\n this.length = 0;\r\n }\r\n}\r\n\r\nfunction Cache() {\r\n const instance = [];\r\n instance.push.apply(instance, arguments);\r\n Object.setPrototypeOf(instance, Cache.prototype);\r\n return instance;\r\n}\r\nCache.prototype = Object.create(Array.prototype);\r\nObject.getOwnPropertyNames(CacheProto.prototype).forEach(methodName =>\r\n Cache.prototype[methodName] = CacheProto.prototype[methodName]\r\n);\r\n\r\nfunction generateElement(template) {\r\n if(template.nodeType !== Node.ELEMENT_NODE) {\r\n throw new Error('ui-scroll directive requires an Element node for templating the view');\r\n }\r\n let element;\r\n switch (template.tagName.toLowerCase()) {\r\n case 'dl':\r\n throw new Error(`ui-scroll directive does not support <${template.tagName}> as a repeating tag: ${template.outerHTML}`);\r\n case 'tr':\r\n let table = angular.element('
    ');\r\n element = table.find('tr');\r\n break;\r\n case 'li':\r\n element = angular.element('
  • ');\r\n break;\r\n default:\r\n element = angular.element('
    ');\r\n }\r\n return element;\r\n}\r\n\r\nclass Padding {\r\n constructor(template) {\r\n this.element = generateElement(template);\r\n this.cache = new Cache();\r\n }\r\n\r\n height() {\r\n return this.element.height.apply(this.element, arguments);\r\n }\r\n}\r\n\r\nexport default Padding;","import Padding from './padding';\r\n\r\nexport default function Viewport(elementRoutines, buffer, element, viewportController, $rootScope, padding) {\r\n let topPadding = null;\r\n let bottomPadding = null;\r\n const viewport = viewportController && viewportController.viewport ? viewportController.viewport : angular.element(window);\r\n const container = viewportController && viewportController.container ? viewportController.container : undefined;\r\n const scope = viewportController && viewportController.scope ? viewportController.scope : $rootScope;\r\n\r\n viewport.css({\r\n 'overflow-anchor': 'none',\r\n 'overflow-y': 'auto',\r\n 'display': 'block'\r\n });\r\n\r\n function bufferPadding() {\r\n return viewport.outerHeight() * padding; // some extra space to initiate preload\r\n }\r\n\r\n angular.extend(viewport, {\r\n getScope() {\r\n return scope;\r\n },\r\n\r\n createPaddingElements(template) {\r\n topPadding = new Padding(template);\r\n bottomPadding = new Padding(template);\r\n element.before(topPadding.element);\r\n element.after(bottomPadding.element);\r\n topPadding.height(0);\r\n bottomPadding.height(0);\r\n },\r\n\r\n applyContainerStyle() {\r\n if (!container) {\r\n return true;\r\n }\r\n if(container !== viewport) {\r\n viewport.css('height', window.getComputedStyle(container[0]).height);\r\n }\r\n return viewport.height() > 0;\r\n },\r\n\r\n bottomDataPos() {\r\n let scrollHeight = viewport[0].scrollHeight;\r\n scrollHeight = scrollHeight != null ? scrollHeight : viewport[0].document.documentElement.scrollHeight;\r\n return scrollHeight - bottomPadding.height();\r\n },\r\n\r\n topDataPos() {\r\n return topPadding.height();\r\n },\r\n\r\n bottomVisiblePos() {\r\n return viewport.scrollTop() + viewport.outerHeight();\r\n },\r\n\r\n topVisiblePos() {\r\n return viewport.scrollTop();\r\n },\r\n\r\n insertElement(e, sibling) {\r\n return elementRoutines.insertElement(e, sibling || topPadding.element);\r\n },\r\n\r\n insertElementAnimated(e, sibling) {\r\n return elementRoutines.insertElementAnimated(e, sibling || topPadding.element);\r\n },\r\n\r\n shouldLoadBottom() {\r\n return !buffer.eof && viewport.bottomDataPos() < viewport.bottomVisiblePos() + bufferPadding();\r\n },\r\n\r\n clipBottom() {\r\n // clip the invisible items off the bottom\r\n let overage = 0;\r\n let overageHeight = 0;\r\n let itemHeight = 0;\r\n let emptySpaceHeight = viewport.bottomDataPos() - viewport.bottomVisiblePos() - bufferPadding();\r\n\r\n for (let i = buffer.length - 1; i >= 0; i--) {\r\n itemHeight = buffer[i].element.outerHeight(true);\r\n if (overageHeight + itemHeight > emptySpaceHeight) {\r\n break;\r\n }\r\n bottomPadding.cache.add(buffer[i]);\r\n overageHeight += itemHeight;\r\n overage++;\r\n }\r\n\r\n if (overage > 0) {\r\n buffer.eof = false;\r\n buffer.remove(buffer.length - overage, buffer.length);\r\n buffer.next -= overage;\r\n viewport.adjustPaddings();\r\n }\r\n },\r\n\r\n shouldLoadTop() {\r\n return !buffer.bof && (viewport.topDataPos() > viewport.topVisiblePos() - bufferPadding());\r\n },\r\n\r\n clipTop() {\r\n // clip the invisible items off the top\r\n let overage = 0;\r\n let overageHeight = 0;\r\n let itemHeight = 0;\r\n let emptySpaceHeight = viewport.topVisiblePos() - viewport.topDataPos() - bufferPadding();\r\n\r\n for (let i = 0; i < buffer.length; i++) {\r\n itemHeight = buffer[i].element.outerHeight(true);\r\n if (overageHeight + itemHeight > emptySpaceHeight) {\r\n break;\r\n }\r\n topPadding.cache.add(buffer[i]);\r\n overageHeight += itemHeight;\r\n overage++;\r\n }\r\n\r\n if (overage > 0) {\r\n // we need to adjust top padding element before items are removed from top\r\n // to avoid strange behaviour of scroll bar during remove top items when we are at the very bottom\r\n topPadding.height(topPadding.height() + overageHeight);\r\n buffer.bof = false;\r\n buffer.remove(0, overage);\r\n buffer.first += overage;\r\n }\r\n },\r\n\r\n adjustPaddings() {\r\n if (!buffer.length) {\r\n return;\r\n }\r\n\r\n // precise heights calculation based on items that are in buffer or that were in buffer once\r\n const visibleItemsHeight = buffer.reduce((summ, item) => summ + item.element.outerHeight(true), 0);\r\n\r\n let topPaddingHeight = 0, topCount = 0;\r\n topPadding.cache.forEach(item => {\r\n if(item.index < buffer.first) {\r\n topPaddingHeight += item.height;\r\n topCount++;\r\n }\r\n });\r\n\r\n let bottomPaddingHeight = 0, bottomCount = 0;\r\n bottomPadding.cache.forEach(item => {\r\n if(item.index >= buffer.next) {\r\n bottomPaddingHeight += item.height;\r\n bottomCount++;\r\n }\r\n });\r\n\r\n const totalHeight = visibleItemsHeight + topPaddingHeight + bottomPaddingHeight;\r\n const averageItemHeight = totalHeight / (topCount + bottomCount + buffer.length);\r\n\r\n // average heights calculation, items that have never been reached\r\n let adjustTopPadding = buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser;\r\n let adjustBottomPadding = buffer.maxIndexUser !== null && buffer.maxIndex < buffer.maxIndexUser;\r\n let topPaddingHeightAdd = adjustTopPadding ? (buffer.minIndex - buffer.minIndexUser) * averageItemHeight : 0;\r\n let bottomPaddingHeightAdd = adjustBottomPadding ? (buffer.maxIndexUser - buffer.maxIndex) * averageItemHeight : 0;\r\n\r\n // paddings combine adjustment\r\n topPadding.height(topPaddingHeight + topPaddingHeightAdd);\r\n bottomPadding.height(bottomPaddingHeight + bottomPaddingHeightAdd);\r\n },\r\n\r\n onAfterMinIndexSet(topPaddingHeightOld) {\r\n // additional scrollTop adjustment in case of datasource.minIndex external set\r\n if (buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser) {\r\n let diff = topPadding.height() - topPaddingHeightOld;\r\n viewport.scrollTop(viewport.scrollTop() + diff);\r\n while((diff -= viewport.scrollTop()) > 0) {\r\n bottomPadding.height(bottomPadding.height() + diff);\r\n viewport.scrollTop(viewport.scrollTop() + diff);\r\n }\r\n }\r\n },\r\n\r\n onAfterPrepend(updates) {\r\n if (!updates.prepended.length)\r\n return;\r\n const height = buffer.effectiveHeight(updates.prepended);\r\n const paddingHeight = topPadding.height() - height;\r\n if (paddingHeight >= 0) {\r\n topPadding.height(paddingHeight);\r\n }\r\n else {\r\n topPadding.height(0);\r\n viewport.scrollTop(viewport.scrollTop() - paddingHeight);\r\n }\r\n },\r\n\r\n resetTopPadding() {\r\n topPadding.height(0);\r\n topPadding.cache.clear();\r\n },\r\n\r\n resetBottomPadding() {\r\n bottomPadding.height(0);\r\n bottomPadding.cache.clear();\r\n },\r\n\r\n removeCacheItem(item, isTop) {\r\n topPadding.cache.remove(item, isTop);\r\n bottomPadding.cache.remove(item, isTop);\r\n },\r\n\r\n removeItem(item) {\r\n this.removeCacheItem(item);\r\n return buffer.remove(item);\r\n }\r\n });\r\n\r\n return viewport;\r\n}\r\n","class Adapter {\r\n\r\n constructor($scope, $parse, $attr, viewport, buffer, doAdjust, reload) {\r\n this.$parse = $parse;\r\n this.$attr = $attr;\r\n this.viewport = viewport;\r\n this.buffer = buffer;\r\n\r\n this.doAdjust = doAdjust;\r\n this.reload = reload;\r\n\r\n this.isLoading = false;\r\n this.disabled = false;\r\n\r\n const viewportScope = viewport.getScope();\r\n this.startScope = viewportScope.$parent ? viewportScope : $scope;\r\n\r\n this.publicContext = {};\r\n this.assignAdapter($attr.adapter);\r\n this.generatePublicContext();\r\n }\r\n\r\n assignAdapter(adapterAttr) {\r\n if (!adapterAttr || !(adapterAttr = adapterAttr.replace(/^\\s+|\\s+$/gm, ''))) {\r\n return;\r\n }\r\n let adapterOnScope;\r\n\r\n try {\r\n this.$parse(adapterAttr).assign(this.startScope, {});\r\n adapterOnScope = this.$parse(adapterAttr)(this.startScope);\r\n }\r\n catch (error) {\r\n error.message = `Angular ui-scroll Adapter assignment exception.\\n` +\r\n `Can't parse \"${adapterAttr}\" expression.\\n` +\r\n error.message;\r\n throw error;\r\n }\r\n\r\n angular.extend(adapterOnScope, this.publicContext);\r\n this.publicContext = adapterOnScope;\r\n }\r\n\r\n generatePublicContext() {\r\n // these methods will be accessible out of ui-scroll via user defined adapter\r\n const publicMethods = ['reload', 'applyUpdates', 'append', 'prepend', 'isBOF', 'isEOF', 'isEmpty'];\r\n for (let i = publicMethods.length - 1; i >= 0; i--) {\r\n this.publicContext[publicMethods[i]] = this[publicMethods[i]].bind(this);\r\n }\r\n\r\n // these read-only props will be accessible out of ui-scroll via user defined adapter\r\n const publicProps = ['isLoading', 'topVisible', 'topVisibleElement', 'topVisibleScope', 'bottomVisible', 'bottomVisibleElement', 'bottomVisibleScope'];\r\n for (let i = publicProps.length - 1; i >= 0; i--) {\r\n let property, attr = this.$attr[publicProps[i]];\r\n Object.defineProperty(this, publicProps[i], {\r\n get: () => property,\r\n set: (value) => {\r\n property = value;\r\n this.publicContext[publicProps[i]] = value;\r\n if (attr) {\r\n this.$parse(attr).assign(this.startScope, value);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // non-read-only public property\r\n Object.defineProperty(this.publicContext, 'disabled', {\r\n get: () => this.disabled,\r\n set: (value) => (!(this.disabled = value)) ? this.doAdjust() : null\r\n });\r\n }\r\n\r\n loading(value) {\r\n this.isLoading = value;\r\n }\r\n\r\n isBOF() {\r\n return this.buffer.bof;\r\n }\r\n\r\n isEOF() {\r\n return this.buffer.eof;\r\n }\r\n\r\n isEmpty() {\r\n return !this.buffer.length;\r\n }\r\n\r\n append(newItems) {\r\n this.buffer.append(newItems);\r\n this.doAdjust();\r\n this.viewport.clipTop();\r\n this.viewport.clipBottom();\r\n }\r\n\r\n prepend(newItems) {\r\n this.buffer.prepend(newItems);\r\n this.doAdjust();\r\n this.viewport.clipTop();\r\n this.viewport.clipBottom();\r\n }\r\n\r\n applyUpdates(arg1, arg2) {\r\n if (typeof arg1 === 'function') {\r\n this.applyUpdatesFunc(arg1);\r\n } else {\r\n this.applyUpdatesIndex(arg1, arg2);\r\n }\r\n this.doAdjust();\r\n }\r\n\r\n applyUpdatesFunc(cb) {\r\n this.buffer.slice(0).forEach((wrapper) => {\r\n // we need to do it on the buffer clone, because buffer content\r\n // may change as we iterate through\r\n this.applyUpdate(wrapper, cb(wrapper.item, wrapper.scope, wrapper.element));\r\n });\r\n }\r\n\r\n applyUpdatesIndex(index, newItems) {\r\n if (index % 1 !== 0) {\r\n throw new Error('applyUpdates - ' + index + ' is not a valid index (should be an integer)');\r\n }\r\n const _index = index - this.buffer.first;\r\n\r\n // apply updates only within buffer\r\n if (_index >= 0 && _index < this.buffer.length) {\r\n this.applyUpdate(this.buffer[_index], newItems);\r\n }\r\n // out-of-buffer case: deletion may affect Paddings\r\n else if(index >= this.buffer.getAbsMinIndex() && index <= this.buffer.getAbsMaxIndex()) {\r\n if(angular.isArray(newItems) && !newItems.length) {\r\n this.viewport.removeCacheItem(index, index === this.buffer.minIndex);\r\n if(index === this.buffer.getAbsMinIndex()) {\r\n this.buffer.incrementMinIndex();\r\n }\r\n else {\r\n this.buffer.decrementMaxIndex();\r\n }\r\n }\r\n }\r\n }\r\n\r\n applyUpdate(wrapper, newItems) {\r\n if (!angular.isArray(newItems)) {\r\n return;\r\n }\r\n let position = this.buffer.indexOf(wrapper);\r\n if (!newItems.reverse().some(newItem => newItem === wrapper.item)) {\r\n wrapper.op = 'remove';\r\n if(position === 0 && !newItems.length) {\r\n wrapper._op = 'isTop'; // to catch \"first\" edge case on remove\r\n }\r\n }\r\n newItems.forEach((newItem) => {\r\n if (newItem === wrapper.item) {\r\n position--;\r\n } else {\r\n // 3 parameter (isTop) is to catch \"first\" edge case on insert\r\n this.buffer.insert(position + 1, newItem, position === -1);\r\n }\r\n });\r\n }\r\n\r\n calculateProperties() {\r\n let rowTop = null, topHeight = 0;\r\n let topDone = false, bottomDone = false;\r\n const length = this.buffer.length;\r\n\r\n for (let i = 0; i < length; i++) {\r\n const item = this.buffer[i];\r\n const itemTop = item.element.offset().top;\r\n\r\n if (rowTop !== itemTop) { // a new row condition\r\n const itemHeight = item.element.outerHeight(true);\r\n const top = this.viewport.topDataPos() + topHeight + itemHeight;\r\n\r\n if (!topDone && top > this.viewport.topVisiblePos()) {\r\n topDone = true;\r\n this['topVisible'] = item.item;\r\n this['topVisibleElement'] = item.element;\r\n this['topVisibleScope'] = item.scope;\r\n }\r\n if (!bottomDone && (top >= this.viewport.bottomVisiblePos() || (i === length - 1 && this.isEOF()))) {\r\n bottomDone = true;\r\n this['bottomVisible'] = item.item;\r\n this['bottomVisibleElement'] = item.element;\r\n this['bottomVisibleScope'] = item.scope;\r\n }\r\n topHeight += itemHeight;\r\n }\r\n rowTop = itemTop;\r\n\r\n if (topDone && bottomDone) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n}\r\n\r\nexport default Adapter;\r\n","import JQLiteExtras from './modules/jqLiteExtras';\nimport ElementRoutines from './modules/elementRoutines.js';\nimport ScrollBuffer from './modules/buffer.js';\nimport Viewport from './modules/viewport.js';\nimport Adapter from './modules/adapter.js';\n\nangular.module('ui.scroll', [])\n\n .constant('JQLiteExtras', JQLiteExtras)\n .run(['JQLiteExtras', (JQLiteExtras) => {\n !window.jQuery ? (new JQLiteExtras()).registerFor(angular.element) : null;\n ElementRoutines.addCSSRules();\n }])\n\n .directive('uiScrollViewport', function () {\n return {\n restrict: 'A',\n controller: [\n '$scope',\n '$element',\n function (scope, element) {\n this.container = element;\n this.viewport = element;\n this.scope = scope;\n\n angular.forEach(element.children(), child => {\n if (child.tagName.toLowerCase() === 'tbody') {\n this.viewport = angular.element(child);\n }\n });\n\n return this;\n }\n ]\n };\n })\n\n .directive('uiScroll', [\n '$log',\n '$injector',\n '$rootScope',\n '$timeout',\n '$interval',\n '$q',\n '$parse',\n function (console, $injector, $rootScope, $timeout, $interval, $q, $parse) {\n\n return {\n require: ['?^uiScrollViewport'],\n restrict: 'A',\n transclude: 'element',\n priority: 1000,\n terminal: true,\n link: link\n };\n\n function link($scope, element, $attr, controllers, linker) {\n const match = $attr.uiScroll.match(/^\\s*(\\w+)\\s+in\\s+([(\\w|\\$)\\.]+)\\s*$/);\n if (!match) {\n throw new Error('Expected uiScroll in form of \\'_item_ in _datasource_\\' but got \\'' + $attr.uiScroll + '\\'');\n }\n\n function parseNumber(value, defaultValue, isFloat) {\n if (!isFloat) {\n value = value === null ? defaultValue : Math.floor(value);\n }\n return isNaN(value) ? defaultValue : value;\n }\n\n function parseNumericAttr(value, defaultValue, isFloat) {\n const result = $parse(value)($scope);\n return parseNumber(result, defaultValue, isFloat);\n }\n\n const BUFFER_MIN = 3;\n const BUFFER_DEFAULT = 10;\n const PADDING_MIN = 0.3;\n const PADDING_DEFAULT = 0.5;\n const START_INDEX_DEFAULT = 1;\n const MAX_VIEWPORT_DELAY = 500;\n const VIEWPORT_POLLING_INTERVAL = 50;\n\n let datasource = null;\n const itemName = match[1];\n const datasourceName = match[2];\n const viewportController = controllers[0];\n const bufferSize = Math.max(BUFFER_MIN, parseNumericAttr($attr.bufferSize, BUFFER_DEFAULT));\n const padding = Math.max(PADDING_MIN, parseNumericAttr($attr.padding, PADDING_DEFAULT, true));\n let startIndex = parseNumericAttr($attr.startIndex, START_INDEX_DEFAULT);\n let ridActual = 0; // current data revision id\n let pending = [];\n\n const elementRoutines = new ElementRoutines($injector, $q);\n const buffer = new ScrollBuffer(elementRoutines, bufferSize, startIndex);\n const viewport = new Viewport(elementRoutines, buffer, element, viewportController, $rootScope, padding);\n const adapter = new Adapter($scope, $parse, $attr, viewport, buffer, doAdjust, reload);\n\n if (viewportController) {\n viewportController.adapter = adapter;\n }\n\n const isDatasourceValid = () =>\n Object.prototype.toString.call(datasource) === '[object Object]' && typeof datasource.get === 'function';\n\n datasource = $parse(datasourceName)($scope); // try to get datasource on scope\n if (!isDatasourceValid()) {\n datasource = $injector.get(datasourceName); // try to inject datasource as service\n if (!isDatasourceValid()) {\n throw new Error(datasourceName + ' is not a valid datasource');\n }\n }\n\n let onRenderHandlers = [];\n function onRenderHandlersRunner() {\n onRenderHandlers.forEach(handler => handler.run());\n onRenderHandlers = [];\n }\n function persistDatasourceIndex(datasource, propName) {\n let getter;\n // need to postpone min/maxIndexUser processing if the view is empty\n if(angular.isNumber(datasource[propName])) {\n getter = datasource[propName];\n if(angular.isNumber(getter)) {\n onRenderHandlers = onRenderHandlers.filter(handler => handler.id !== propName);\n onRenderHandlers.push({\n id: propName,\n run: () => datasource[propName] = getter\n });\n }\n }\n }\n\n function defineDatasourceIndex(datasource, propName, propUserName) {\n const descriptor = Object.getOwnPropertyDescriptor(datasource, propName);\n if (descriptor && (descriptor.set || descriptor.get)) {\n return;\n }\n let getter;\n persistDatasourceIndex(datasource, propName);\n Object.defineProperty(datasource, propName, {\n set: (value) => {\n getter = value;\n if(pending.length && !buffer.length) {\n persistDatasourceIndex(datasource, propName);\n return;\n }\n buffer[propUserName] = value;\n const topPaddingHeightOld = viewport.topDataPos();\n viewport.adjustPaddings();\n if (propName === 'minIndex') {\n viewport.onAfterMinIndexSet(topPaddingHeightOld);\n }\n },\n get: () => getter\n });\n }\n\n defineDatasourceIndex(datasource, 'minIndex', 'minIndexUser');\n defineDatasourceIndex(datasource, 'maxIndex', 'maxIndexUser');\n\n const fetchNext = (datasource.get.length !== 2) ?\n (success) => datasource.get(buffer.next, bufferSize, success) :\n (success) => {\n datasource.get({\n index: buffer.next,\n append: buffer.length ? buffer[buffer.length - 1].item : void 0,\n count: bufferSize\n }, success);\n };\n\n const fetchPrevious = (datasource.get.length !== 2) ?\n (success) => datasource.get(buffer.first - bufferSize, bufferSize, success) :\n (success) => {\n datasource.get({\n index: buffer.first - bufferSize,\n prepend: buffer.length ? buffer[0].item : void 0,\n count: bufferSize\n }, success);\n };\n\n const initialize = () => {\n let tryCount = 0;\n if(!viewport.applyContainerStyle()) {\n const timer = $interval(() => {\n tryCount++;\n if(viewport.applyContainerStyle()) {\n $interval.cancel(timer);\n doAdjust();\n }\n if(tryCount * VIEWPORT_POLLING_INTERVAL >= MAX_VIEWPORT_DELAY) {\n $interval.cancel(timer);\n throw Error(`ui-scroll directive requires a viewport with non-zero height in ${MAX_VIEWPORT_DELAY}ms`);\n }\n }, VIEWPORT_POLLING_INTERVAL);\n }\n else {\n doAdjust();\n }\n };\n\n /**\n * Build padding elements\n *\n * Calling linker is the only way I found to get access to the tag name of the template\n * to prevent the directive scope from pollution a new scope is created and destroyed\n * right after the builder creation is completed\n */\n linker((clone, scope) => {\n viewport.createPaddingElements(clone[0]);\n // we do not include the clone in the DOM. It means that the nested directives will not\n // be able to reach the parent directives, but in this case it is intentional because we\n // created the clone to access the template tag name\n scope.$destroy();\n clone.remove();\n });\n\n $scope.$on('$destroy', () => {\n unbindEvents();\n viewport.unbind('mousewheel', wheelHandler);\n });\n\n viewport.bind('mousewheel', wheelHandler);\n\n initialize();\n\n /* Private function definitions */\n\n function isInvalid(rid) {\n return (rid && rid !== ridActual) || $scope.$$destroyed;\n }\n\n function bindEvents() {\n viewport.bind('resize', resizeAndScrollHandler);\n viewport.bind('scroll', resizeAndScrollHandler);\n }\n\n function unbindEvents() {\n viewport.unbind('resize', resizeAndScrollHandler);\n viewport.unbind('scroll', resizeAndScrollHandler);\n }\n\n function reload() {\n viewport.resetTopPadding();\n viewport.resetBottomPadding();\n if (arguments.length) {\n startIndex = parseNumber(arguments[0], START_INDEX_DEFAULT, false);\n }\n buffer.reset(startIndex);\n persistDatasourceIndex(datasource, 'minIndex');\n persistDatasourceIndex(datasource, 'maxIndex');\n doAdjust();\n }\n\n function isElementVisible(wrapper) {\n return wrapper.element.height() && wrapper.element[0].offsetParent;\n }\n\n function visibilityWatcher(wrapper) {\n if (isElementVisible(wrapper)) {\n buffer.forEach((item) => {\n if (typeof item.unregisterVisibilityWatcher === 'function') {\n item.unregisterVisibilityWatcher();\n delete item.unregisterVisibilityWatcher;\n }\n });\n if (!pending.length) {\n $timeout(() => doAdjust());\n }\n }\n }\n\n function insertWrapperContent(wrapper, insertAfter) {\n createElement(wrapper, insertAfter, viewport.insertElement);\n if (!isElementVisible(wrapper)) {\n wrapper.unregisterVisibilityWatcher = wrapper.scope.$watch(() => visibilityWatcher(wrapper));\n }\n elementRoutines.hideElement(wrapper); // hide inserted elements before data binding\n }\n\n function createElement(wrapper, insertAfter, insertElement) {\n let promises = null;\n const sibling = (insertAfter > 0) ? buffer[insertAfter - 1].element : undefined;\n linker((clone, scope) => {\n promises = insertElement(clone, sibling);\n wrapper.element = clone;\n wrapper.scope = scope;\n scope[itemName] = wrapper.item;\n });\n // ui-scroll-grid apply\n if (adapter.transform) {\n const tdInitializer = wrapper.scope.uiScrollTdInitializer;\n if (tdInitializer && tdInitializer.linking) {\n adapter.transform(wrapper.scope, wrapper.element);\n } else {\n wrapper.scope.uiScrollTdInitializer = {\n onLink: () => adapter.transform(wrapper.scope, wrapper.element),\n scope: wrapper.scope\n };\n }\n }\n return promises;\n }\n\n function updateDOM() {\n let promises = [];\n const toBePrepended = [];\n const toBeRemoved = [];\n const inserted = [];\n\n buffer.forEach((wrapper, i) => {\n switch (wrapper.op) {\n case 'prepend':\n toBePrepended.unshift(wrapper);\n break;\n case 'append':\n insertWrapperContent(wrapper, i);\n wrapper.op = 'none';\n inserted.push(wrapper);\n break;\n case 'insert':\n promises = promises.concat(createElement(wrapper, i, viewport.insertElementAnimated));\n wrapper.op = 'none';\n inserted.push(wrapper);\n break;\n case 'remove':\n toBeRemoved.push(wrapper);\n }\n });\n\n toBeRemoved.forEach((wrapper) => promises = promises.concat(viewport.removeItem(wrapper)));\n\n if (toBePrepended.length)\n toBePrepended.forEach((wrapper) => {\n insertWrapperContent(wrapper);\n wrapper.op = 'none';\n });\n\n buffer.forEach((item, i) => item.scope.$index = buffer.first + i);\n\n return {\n prepended: toBePrepended,\n removed: toBeRemoved,\n inserted: inserted,\n animated: promises\n };\n\n }\n\n function updatePaddings(rid, updates) {\n // schedule another doAdjust after animation completion\n if (updates.animated.length) {\n $q.all(updates.animated).then(() => {\n viewport.adjustPaddings();\n doAdjust(rid);\n });\n } else {\n viewport.adjustPaddings();\n }\n }\n\n function enqueueFetch(rid, updates) {\n if (viewport.shouldLoadBottom()) {\n if (!updates || buffer.effectiveHeight(updates.inserted) > 0) {\n // this means that at least one item appended in the last batch has height > 0\n if (pending.push(true) === 1) {\n adapter.loading(true);\n fetch(rid);\n }\n }\n } else if (viewport.shouldLoadTop()) {\n if ((!updates || buffer.effectiveHeight(updates.prepended) > 0) || pending[0]) {\n // this means that at least one item appended in the last batch has height > 0\n // pending[0] = true means that previous fetch was appending. We need to force at least one prepend\n // BTW there will always be at least 1 element in the pending array because bottom is fetched first\n if (pending.push(false) === 1) {\n adapter.loading(true);\n fetch(rid);\n }\n }\n }\n }\n\n function processUpdates() {\n const updates = updateDOM();\n\n // We need the item bindings to be processed before we can do adjustments\n !$scope.$$phase && !$rootScope.$$phase && $scope.$digest();\n\n updates.inserted.forEach(w => elementRoutines.showElement(w));\n updates.prepended.forEach(w => elementRoutines.showElement(w));\n return updates;\n }\n\n function doAdjust(rid) {\n if (!rid) { // dismiss pending requests\n pending = [];\n rid = ++ridActual;\n }\n\n const updates = processUpdates();\n\n if (isInvalid(rid)) {\n return;\n }\n\n updatePaddings(rid, updates);\n enqueueFetch(rid);\n\n if (!pending.length) {\n adapter.calculateProperties();\n }\n }\n\n function doAdjustAfterFetch(rid) {\n const updates = processUpdates();\n\n viewport.onAfterPrepend(updates);\n\n if (isInvalid(rid)) {\n return;\n }\n\n updatePaddings(rid, updates);\n onRenderHandlersRunner();\n enqueueFetch(rid, updates);\n pending.shift();\n\n if (pending.length)\n fetch(rid);\n else {\n adapter.loading(false);\n bindEvents();\n adapter.calculateProperties();\n }\n }\n\n function fetch(rid) {\n if (pending[0]) {// scrolling down\n if (buffer.length && !viewport.shouldLoadBottom()) {\n doAdjustAfterFetch(rid);\n } else {\n fetchNext((result) => {\n if (isInvalid(rid)) {\n return;\n }\n\n if (result.length < bufferSize) {\n buffer.eof = true;\n }\n\n if (result.length > 0) {\n viewport.clipTop();\n buffer.append(result);\n }\n\n doAdjustAfterFetch(rid);\n });\n }\n } else { // scrolling up\n if (buffer.length && !viewport.shouldLoadTop()) {\n doAdjustAfterFetch(rid);\n } else {\n fetchPrevious((result) => {\n if (isInvalid(rid)) {\n return;\n }\n\n if (result.length < bufferSize) {\n buffer.bof = true;\n // log 'bof is reached'\n }\n\n if (result.length > 0) {\n if (buffer.length) {\n viewport.clipBottom();\n }\n buffer.prepend(result);\n }\n\n doAdjustAfterFetch(rid);\n });\n }\n }\n }\n\n function resizeAndScrollHandler() {\n if (!$rootScope.$$phase && !adapter.isLoading && !adapter.disabled) {\n\n enqueueFetch(ridActual);\n\n if (pending.length) {\n unbindEvents();\n } else {\n adapter.calculateProperties();\n !$scope.$$phase && $scope.$digest();\n }\n }\n }\n\n function wheelHandler(event) {\n if (!adapter.disabled) {\n const scrollTop = viewport[0].scrollTop;\n const yMax = viewport[0].scrollHeight - viewport[0].clientHeight;\n\n if ((scrollTop === 0 && !buffer.bof) || (scrollTop === yMax && !buffer.eof)) {\n event.preventDefault();\n }\n }\n }\n }\n\n }\n ]);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/modules/jqLiteExtras.js","webpack:///./src/modules/elementRoutines.js","webpack:///./src/modules/buffer.js","webpack:///./src/modules/padding.js","webpack:///./src/modules/viewport.js","webpack:///./src/modules/adapter.js","webpack:///./src/ui-scroll.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","JQLiteExtras","element","convertToPx","css","getStyle","isWindow","scrollTo","self","direction","elem","_top$left$direction","_slicedToArray","top","left","method","prop","preserve","isValueDefined","document","documentElement","getWidthHeight","measure","result","measurements","base","borderA","borderB","computedMarginA","computedMarginB","computedStyle","dirA","dirB","paddingA","paddingB","height","width","padding","border","margin","_width$height$measure","offsetWidth","offsetHeight","getMeasurements","outer","outerfull","style","parseFloat","angular","this","nodeType","obj","location","alert","setInterval","window","getComputedStyle","currentStyle","rs","rsLeft","RegExp","source","test","runtimeStyle","pixelLeft","forEach","before","newElem","children","j","parent","ref","contents","prepend","length","after","Error","outerHTML","isNumber","outerHeight","option","outerWidth","offset","docElem","win","box","doc","ownerDocument","arguments","undefined","getBoundingClientRect","defaultView","parentWindow","pageYOffset","scrollTop","clientTop","pageXOffset","scrollLeft","clientLeft","hideClassToken","ElementRoutines","$injector","$q","elementRoutines_classCallCheck","$animate","has","isAngularVersionLessThen1_3","version","major","minor","index","selector","rules","sheet","styleSheets","cssRules","err","insertRule","addRule","wrapper","addClass","removeClass","newElement","previousElement","remove","scope","$destroy","insertElement","deferred","defer","enter","resolve","promise","removeElement","leave","then","ScrollBuffer","elementRoutines","bufferSize","startIndex","buffer","Array","extend","size","reset","eof","bof","first","next","minIndex","maxIndex","minIndexUser","maxIndexUser","append","items","item","insert","Math","max","reverse","min","operation","isTop","op","splice","push","unshift","arg1","arg2","indexOf","_op","getAbsMinIndex","incrementMinIndex","decrementMaxIndex","removeElementAnimated","getAbsMaxIndex","effectiveHeight","elements","Number","MAX_VALUE","bottom","NEGATIVE_INFINITY","offsetParent","CacheProto","$index","sort","a","b","argument","_isTop","Cache","instance","apply","setPrototypeOf","getOwnPropertyNames","methodName","Padding","template","padding_classCallCheck","Node","ELEMENT_NODE","tagName","toLowerCase","concat","find","generateElement","cache","Viewport","viewportController","$rootScope","topPadding","bottomPadding","viewport","container","bufferPadding","overflow-anchor","overflow-y","display","getScope","createPaddingElements","applyContainerStyle","bottomDataPos","scrollHeight","topDataPos","bottomVisiblePos","topVisiblePos","e","sibling","insertElementAnimated","shouldLoadBottom","clipBottom","overage","overageHeight","itemHeight","emptySpaceHeight","add","adjustPaddings","shouldLoadTop","clipTop","visibleItemsHeight","reduce","summ","topPaddingHeight","topCount","bottomPaddingHeight","bottomCount","averageItemHeight","adjustTopPadding","adjustBottomPadding","topPaddingHeightAdd","bottomPaddingHeightAdd","onAfterMinIndexSet","topPaddingHeightOld","diff","onAfterPrepend","updates","prepended","paddingHeight","resetTopPadding","clear","resetBottomPadding","removeCacheItem","removeItem","Adapter","$scope","$parse","$attr","doAdjust","reload","adapter_classCallCheck","isLoading","disabled","viewportScope","startScope","$parent","publicContext","assignAdapter","adapter","generatePublicContext","adapterAttr","replace","adapterOnScope","assign","error","message","_this","publicMethods","publicProps","_loop","attr","set","newItems","applyUpdatesFunc","applyUpdatesIndex","cb","_this2","slice","applyUpdate","_index","isArray","_this3","position","some","newItem","rowTop","topHeight","topDone","bottomDone","itemTop","isEOF","constant","run","elt","jQuery","fn","jquery","registerFor","addCSSRules","directive","restrict","controller","child","console","$timeout","$interval","require","transclude","priority","terminal","link","controllers","linker","match","uiScroll","parseNumber","defaultValue","isFloat","floor","isNaN","parseNumericAttr","datasource","itemName","datasourceName","ridActual","pending","persistDatasourceIndex","isDatasourceValid","toString","onRenderHandlers","propName","filter","handler","id","defineDatasourceIndex","propUserName","descriptor","getOwnPropertyDescriptor","fetchNext","success","count","fetchPrevious","isInvalid","rid","$$destroyed","unbindEvents","unbind","resizeAndScrollHandler","isElementVisible","insertWrapperContent","insertAfter","createElement","unregisterVisibilityWatcher","$watch","hideElement","promises","clone","transform","tdInitializer","uiScrollTdInitializer","linking","onLink","updatePaddings","animated","all","enqueueFetch","inserted","loading","fetch","processUpdates","toBePrepended","toBeRemoved","removed","updateDOM","$$phase","$digest","w","showElement","calculateProperties","doAdjustAfterFetch","shift","wheelHand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S0B,UACTlG,EAAOa,OAAOlI,IAGhBuX,EAAmBpC,MAInB9N,EAAOlE,SAAW0I,EAASyB,gBAC7BiK,EAAmBpC,GAEnBF,EAAc,SAACjV,GACTkV,EAAUC,KAIVnV,EAAOmD,OAASgE,IAClBE,EAAOM,KAAM,GAIK,EAAhB3H,EAAOmD,SACLkE,EAAOlE,QACT0I,EAASkB,aAEX1F,EAAOnE,QAAQlD,IAGjBuX,EAAmBpC,MAM3B,SAASI,IACF7J,EAAWwL,SAAYpH,EAAQP,WAAcO,EAAQN,WAExDiH,EAAazC,GAETC,EAAQ9Q,OACVkS,KAEAvF,EAAQwH,uBACPrI,EAAOiI,SAAWjI,EAAOkI,YAKhC,SAASM,EAAaC,GACpB,IAAK5H,EAAQN,SAAU,CACrB,IAAMjL,EAAYsH,EAAS,GAAGtH,UACxBoT,EAAO9L,EAAS,GAAGU,aAAeV,EAAS,GAAG+L,cAEjC,IAAdrT,IAAoB8C,EAAOM,KAASpD,IAAcoT,IAAStQ,EAAOK,MACrEgQ,EAAMG,kBA1SZzE,EAAO,SAAC4C,EAAO1P,GACbuF,EAASO,sBAAsB4J,EAAM,IAIrC1P,EAAMC,WACNyP,EAAM3P,WAGR4I,EAAO6I,IAAI,WAAY,WACrBzC,IACAxJ,EAASyJ,OAAO,aAAcmC,KAGhC5L,EAAS3N,KAAK,aAAcuZ,GAzCT,WACjB,IAAIM,EAAW,EACf,GAAIlM,EAASQ,sBAcX+C,SAbA,IAAM4I,EAAQnF,EAAU,WAMtB,GALAkF,IACGlM,EAASQ,wBACVwG,EAAUoF,OAAOD,GACjB5I,KA5GmB,KACO,GA6GzB2I,EAED,MADAlF,EAAUoF,OAAOD,GACX3U,MAAK,mEAAA+H,OAhHQ,IAgHR,QA/Ge,IA+IlC8M","file":"ui-scroll.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","/*!\r\n globals: angular, window\r\n List of used element methods available in JQuery but not in JQuery Lite\r\n element.before(elem)\r\n element.height()\r\n element.outerHeight(true)\r\n element.height(value) = only for Top/Bottom padding elements\r\n element.scrollTop()\r\n element.scrollTop(value)\r\n */\r\n\r\nexport default class JQLiteExtras {\r\n\r\n registerFor(element) {\r\n let convertToPx, css, getStyle, isWindow;\r\n // angular implementation blows up if elem is the window\r\n css = angular.element.prototype.css;\r\n\r\n element.prototype.css = function (name, value) {\r\n let self = this;\r\n let elem = self[0];\r\n if (!(!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style)) {\r\n return css.call(self, name, value);\r\n }\r\n };\r\n\r\n // as defined in angularjs v1.0.5\r\n isWindow = (obj) => obj && obj.document && obj.location && obj.alert && obj.setInterval;\r\n\r\n function scrollTo(self, direction, value) {\r\n let elem = self[0];\r\n let [method, prop, preserve] = {\r\n top: [\r\n 'scrollTop',\r\n 'pageYOffset',\r\n 'scrollLeft'\r\n ],\r\n left: [\r\n 'scrollLeft',\r\n 'pageXOffset',\r\n 'scrollTop'\r\n ]\r\n }[direction];\r\n\r\n const isValueDefined = typeof value !== 'undefined';\r\n if (isWindow(elem)) {\r\n if (isValueDefined) {\r\n return elem.scrollTo(self[preserve].call(self), value);\r\n }\r\n return (prop in elem) ? elem[prop] : elem.document.documentElement[method];\r\n } else {\r\n if (isValueDefined) {\r\n elem[method] = value;\r\n }\r\n return elem[method];\r\n }\r\n }\r\n\r\n if (window.getComputedStyle) {\r\n getStyle = (elem) => window.getComputedStyle(elem, null);\r\n convertToPx = (elem, value) => parseFloat(value);\r\n } else {\r\n getStyle = (elem) => elem.currentStyle;\r\n convertToPx = (elem, value) => {\r\n let left, result, rs, rsLeft, style;\r\n let core_pnum = /[+-]?(?:\\d*\\.|)\\d+(?:[eE][+-]?\\d+|)/.source;\r\n let rnumnonpx = new RegExp('^(' + core_pnum + ')(?!px)[a-z%]+$', 'i');\r\n\r\n if (!rnumnonpx.test(value)) {\r\n return parseFloat(value);\r\n }\r\n\r\n // ported from JQuery\r\n style = elem.style;\r\n left = style.left;\r\n rs = elem.runtimeStyle;\r\n rsLeft = rs && rs.left;\r\n if (rs) {\r\n rs.left = style.left;\r\n }\r\n // put in the new values to get a computed style out\r\n style.left = value;\r\n result = style.pixelLeft;\r\n style.left = left;\r\n if (rsLeft) {\r\n rs.left = rsLeft;\r\n }\r\n return result;\r\n };\r\n }\r\n\r\n function getMeasurements(elem, measure) {\r\n let base, borderA, borderB, computedMarginA, computedMarginB, computedStyle, dirA, dirB, marginA, marginB, paddingA, paddingB;\r\n\r\n if (isWindow(elem)) {\r\n base = document.documentElement[{height: 'clientHeight', width: 'clientWidth'}[measure]];\r\n\r\n return {\r\n base: base,\r\n padding: 0,\r\n border: 0,\r\n margin: 0\r\n };\r\n }\r\n\r\n // Start with offset property\r\n [\r\n base,\r\n dirA,\r\n dirB\r\n ] = {\r\n width: [\r\n elem.offsetWidth,\r\n 'Left',\r\n 'Right'\r\n ],\r\n height: [\r\n elem.offsetHeight,\r\n 'Top',\r\n 'Bottom'\r\n ]\r\n }[measure];\r\n\r\n computedStyle = getStyle(elem);\r\n paddingA = convertToPx(elem, computedStyle['padding' + dirA]) || 0;\r\n paddingB = convertToPx(elem, computedStyle['padding' + dirB]) || 0;\r\n borderA = convertToPx(elem, computedStyle['border' + dirA + 'Width']) || 0;\r\n borderB = convertToPx(elem, computedStyle['border' + dirB + 'Width']) || 0;\r\n computedMarginA = computedStyle['margin' + dirA];\r\n computedMarginB = computedStyle['margin' + dirB];\r\n\r\n // I do not care for width for now, so this hack is irrelevant\r\n // if ( !supportsPercentMargin )\r\n // computedMarginA = hackPercentMargin( elem, computedStyle, computedMarginA )\r\n // computedMarginB = hackPercentMargin( elem, computedStyle, computedMarginB )\r\n marginA = convertToPx(elem, computedMarginA) || 0;\r\n marginB = convertToPx(elem, computedMarginB) || 0;\r\n\r\n return {\r\n base: base,\r\n padding: paddingA + paddingB,\r\n border: borderA + borderB,\r\n margin: marginA + marginB\r\n };\r\n }\r\n\r\n function getWidthHeight(elem, direction, measure) {\r\n let computedStyle, result;\r\n\r\n let measurements = getMeasurements(elem, direction);\r\n\r\n if (measurements.base > 0) {\r\n return {\r\n base: measurements.base - measurements.padding - measurements.border,\r\n outer: measurements.base,\r\n outerfull: measurements.base + measurements.margin\r\n }[measure];\r\n }\r\n\r\n // Fall back to computed then uncomputed css if necessary\r\n computedStyle = getStyle(elem);\r\n result = computedStyle[direction];\r\n\r\n if (result < 0 || result === null) {\r\n result = elem.style[direction] || 0;\r\n }\r\n\r\n // Normalize \"\", auto, and prepare for extra\r\n result = parseFloat(result) || 0;\r\n\r\n return {\r\n base: result - measurements.padding - measurements.border,\r\n outer: result,\r\n outerfull: result + measurements.padding + measurements.border + measurements.margin\r\n }[measure];\r\n }\r\n\r\n // define missing methods\r\n return angular.forEach({\r\n before(newElem) {\r\n var children, elem, i, j, parent, ref, self;\r\n self = this;\r\n elem = self[0];\r\n parent = self.parent();\r\n children = parent.contents();\r\n if (children[0] === elem) {\r\n return parent.prepend(newElem);\r\n } else {\r\n for (i = j = 1, ref = children.length - 1; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {\r\n if (children[i] === elem) {\r\n angular.element(children[i - 1]).after(newElem);\r\n return;\r\n }\r\n }\r\n throw new Error('invalid DOM structure ' + elem.outerHTML);\r\n }\r\n },\r\n height (value){\r\n var self;\r\n self = this;\r\n if (typeof value !== 'undefined') {\r\n if (angular.isNumber(value)) {\r\n value = value + 'px';\r\n }\r\n return css.call(self, 'height', value);\r\n } else {\r\n return getWidthHeight(this[0], 'height', 'base');\r\n }\r\n },\r\n outerHeight(option) {\r\n return getWidthHeight(this[0], 'height', option ? 'outerfull' : 'outer');\r\n },\r\n outerWidth(option) {\r\n return getWidthHeight(this[0], 'width', option ? 'outerfull' : 'outer');\r\n },\r\n\r\n /*\r\n The offset setter method is not implemented\r\n */\r\n offset(value) {\r\n let docElem, win;\r\n let self = this;\r\n let box = {\r\n top: 0,\r\n left: 0\r\n };\r\n let elem = self[0];\r\n let doc = elem && elem.ownerDocument;\r\n\r\n if (arguments.length) {\r\n if (value === undefined) {\r\n return self;\r\n }\r\n // TODO: implement setter\r\n throw new Error('offset setter method is not implemented');\r\n }\r\n\r\n if (!doc) {\r\n return;\r\n }\r\n\r\n docElem = doc.documentElement;\r\n\r\n // TODO: Make sure it's not a disconnected DOM node\r\n\r\n if (elem.getBoundingClientRect != null) {\r\n box = elem.getBoundingClientRect();\r\n }\r\n\r\n win = doc.defaultView || doc.parentWindow;\r\n\r\n return {\r\n top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),\r\n left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)\r\n };\r\n },\r\n scrollTop(value) {\r\n return scrollTo(this, 'top', value);\r\n },\r\n scrollLeft(value) {\r\n return scrollTo(this, 'left', value);\r\n }\r\n }, (value, key) => {\r\n if (!element.prototype[key]) {\r\n return element.prototype[key] = value;\r\n }\r\n });\r\n }\r\n\r\n}\r\n","const hideClassToken = 'ng-ui-scroll-hide';\r\n\r\nexport default class ElementRoutines {\r\n\r\n static addCSSRules() {\r\n const selector = '.' + hideClassToken;\r\n const rules = 'display: none';\r\n const sheet = document.styleSheets[0];\r\n let index;\r\n try {\r\n index = sheet.cssRules.length;\r\n } catch (err) {\r\n index = 0;\r\n }\r\n if('insertRule' in sheet) {\r\n sheet.insertRule(selector + '{' + rules + '}', index);\r\n }\r\n else if('addRule' in sheet) {\r\n sheet.addRule(selector, rules, index);\r\n }\r\n }\r\n\r\n constructor($injector, $q) {\r\n this.$animate = ($injector.has && $injector.has('$animate')) ? $injector.get('$animate') : null;\r\n this.isAngularVersionLessThen1_3 = angular.version.major === 1 && angular.version.minor < 3;\r\n this.$q = $q;\r\n }\r\n\r\n hideElement(wrapper) {\r\n wrapper.element.addClass(hideClassToken);\r\n }\r\n\r\n showElement(wrapper) {\r\n wrapper.element.removeClass(hideClassToken);\r\n }\r\n\r\n insertElement(newElement, previousElement) {\r\n previousElement.after(newElement);\r\n return [];\r\n }\r\n\r\n removeElement(wrapper) {\r\n wrapper.element.remove();\r\n wrapper.scope.$destroy();\r\n return [];\r\n }\r\n\r\n insertElementAnimated(newElement, previousElement) {\r\n if (!this.$animate) {\r\n return this.insertElement(newElement, previousElement);\r\n }\r\n\r\n if (this.isAngularVersionLessThen1_3) {\r\n const deferred = this.$q.defer();\r\n // no need for parent - previous element is never null\r\n this.$animate.enter(newElement, null, previousElement, () => deferred.resolve());\r\n\r\n return [deferred.promise];\r\n }\r\n\r\n // no need for parent - previous element is never null\r\n return [this.$animate.enter(newElement, null, previousElement)];\r\n }\r\n\r\n removeElementAnimated(wrapper) {\r\n if (!this.$animate) {\r\n return this.removeElement(wrapper);\r\n }\r\n\r\n if (this.isAngularVersionLessThen1_3) {\r\n const deferred = this.$q.defer();\r\n this.$animate.leave(wrapper.element, () => {\r\n wrapper.scope.$destroy();\r\n return deferred.resolve();\r\n });\r\n\r\n return [deferred.promise];\r\n }\r\n\r\n return [(this.$animate.leave(wrapper.element)).then(() => wrapper.scope.$destroy())];\r\n }\r\n}","export default function ScrollBuffer(elementRoutines, bufferSize, startIndex) {\r\n const buffer = Object.create(Array.prototype);\r\n\r\n angular.extend(buffer, {\r\n size: bufferSize,\r\n\r\n reset(startIndex) {\r\n buffer.remove(0, buffer.length);\r\n buffer.eof = false;\r\n buffer.bof = false;\r\n buffer.first = startIndex;\r\n buffer.next = startIndex;\r\n buffer.minIndex = startIndex;\r\n buffer.maxIndex = startIndex;\r\n buffer.minIndexUser = null;\r\n buffer.maxIndexUser = null;\r\n },\r\n\r\n append(items) {\r\n items.forEach((item) => {\r\n ++buffer.next;\r\n buffer.insert('append', item);\r\n });\r\n buffer.maxIndex = buffer.eof ? buffer.next - 1 : Math.max(buffer.next - 1, buffer.maxIndex);\r\n },\r\n\r\n prepend(items) {\r\n items.reverse().forEach((item) => {\r\n --buffer.first;\r\n buffer.insert('prepend', item);\r\n });\r\n buffer.minIndex = buffer.bof ? buffer.minIndex = buffer.first : Math.min(buffer.first, buffer.minIndex);\r\n },\r\n\r\n /**\r\n * inserts wrapped element in the buffer\r\n * the first argument is either operation keyword (see below) or a number for operation 'insert'\r\n * for insert the number is the index for the buffer element the new one have to be inserted after\r\n * operations: 'append', 'prepend', 'insert', 'remove', 'update', 'none'\r\n */\r\n insert(operation, item, isTop) {\r\n const wrapper = {\r\n item: item\r\n };\r\n\r\n if (operation % 1 === 0) {// it is an insert\r\n wrapper.op = 'insert';\r\n buffer.splice(operation, 0, wrapper);\r\n if(isTop) {\r\n buffer.first--;\r\n }\r\n else {\r\n buffer.next++;\r\n }\r\n } else {\r\n wrapper.op = operation;\r\n switch (operation) {\r\n case 'append':\r\n buffer.push(wrapper);\r\n break;\r\n case 'prepend':\r\n buffer.unshift(wrapper);\r\n break;\r\n }\r\n }\r\n },\r\n\r\n // removes elements from buffer\r\n remove(arg1, arg2) {\r\n if (angular.isNumber(arg1)) {\r\n // removes items from arg1 (including) through arg2 (excluding)\r\n for (let i = arg1; i < arg2; i++) {\r\n elementRoutines.removeElement(buffer[i]);\r\n }\r\n return buffer.splice(arg1, arg2 - arg1);\r\n }\r\n // removes single item(wrapper) from the buffer\r\n buffer.splice(buffer.indexOf(arg1), 1);\r\n if(arg1._op === 'isTop' && buffer.first === this.getAbsMinIndex()) {\r\n this.incrementMinIndex();\r\n }\r\n else {\r\n this.decrementMaxIndex();\r\n }\r\n if(arg1._op === 'isTop') {\r\n buffer.first++;\r\n }\r\n else {\r\n buffer.next--;\r\n }\r\n if(!buffer.length) {\r\n buffer.first = 1;\r\n buffer.next = 1;\r\n }\r\n\r\n return elementRoutines.removeElementAnimated(arg1);\r\n },\r\n\r\n incrementMinIndex() {\r\n if(buffer.minIndexUser !== null) {\r\n if(buffer.minIndex > buffer.minIndexUser) {\r\n buffer.minIndexUser++;\r\n return;\r\n }\r\n if(buffer.minIndex === buffer.minIndexUser) {\r\n buffer.minIndexUser++;\r\n }\r\n }\r\n buffer.minIndex++;\r\n },\r\n\r\n decrementMaxIndex() {\r\n if(buffer.maxIndexUser !== null && buffer.maxIndex <= buffer.maxIndexUser) {\r\n buffer.maxIndexUser--;\r\n }\r\n buffer.maxIndex--;\r\n },\r\n\r\n getAbsMinIndex() {\r\n if(buffer.minIndexUser !== null) {\r\n return Math.min(buffer.minIndexUser, buffer.minIndex);\r\n }\r\n return buffer.minIndex;\r\n },\r\n\r\n getAbsMaxIndex() {\r\n if(buffer.maxIndexUser !== null) {\r\n return Math.max(buffer.maxIndexUser, buffer.maxIndex);\r\n }\r\n return buffer.maxIndex;\r\n },\r\n\r\n effectiveHeight(elements) {\r\n if (!elements.length) {\r\n return 0;\r\n }\r\n let top = Number.MAX_VALUE;\r\n let bottom = Number.NEGATIVE_INFINITY;\r\n elements.forEach((wrapper) => {\r\n if (wrapper.element[0].offsetParent) {\r\n // element style is not display:none\r\n top = Math.min(top, wrapper.element.offset().top);\r\n bottom = Math.max(bottom, wrapper.element.offset().top + wrapper.element.outerHeight(true));\r\n }\r\n });\r\n return Math.max(0, bottom - top);\r\n }\r\n\r\n });\r\n\r\n buffer.reset(startIndex);\r\n\r\n return buffer;\r\n}\r\n","// Can't just extend the Array, due to Babel does not support built-in classes extending\r\n// This solution was taken from https://stackoverflow.com/questions/46897414/es6-class-extends-array-workaround-for-es5-babel-transpile\r\nclass CacheProto {\r\n add(item) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index === item.scope.$index) {\r\n this[i].height = item.element.outerHeight();\r\n return;\r\n }\r\n }\r\n this.push({\r\n index: item.scope.$index,\r\n height: item.element.outerHeight()\r\n });\r\n this.sort((a, b) => ((a.index < b.index) ? -1 : ((a.index > b.index) ? 1 : 0)));\r\n }\r\n\r\n remove(argument, _isTop) {\r\n const index = argument % 1 === 0 ? argument : argument.scope.$index;\r\n const isTop = argument % 1 === 0 ? _isTop : argument._op === 'isTop';\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index === index) {\r\n this.splice(i, 1);\r\n break;\r\n }\r\n }\r\n if(!isTop) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n if (this[i].index > index) {\r\n this[i].index--;\r\n }\r\n }\r\n }\r\n }\r\n\r\n clear() {\r\n this.length = 0;\r\n }\r\n}\r\n\r\nfunction Cache() {\r\n const instance = [];\r\n instance.push.apply(instance, arguments);\r\n Object.setPrototypeOf(instance, Cache.prototype);\r\n return instance;\r\n}\r\nCache.prototype = Object.create(Array.prototype);\r\nObject.getOwnPropertyNames(CacheProto.prototype).forEach(methodName =>\r\n Cache.prototype[methodName] = CacheProto.prototype[methodName]\r\n);\r\n\r\nfunction generateElement(template) {\r\n if(template.nodeType !== Node.ELEMENT_NODE) {\r\n throw new Error('ui-scroll directive requires an Element node for templating the view');\r\n }\r\n let element;\r\n switch (template.tagName.toLowerCase()) {\r\n case 'dl':\r\n throw new Error(`ui-scroll directive does not support <${template.tagName}> as a repeating tag: ${template.outerHTML}`);\r\n case 'tr':\r\n let table = angular.element('
    ');\r\n element = table.find('tr');\r\n break;\r\n case 'li':\r\n element = angular.element('
  • ');\r\n break;\r\n default:\r\n element = angular.element('
    ');\r\n }\r\n return element;\r\n}\r\n\r\nclass Padding {\r\n constructor(template) {\r\n this.element = generateElement(template);\r\n this.cache = new Cache();\r\n }\r\n\r\n height() {\r\n return this.element.height.apply(this.element, arguments);\r\n }\r\n}\r\n\r\nexport default Padding;","import Padding from './padding';\r\n\r\nexport default function Viewport(elementRoutines, buffer, element, viewportController, $rootScope, padding) {\r\n let topPadding = null;\r\n let bottomPadding = null;\r\n const viewport = viewportController && viewportController.viewport ? viewportController.viewport : angular.element(window);\r\n const container = viewportController && viewportController.container ? viewportController.container : undefined;\r\n const scope = viewportController && viewportController.scope ? viewportController.scope : $rootScope;\r\n\r\n viewport.css({\r\n 'overflow-anchor': 'none',\r\n 'overflow-y': 'auto',\r\n 'display': 'block'\r\n });\r\n\r\n function bufferPadding() {\r\n return viewport.outerHeight() * padding; // some extra space to initiate preload\r\n }\r\n\r\n angular.extend(viewport, {\r\n getScope() {\r\n return scope;\r\n },\r\n\r\n createPaddingElements(template) {\r\n topPadding = new Padding(template);\r\n bottomPadding = new Padding(template);\r\n element.before(topPadding.element);\r\n element.after(bottomPadding.element);\r\n topPadding.height(0);\r\n bottomPadding.height(0);\r\n },\r\n\r\n applyContainerStyle() {\r\n if (!container) {\r\n return true;\r\n }\r\n if(container !== viewport) {\r\n viewport.css('height', window.getComputedStyle(container[0]).height);\r\n }\r\n return viewport.height() > 0;\r\n },\r\n\r\n bottomDataPos() {\r\n let scrollHeight = viewport[0].scrollHeight;\r\n scrollHeight = scrollHeight != null ? scrollHeight : viewport[0].document.documentElement.scrollHeight;\r\n return scrollHeight - bottomPadding.height();\r\n },\r\n\r\n topDataPos() {\r\n return topPadding.height();\r\n },\r\n\r\n bottomVisiblePos() {\r\n return viewport.scrollTop() + viewport.outerHeight();\r\n },\r\n\r\n topVisiblePos() {\r\n return viewport.scrollTop();\r\n },\r\n\r\n insertElement(e, sibling) {\r\n return elementRoutines.insertElement(e, sibling || topPadding.element);\r\n },\r\n\r\n insertElementAnimated(e, sibling) {\r\n return elementRoutines.insertElementAnimated(e, sibling || topPadding.element);\r\n },\r\n\r\n shouldLoadBottom() {\r\n return !buffer.eof && viewport.bottomDataPos() < viewport.bottomVisiblePos() + bufferPadding();\r\n },\r\n\r\n clipBottom() {\r\n // clip the invisible items off the bottom\r\n let overage = 0;\r\n let overageHeight = 0;\r\n let itemHeight = 0;\r\n let emptySpaceHeight = viewport.bottomDataPos() - viewport.bottomVisiblePos() - bufferPadding();\r\n\r\n for (let i = buffer.length - 1; i >= 0; i--) {\r\n itemHeight = buffer[i].element.outerHeight(true);\r\n if (overageHeight + itemHeight > emptySpaceHeight) {\r\n break;\r\n }\r\n bottomPadding.cache.add(buffer[i]);\r\n overageHeight += itemHeight;\r\n overage++;\r\n }\r\n\r\n if (overage > 0) {\r\n buffer.eof = false;\r\n buffer.remove(buffer.length - overage, buffer.length);\r\n buffer.next -= overage;\r\n viewport.adjustPaddings();\r\n }\r\n },\r\n\r\n shouldLoadTop() {\r\n return !buffer.bof && (viewport.topDataPos() > viewport.topVisiblePos() - bufferPadding());\r\n },\r\n\r\n clipTop() {\r\n // clip the invisible items off the top\r\n let overage = 0;\r\n let overageHeight = 0;\r\n let itemHeight = 0;\r\n let emptySpaceHeight = viewport.topVisiblePos() - viewport.topDataPos() - bufferPadding();\r\n\r\n for (let i = 0; i < buffer.length; i++) {\r\n itemHeight = buffer[i].element.outerHeight(true);\r\n if (overageHeight + itemHeight > emptySpaceHeight) {\r\n break;\r\n }\r\n topPadding.cache.add(buffer[i]);\r\n overageHeight += itemHeight;\r\n overage++;\r\n }\r\n\r\n if (overage > 0) {\r\n // we need to adjust top padding element before items are removed from top\r\n // to avoid strange behaviour of scroll bar during remove top items when we are at the very bottom\r\n topPadding.height(topPadding.height() + overageHeight);\r\n buffer.bof = false;\r\n buffer.remove(0, overage);\r\n buffer.first += overage;\r\n }\r\n },\r\n\r\n adjustPaddings() {\r\n if (!buffer.length) {\r\n return;\r\n }\r\n\r\n // precise heights calculation based on items that are in buffer or that were in buffer once\r\n const visibleItemsHeight = buffer.reduce((summ, item) => summ + item.element.outerHeight(true), 0);\r\n\r\n let topPaddingHeight = 0, topCount = 0;\r\n topPadding.cache.forEach(item => {\r\n if(item.index < buffer.first) {\r\n topPaddingHeight += item.height;\r\n topCount++;\r\n }\r\n });\r\n\r\n let bottomPaddingHeight = 0, bottomCount = 0;\r\n bottomPadding.cache.forEach(item => {\r\n if(item.index >= buffer.next) {\r\n bottomPaddingHeight += item.height;\r\n bottomCount++;\r\n }\r\n });\r\n\r\n const totalHeight = visibleItemsHeight + topPaddingHeight + bottomPaddingHeight;\r\n const averageItemHeight = totalHeight / (topCount + bottomCount + buffer.length);\r\n\r\n // average heights calculation, items that have never been reached\r\n let adjustTopPadding = buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser;\r\n let adjustBottomPadding = buffer.maxIndexUser !== null && buffer.maxIndex < buffer.maxIndexUser;\r\n let topPaddingHeightAdd = adjustTopPadding ? (buffer.minIndex - buffer.minIndexUser) * averageItemHeight : 0;\r\n let bottomPaddingHeightAdd = adjustBottomPadding ? (buffer.maxIndexUser - buffer.maxIndex) * averageItemHeight : 0;\r\n\r\n // paddings combine adjustment\r\n topPadding.height(topPaddingHeight + topPaddingHeightAdd);\r\n bottomPadding.height(bottomPaddingHeight + bottomPaddingHeightAdd);\r\n },\r\n\r\n onAfterMinIndexSet(topPaddingHeightOld) {\r\n // additional scrollTop adjustment in case of datasource.minIndex external set\r\n if (buffer.minIndexUser !== null && buffer.minIndex > buffer.minIndexUser) {\r\n let diff = topPadding.height() - topPaddingHeightOld;\r\n viewport.scrollTop(viewport.scrollTop() + diff);\r\n while((diff -= viewport.scrollTop()) > 0) {\r\n bottomPadding.height(bottomPadding.height() + diff);\r\n viewport.scrollTop(viewport.scrollTop() + diff);\r\n }\r\n }\r\n },\r\n\r\n onAfterPrepend(updates) {\r\n if (!updates.prepended.length)\r\n return;\r\n const height = buffer.effectiveHeight(updates.prepended);\r\n const paddingHeight = topPadding.height() - height;\r\n if (paddingHeight >= 0) {\r\n topPadding.height(paddingHeight);\r\n }\r\n else {\r\n topPadding.height(0);\r\n viewport.scrollTop(viewport.scrollTop() - paddingHeight);\r\n }\r\n },\r\n\r\n resetTopPadding() {\r\n topPadding.height(0);\r\n topPadding.cache.clear();\r\n },\r\n\r\n resetBottomPadding() {\r\n bottomPadding.height(0);\r\n bottomPadding.cache.clear();\r\n },\r\n\r\n removeCacheItem(item, isTop) {\r\n topPadding.cache.remove(item, isTop);\r\n bottomPadding.cache.remove(item, isTop);\r\n },\r\n\r\n removeItem(item) {\r\n this.removeCacheItem(item);\r\n return buffer.remove(item);\r\n }\r\n });\r\n\r\n return viewport;\r\n}\r\n","class Adapter {\r\n\r\n constructor($scope, $parse, $attr, viewport, buffer, doAdjust, reload) {\r\n this.$parse = $parse;\r\n this.$attr = $attr;\r\n this.viewport = viewport;\r\n this.buffer = buffer;\r\n\r\n this.doAdjust = doAdjust;\r\n this.reload = reload;\r\n\r\n this.isLoading = false;\r\n this.disabled = false;\r\n\r\n const viewportScope = viewport.getScope();\r\n this.startScope = viewportScope.$parent ? viewportScope : $scope;\r\n\r\n this.publicContext = {};\r\n this.assignAdapter($attr.adapter);\r\n this.generatePublicContext();\r\n }\r\n\r\n assignAdapter(adapterAttr) {\r\n if (!adapterAttr || !(adapterAttr = adapterAttr.replace(/^\\s+|\\s+$/gm, ''))) {\r\n return;\r\n }\r\n let adapterOnScope;\r\n\r\n try {\r\n this.$parse(adapterAttr).assign(this.startScope, {});\r\n adapterOnScope = this.$parse(adapterAttr)(this.startScope);\r\n }\r\n catch (error) {\r\n error.message = `Angular ui-scroll Adapter assignment exception.\\n` +\r\n `Can't parse \"${adapterAttr}\" expression.\\n` +\r\n error.message;\r\n throw error;\r\n }\r\n\r\n angular.extend(adapterOnScope, this.publicContext);\r\n this.publicContext = adapterOnScope;\r\n }\r\n\r\n generatePublicContext() {\r\n // these methods will be accessible out of ui-scroll via user defined adapter\r\n const publicMethods = ['reload', 'applyUpdates', 'append', 'prepend', 'isBOF', 'isEOF', 'isEmpty'];\r\n for (let i = publicMethods.length - 1; i >= 0; i--) {\r\n this.publicContext[publicMethods[i]] = this[publicMethods[i]].bind(this);\r\n }\r\n\r\n // these read-only props will be accessible out of ui-scroll via user defined adapter\r\n const publicProps = ['isLoading', 'topVisible', 'topVisibleElement', 'topVisibleScope', 'bottomVisible', 'bottomVisibleElement', 'bottomVisibleScope'];\r\n for (let i = publicProps.length - 1; i >= 0; i--) {\r\n let property, attr = this.$attr[publicProps[i]];\r\n Object.defineProperty(this, publicProps[i], {\r\n get: () => property,\r\n set: (value) => {\r\n property = value;\r\n this.publicContext[publicProps[i]] = value;\r\n if (attr) {\r\n this.$parse(attr).assign(this.startScope, value);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // non-read-only public property\r\n Object.defineProperty(this.publicContext, 'disabled', {\r\n get: () => this.disabled,\r\n set: (value) => (!(this.disabled = value)) ? this.doAdjust() : null\r\n });\r\n }\r\n\r\n loading(value) {\r\n this.isLoading = value;\r\n }\r\n\r\n isBOF() {\r\n return this.buffer.bof;\r\n }\r\n\r\n isEOF() {\r\n return this.buffer.eof;\r\n }\r\n\r\n isEmpty() {\r\n return !this.buffer.length;\r\n }\r\n\r\n append(newItems) {\r\n this.buffer.append(newItems);\r\n this.doAdjust();\r\n this.viewport.clipTop();\r\n this.viewport.clipBottom();\r\n }\r\n\r\n prepend(newItems) {\r\n this.buffer.prepend(newItems);\r\n this.doAdjust();\r\n this.viewport.clipTop();\r\n this.viewport.clipBottom();\r\n }\r\n\r\n applyUpdates(arg1, arg2) {\r\n if (typeof arg1 === 'function') {\r\n this.applyUpdatesFunc(arg1);\r\n } else {\r\n this.applyUpdatesIndex(arg1, arg2);\r\n }\r\n this.doAdjust();\r\n }\r\n\r\n applyUpdatesFunc(cb) {\r\n this.buffer.slice(0).forEach((wrapper) => {\r\n // we need to do it on the buffer clone, because buffer content\r\n // may change as we iterate through\r\n this.applyUpdate(wrapper, cb(wrapper.item, wrapper.scope, wrapper.element));\r\n });\r\n }\r\n\r\n applyUpdatesIndex(index, newItems) {\r\n if (index % 1 !== 0) {\r\n throw new Error('applyUpdates - ' + index + ' is not a valid index (should be an integer)');\r\n }\r\n const _index = index - this.buffer.first;\r\n\r\n // apply updates only within buffer\r\n if (_index >= 0 && _index < this.buffer.length) {\r\n this.applyUpdate(this.buffer[_index], newItems);\r\n }\r\n // out-of-buffer case: deletion may affect Paddings\r\n else if(index >= this.buffer.getAbsMinIndex() && index <= this.buffer.getAbsMaxIndex()) {\r\n if(angular.isArray(newItems) && !newItems.length) {\r\n this.viewport.removeCacheItem(index, index === this.buffer.minIndex);\r\n if(index === this.buffer.getAbsMinIndex()) {\r\n this.buffer.incrementMinIndex();\r\n }\r\n else {\r\n this.buffer.decrementMaxIndex();\r\n }\r\n }\r\n }\r\n }\r\n\r\n applyUpdate(wrapper, newItems) {\r\n if (!angular.isArray(newItems)) {\r\n return;\r\n }\r\n let position = this.buffer.indexOf(wrapper);\r\n if (!newItems.reverse().some(newItem => newItem === wrapper.item)) {\r\n wrapper.op = 'remove';\r\n if(position === 0 && !newItems.length) {\r\n wrapper._op = 'isTop'; // to catch \"first\" edge case on remove\r\n }\r\n }\r\n newItems.forEach((newItem) => {\r\n if (newItem === wrapper.item) {\r\n position--;\r\n } else {\r\n // 3 parameter (isTop) is to catch \"first\" edge case on insert\r\n this.buffer.insert(position + 1, newItem, position === -1);\r\n }\r\n });\r\n }\r\n\r\n calculateProperties() {\r\n let rowTop = null, topHeight = 0;\r\n let topDone = false, bottomDone = false;\r\n const length = this.buffer.length;\r\n\r\n for (let i = 0; i < length; i++) {\r\n const item = this.buffer[i];\r\n const itemTop = item.element.offset().top;\r\n\r\n if (rowTop !== itemTop) { // a new row condition\r\n const itemHeight = item.element.outerHeight(true);\r\n const top = this.viewport.topDataPos() + topHeight + itemHeight;\r\n\r\n if (!topDone && top > this.viewport.topVisiblePos()) {\r\n topDone = true;\r\n this['topVisible'] = item.item;\r\n this['topVisibleElement'] = item.element;\r\n this['topVisibleScope'] = item.scope;\r\n }\r\n if (!bottomDone && (top >= this.viewport.bottomVisiblePos() || (i === length - 1 && this.isEOF()))) {\r\n bottomDone = true;\r\n this['bottomVisible'] = item.item;\r\n this['bottomVisibleElement'] = item.element;\r\n this['bottomVisibleScope'] = item.scope;\r\n }\r\n topHeight += itemHeight;\r\n }\r\n rowTop = itemTop;\r\n\r\n if (topDone && bottomDone) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n}\r\n\r\nexport default Adapter;\r\n","import JQLiteExtras from './modules/jqLiteExtras';\nimport ElementRoutines from './modules/elementRoutines.js';\nimport ScrollBuffer from './modules/buffer.js';\nimport Viewport from './modules/viewport.js';\nimport Adapter from './modules/adapter.js';\n\nangular.module('ui.scroll', [])\n\n .constant('JQLiteExtras', JQLiteExtras)\n .run(['JQLiteExtras', (JQLiteExtras) => {\n const elt = angular.element;\n !(window.jQuery && elt.fn && elt.fn.jquery) ? (new JQLiteExtras()).registerFor(elt) : null;\n ElementRoutines.addCSSRules();\n }])\n\n .directive('uiScrollViewport', function () {\n return {\n restrict: 'A',\n controller: [\n '$scope',\n '$element',\n function (scope, element) {\n this.container = element;\n this.viewport = element;\n this.scope = scope;\n\n angular.forEach(element.children(), child => {\n if (child.tagName.toLowerCase() === 'tbody') {\n this.viewport = angular.element(child);\n }\n });\n\n return this;\n }\n ]\n };\n })\n\n .directive('uiScroll', [\n '$log',\n '$injector',\n '$rootScope',\n '$timeout',\n '$interval',\n '$q',\n '$parse',\n function (console, $injector, $rootScope, $timeout, $interval, $q, $parse) {\n\n return {\n require: ['?^uiScrollViewport'],\n restrict: 'A',\n transclude: 'element',\n priority: 1000,\n terminal: true,\n link: link\n };\n\n function link($scope, element, $attr, controllers, linker) {\n const match = $attr.uiScroll.match(/^\\s*(\\w+)\\s+in\\s+([(\\w|\\$)\\.]+)\\s*$/);\n if (!match) {\n throw new Error('Expected uiScroll in form of \\'_item_ in _datasource_\\' but got \\'' + $attr.uiScroll + '\\'');\n }\n\n function parseNumber(value, defaultValue, isFloat) {\n if (!isFloat) {\n value = value === null ? defaultValue : Math.floor(value);\n }\n return isNaN(value) ? defaultValue : value;\n }\n\n function parseNumericAttr(value, defaultValue, isFloat) {\n const result = $parse(value)($scope);\n return parseNumber(result, defaultValue, isFloat);\n }\n\n const BUFFER_MIN = 3;\n const BUFFER_DEFAULT = 10;\n const PADDING_MIN = 0.3;\n const PADDING_DEFAULT = 0.5;\n const START_INDEX_DEFAULT = 1;\n const MAX_VIEWPORT_DELAY = 500;\n const VIEWPORT_POLLING_INTERVAL = 50;\n\n let datasource = null;\n const itemName = match[1];\n const datasourceName = match[2];\n const viewportController = controllers[0];\n const bufferSize = Math.max(BUFFER_MIN, parseNumericAttr($attr.bufferSize, BUFFER_DEFAULT));\n const padding = Math.max(PADDING_MIN, parseNumericAttr($attr.padding, PADDING_DEFAULT, true));\n let startIndex = parseNumericAttr($attr.startIndex, START_INDEX_DEFAULT);\n let ridActual = 0; // current data revision id\n let pending = [];\n\n const elementRoutines = new ElementRoutines($injector, $q);\n const buffer = new ScrollBuffer(elementRoutines, bufferSize, startIndex);\n const viewport = new Viewport(elementRoutines, buffer, element, viewportController, $rootScope, padding);\n const adapter = new Adapter($scope, $parse, $attr, viewport, buffer, doAdjust, reload);\n\n if (viewportController) {\n viewportController.adapter = adapter;\n }\n\n const isDatasourceValid = () =>\n Object.prototype.toString.call(datasource) === '[object Object]' && typeof datasource.get === 'function';\n\n datasource = $parse(datasourceName)($scope); // try to get datasource on scope\n if (!isDatasourceValid()) {\n datasource = $injector.get(datasourceName); // try to inject datasource as service\n if (!isDatasourceValid()) {\n throw new Error(datasourceName + ' is not a valid datasource');\n }\n }\n\n let onRenderHandlers = [];\n function onRenderHandlersRunner() {\n onRenderHandlers.forEach(handler => handler.run());\n onRenderHandlers = [];\n }\n function persistDatasourceIndex(datasource, propName) {\n let getter;\n // need to postpone min/maxIndexUser processing if the view is empty\n if(angular.isNumber(datasource[propName])) {\n getter = datasource[propName];\n if(angular.isNumber(getter)) {\n onRenderHandlers = onRenderHandlers.filter(handler => handler.id !== propName);\n onRenderHandlers.push({\n id: propName,\n run: () => datasource[propName] = getter\n });\n }\n }\n }\n\n function defineDatasourceIndex(datasource, propName, propUserName) {\n const descriptor = Object.getOwnPropertyDescriptor(datasource, propName);\n if (descriptor && (descriptor.set || descriptor.get)) {\n return;\n }\n let getter;\n persistDatasourceIndex(datasource, propName);\n Object.defineProperty(datasource, propName, {\n set: (value) => {\n getter = value;\n if(pending.length && !buffer.length) {\n persistDatasourceIndex(datasource, propName);\n return;\n }\n buffer[propUserName] = value;\n const topPaddingHeightOld = viewport.topDataPos();\n viewport.adjustPaddings();\n if (propName === 'minIndex') {\n viewport.onAfterMinIndexSet(topPaddingHeightOld);\n }\n },\n get: () => getter\n });\n }\n\n defineDatasourceIndex(datasource, 'minIndex', 'minIndexUser');\n defineDatasourceIndex(datasource, 'maxIndex', 'maxIndexUser');\n\n const fetchNext = (datasource.get.length !== 2) ?\n (success) => datasource.get(buffer.next, bufferSize, success) :\n (success) => {\n datasource.get({\n index: buffer.next,\n append: buffer.length ? buffer[buffer.length - 1].item : void 0,\n count: bufferSize\n }, success);\n };\n\n const fetchPrevious = (datasource.get.length !== 2) ?\n (success) => datasource.get(buffer.first - bufferSize, bufferSize, success) :\n (success) => {\n datasource.get({\n index: buffer.first - bufferSize,\n prepend: buffer.length ? buffer[0].item : void 0,\n count: bufferSize\n }, success);\n };\n\n const initialize = () => {\n let tryCount = 0;\n if(!viewport.applyContainerStyle()) {\n const timer = $interval(() => {\n tryCount++;\n if(viewport.applyContainerStyle()) {\n $interval.cancel(timer);\n doAdjust();\n }\n if(tryCount * VIEWPORT_POLLING_INTERVAL >= MAX_VIEWPORT_DELAY) {\n $interval.cancel(timer);\n throw Error(`ui-scroll directive requires a viewport with non-zero height in ${MAX_VIEWPORT_DELAY}ms`);\n }\n }, VIEWPORT_POLLING_INTERVAL);\n }\n else {\n doAdjust();\n }\n };\n\n /**\n * Build padding elements\n *\n * Calling linker is the only way I found to get access to the tag name of the template\n * to prevent the directive scope from pollution a new scope is created and destroyed\n * right after the builder creation is completed\n */\n linker((clone, scope) => {\n viewport.createPaddingElements(clone[0]);\n // we do not include the clone in the DOM. It means that the nested directives will not\n // be able to reach the parent directives, but in this case it is intentional because we\n // created the clone to access the template tag name\n scope.$destroy();\n clone.remove();\n });\n\n $scope.$on('$destroy', () => {\n unbindEvents();\n viewport.unbind('mousewheel', wheelHandler);\n });\n\n viewport.bind('mousewheel', wheelHandler);\n\n initialize();\n\n /* Private function definitions */\n\n function isInvalid(rid) {\n return (rid && rid !== ridActual) || $scope.$$destroyed;\n }\n\n function bindEvents() {\n viewport.bind('resize', resizeAndScrollHandler);\n viewport.bind('scroll', resizeAndScrollHandler);\n }\n\n function unbindEvents() {\n viewport.unbind('resize', resizeAndScrollHandler);\n viewport.unbind('scroll', resizeAndScrollHandler);\n }\n\n function reload() {\n viewport.resetTopPadding();\n viewport.resetBottomPadding();\n if (arguments.length) {\n startIndex = parseNumber(arguments[0], START_INDEX_DEFAULT, false);\n }\n buffer.reset(startIndex);\n persistDatasourceIndex(datasource, 'minIndex');\n persistDatasourceIndex(datasource, 'maxIndex');\n doAdjust();\n }\n\n function isElementVisible(wrapper) {\n return wrapper.element.height() && wrapper.element[0].offsetParent;\n }\n\n function visibilityWatcher(wrapper) {\n if (isElementVisible(wrapper)) {\n buffer.forEach((item) => {\n if (typeof item.unregisterVisibilityWatcher === 'function') {\n item.unregisterVisibilityWatcher();\n delete item.unregisterVisibilityWatcher;\n }\n });\n if (!pending.length) {\n $timeout(() => doAdjust());\n }\n }\n }\n\n function insertWrapperContent(wrapper, insertAfter) {\n createElement(wrapper, insertAfter, viewport.insertElement);\n if (!isElementVisible(wrapper)) {\n wrapper.unregisterVisibilityWatcher = wrapper.scope.$watch(() => visibilityWatcher(wrapper));\n }\n elementRoutines.hideElement(wrapper); // hide inserted elements before data binding\n }\n\n function createElement(wrapper, insertAfter, insertElement) {\n let promises = null;\n const sibling = (insertAfter > 0) ? buffer[insertAfter - 1].element : undefined;\n linker((clone, scope) => {\n promises = insertElement(clone, sibling);\n wrapper.element = clone;\n wrapper.scope = scope;\n scope[itemName] = wrapper.item;\n });\n // ui-scroll-grid apply\n if (adapter.transform) {\n const tdInitializer = wrapper.scope.uiScrollTdInitializer;\n if (tdInitializer && tdInitializer.linking) {\n adapter.transform(wrapper.scope, wrapper.element);\n } else {\n wrapper.scope.uiScrollTdInitializer = {\n onLink: () => adapter.transform(wrapper.scope, wrapper.element),\n scope: wrapper.scope\n };\n }\n }\n return promises;\n }\n\n function updateDOM() {\n let promises = [];\n const toBePrepended = [];\n const toBeRemoved = [];\n const inserted = [];\n\n buffer.forEach((wrapper, i) => {\n switch (wrapper.op) {\n case 'prepend':\n toBePrepended.unshift(wrapper);\n break;\n case 'append':\n insertWrapperContent(wrapper, i);\n wrapper.op = 'none';\n inserted.push(wrapper);\n break;\n case 'insert':\n promises = promises.concat(createElement(wrapper, i, viewport.insertElementAnimated));\n wrapper.op = 'none';\n inserted.push(wrapper);\n break;\n case 'remove':\n toBeRemoved.push(wrapper);\n }\n });\n\n toBeRemoved.forEach((wrapper) => promises = promises.concat(viewport.removeItem(wrapper)));\n\n if (toBePrepended.length)\n toBePrepended.forEach((wrapper) => {\n insertWrapperContent(wrapper);\n wrapper.op = 'none';\n });\n\n buffer.forEach((item, i) => item.scope.$index = buffer.first + i);\n\n return {\n prepended: toBePrepended,\n removed: toBeRemoved,\n inserted: inserted,\n animated: promises\n };\n\n }\n\n function updatePaddings(rid, updates) {\n // schedule another doAdjust after animation completion\n if (updates.animated.length) {\n $q.all(updates.animated).then(() => {\n viewport.adjustPaddings();\n doAdjust(rid);\n });\n } else {\n viewport.adjustPaddings();\n }\n }\n\n function enqueueFetch(rid, updates) {\n if (viewport.shouldLoadBottom()) {\n if (!updates || buffer.effectiveHeight(updates.inserted) > 0) {\n // this means that at least one item appended in the last batch has height > 0\n if (pending.push(true) === 1) {\n adapter.loading(true);\n fetch(rid);\n }\n }\n } else if (viewport.shouldLoadTop()) {\n if ((!updates || buffer.effectiveHeight(updates.prepended) > 0) || pending[0]) {\n // this means that at least one item appended in the last batch has height > 0\n // pending[0] = true means that previous fetch was appending. We need to force at least one prepend\n // BTW there will always be at least 1 element in the pending array because bottom is fetched first\n if (pending.push(false) === 1) {\n adapter.loading(true);\n fetch(rid);\n }\n }\n }\n }\n\n function processUpdates() {\n const updates = updateDOM();\n\n // We need the item bindings to be processed before we can do adjustments\n !$scope.$$phase && !$rootScope.$$phase && $scope.$digest();\n\n updates.inserted.forEach(w => elementRoutines.showElement(w));\n updates.prepended.forEach(w => elementRoutines.showElement(w));\n return updates;\n }\n\n function doAdjust(rid) {\n if (!rid) { // dismiss pending requests\n pending = [];\n rid = ++ridActual;\n }\n\n const updates = processUpdates();\n\n if (isInvalid(rid)) {\n return;\n }\n\n updatePaddings(rid, updates);\n enqueueFetch(rid);\n\n if (!pending.length) {\n adapter.calculateProperties();\n }\n }\n\n function doAdjustAfterFetch(rid) {\n const updates = processUpdates();\n\n viewport.onAfterPrepend(updates);\n\n if (isInvalid(rid)) {\n return;\n }\n\n updatePaddings(rid, updates);\n onRenderHandlersRunner();\n enqueueFetch(rid, updates);\n pending.shift();\n\n if (pending.length)\n fetch(rid);\n else {\n adapter.loading(false);\n bindEvents();\n adapter.calculateProperties();\n }\n }\n\n function fetch(rid) {\n if (pending[0]) {// scrolling down\n if (buffer.length && !viewport.shouldLoadBottom()) {\n doAdjustAfterFetch(rid);\n } else {\n fetchNext((result) => {\n if (isInvalid(rid)) {\n return;\n }\n\n if (result.length < bufferSize) {\n buffer.eof = true;\n }\n\n if (result.length > 0) {\n viewport.clipTop();\n buffer.append(result);\n }\n\n doAdjustAfterFetch(rid);\n });\n }\n } else { // scrolling up\n if (buffer.length && !viewport.shouldLoadTop()) {\n doAdjustAfterFetch(rid);\n } else {\n fetchPrevious((result) => {\n if (isInvalid(rid)) {\n return;\n }\n\n if (result.length < bufferSize) {\n buffer.bof = true;\n // log 'bof is reached'\n }\n\n if (result.length > 0) {\n if (buffer.length) {\n viewport.clipBottom();\n }\n buffer.prepend(result);\n }\n\n doAdjustAfterFetch(rid);\n });\n }\n }\n }\n\n function resizeAndScrollHandler() {\n if (!$rootScope.$$phase && !adapter.isLoading && !adapter.disabled) {\n\n enqueueFetch(ridActual);\n\n if (pending.length) {\n unbindEvents();\n } else {\n adapter.calculateProperties();\n !$scope.$$phase && $scope.$digest();\n }\n }\n }\n\n function wheelHandler(event) {\n if (!adapter.disabled) {\n const scrollTop = viewport[0].scrollTop;\n const yMax = viewport[0].scrollHeight - viewport[0].clientHeight;\n\n if ((scrollTop === 0 && !buffer.bof) || (scrollTop === yMax && !buffer.eof)) {\n event.preventDefault();\n }\n }\n }\n }\n\n }\n ]);\n"],"sourceRoot":""} \ No newline at end of file