smart-table-scroll
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -20,3 +20,3 @@ // | ||
// | ||
heightFn: function() { return 20; }, | ||
heightFn: function() { return 17; }, | ||
availableNodes: 200, | ||
@@ -23,0 +23,0 @@ |
{ | ||
"name": "smart-table-scroll", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Build scrollable tables w/ many(1MM) rows.", | ||
@@ -5,0 +5,0 @@ "main": "src/smart-table-scroll.js", |
@@ -1963,2 +1963,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SmartTableScroll = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
this.tops = []; // css `top` values for each data row - in seperate array for faster _sortedIndex call | ||
this.el.className = this.el.className + ' sts-container'; | ||
this.reset(); | ||
@@ -1987,2 +1988,3 @@ }; | ||
newRow.style.top = this.data[ndx].__top + 'px'; | ||
newRow.className = newRow.className + ' sts-row'; | ||
this.el.appendChild(newRow); | ||
@@ -1995,4 +1997,3 @@ this.rowsWithNodes.push(ndx); | ||
this.bottomEl = document.createElement('div'); | ||
this.bottomEl.innerText = '.'; | ||
this.bottomEl.style.position = 'absolute'; | ||
this.bottomEl.className = 'sts-bottom-anchor'; | ||
this.bottomEl.style.top = this.totalHeight + 'px'; | ||
@@ -1999,0 +2000,0 @@ this.el.appendChild(this.bottomEl); |
@@ -1,1 +0,1 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SmartTableScroll=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var baseCallback=require("lodash._basecallback"),binaryIndex=require("lodash._binaryindex"),binaryIndexBy=require("lodash._binaryindexby");function createSortedIndex(retHighest){return function(array,value,iteratee,thisArg){return iteratee==null?binaryIndex(array,value,retHighest):binaryIndexBy(array,value,baseCallback(iteratee,thisArg,1),retHighest)}}var sortedIndex=createSortedIndex();module.exports=sortedIndex},{"lodash._basecallback":2,"lodash._binaryindex":13,"lodash._binaryindexby":14}],2:[function(require,module,exports){var baseIsEqual=require("lodash._baseisequal"),bindCallback=require("lodash._bindcallback"),isArray=require("lodash.isarray"),pairs=require("lodash.pairs");var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;var reEscapeChar=/\\(\\)?/g;function baseToString(value){return value==null?"":value+""}function baseCallback(func,thisArg,argCount){var type=typeof func;if(type=="function"){return thisArg===undefined?func:bindCallback(func,thisArg,argCount)}if(func==null){return identity}if(type=="object"){return baseMatches(func)}return thisArg===undefined?property(func):baseMatchesProperty(func,thisArg)}function baseGet(object,path,pathKey){if(object==null){return}if(pathKey!==undefined&&pathKey in toObject(object)){path=[pathKey]}var index=0,length=path.length;while(object!=null&&index<length){object=object[path[index++]]}return index&&index==length?object:undefined}function baseIsMatch(object,matchData,customizer){var index=matchData.length,length=index,noCustomizer=!customizer;if(object==null){return!length}object=toObject(object);while(index--){var data=matchData[index];if(noCustomizer&&data[2]?data[1]!==object[data[0]]:!(data[0]in object)){return false}}while(++index<length){data=matchData[index];var key=data[0],objValue=object[key],srcValue=data[1];if(noCustomizer&&data[2]){if(objValue===undefined&&!(key in object)){return false}}else{var result=customizer?customizer(objValue,srcValue,key):undefined;if(!(result===undefined?baseIsEqual(srcValue,objValue,customizer,true):result)){return false}}}return true}function baseMatches(source){var matchData=getMatchData(source);if(matchData.length==1&&matchData[0][2]){var key=matchData[0][0],value=matchData[0][1];return function(object){if(object==null){return false}return object[key]===value&&(value!==undefined||key in toObject(object))}}return function(object){return baseIsMatch(object,matchData)}}function baseMatchesProperty(path,srcValue){var isArr=isArray(path),isCommon=isKey(path)&&isStrictComparable(srcValue),pathKey=path+"";path=toPath(path);return function(object){if(object==null){return false}var key=pathKey;object=toObject(object);if((isArr||!isCommon)&&!(key in object)){object=path.length==1?object:baseGet(object,baseSlice(path,0,-1));if(object==null){return false}key=last(path);object=toObject(object)}return object[key]===srcValue?srcValue!==undefined||key in object:baseIsEqual(srcValue,object[key],undefined,true)}}function baseProperty(key){return function(object){return object==null?undefined:object[key]}}function basePropertyDeep(path){var pathKey=path+"";path=toPath(path);return function(object){return baseGet(object,path,pathKey)}}function baseSlice(array,start,end){var index=-1,length=array.length;start=start==null?0:+start||0;if(start<0){start=-start>length?0:length+start}end=end===undefined||end>length?length:+end||0;if(end<0){end+=length}length=start>end?0:end-start>>>0;start>>>=0;var result=Array(length);while(++index<length){result[index]=array[index+start]}return result}function getMatchData(object){var result=pairs(object),length=result.length;while(length--){result[length][2]=isStrictComparable(result[length][1])}return result}function isKey(value,object){var type=typeof value;if(type=="string"&&reIsPlainProp.test(value)||type=="number"){return true}if(isArray(value)){return false}var result=!reIsDeepProp.test(value);return result||object!=null&&value in toObject(object)}function isStrictComparable(value){return value===value&&!isObject(value)}function toObject(value){return isObject(value)?value:Object(value)}function toPath(value){if(isArray(value)){return value}var result=[];baseToString(value).replace(rePropName,function(match,number,quote,string){result.push(quote?string.replace(reEscapeChar,"$1"):number||match)});return result}function last(array){var length=array?array.length:0;return length?array[length-1]:undefined}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function identity(value){return value}function property(path){return isKey(path)?baseProperty(path):basePropertyDeep(path)}module.exports=baseCallback},{"lodash._baseisequal":3,"lodash._bindcallback":8,"lodash.isarray":15,"lodash.pairs":9}],3:[function(require,module,exports){var isArray=require("lodash.isarray"),isTypedArray=require("lodash.istypedarray"),keys=require("lodash.keys");var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",stringTag="[object String]";function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;function arraySome(array,predicate){var index=-1,length=array.length;while(++index<length){if(predicate(array[index],index,array)){return true}}return false}function baseIsEqual(value,other,customizer,isLoose,stackA,stackB){if(value===other){return true}if(value==null||other==null||!isObject(value)&&!isObjectLike(other)){return value!==value&&other!==other}return baseIsEqualDeep(value,other,baseIsEqual,customizer,isLoose,stackA,stackB)}function baseIsEqualDeep(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=arrayTag,othTag=arrayTag;if(!objIsArr){objTag=objToString.call(object);if(objTag==argsTag){objTag=objectTag}else if(objTag!=objectTag){objIsArr=isTypedArray(object)}}if(!othIsArr){othTag=objToString.call(other);if(othTag==argsTag){othTag=objectTag}else if(othTag!=objectTag){othIsArr=isTypedArray(other)}}var objIsObj=objTag==objectTag,othIsObj=othTag==objectTag,isSameTag=objTag==othTag;if(isSameTag&&!(objIsArr||objIsObj)){return equalByTag(object,other,objTag)}if(!isLoose){var objIsWrapped=objIsObj&&hasOwnProperty.call(object,"__wrapped__"),othIsWrapped=othIsObj&&hasOwnProperty.call(other,"__wrapped__");if(objIsWrapped||othIsWrapped){return equalFunc(objIsWrapped?object.value():object,othIsWrapped?other.value():other,customizer,isLoose,stackA,stackB)}}if(!isSameTag){return false}stackA||(stackA=[]);stackB||(stackB=[]);var length=stackA.length;while(length--){if(stackA[length]==object){return stackB[length]==other}}stackA.push(object);stackB.push(other);var result=(objIsArr?equalArrays:equalObjects)(object,other,equalFunc,customizer,isLoose,stackA,stackB);stackA.pop();stackB.pop();return result}function equalArrays(array,other,equalFunc,customizer,isLoose,stackA,stackB){var index=-1,arrLength=array.length,othLength=other.length;if(arrLength!=othLength&&!(isLoose&&othLength>arrLength)){return false}while(++index<arrLength){var arrValue=array[index],othValue=other[index],result=customizer?customizer(isLoose?othValue:arrValue,isLoose?arrValue:othValue,index):undefined;if(result!==undefined){if(result){continue}return false}if(isLoose){if(!arraySome(other,function(othValue){return arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB)})){return false}}else if(!(arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB))){return false}}return true}function equalByTag(object,other,tag){switch(tag){case boolTag:case dateTag:return+object==+other;case errorTag:return object.name==other.name&&object.message==other.message;case numberTag:return object!=+object?other!=+other:object==+other;case regexpTag:case stringTag:return object==other+""}return false}function equalObjects(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objProps=keys(object),objLength=objProps.length,othProps=keys(other),othLength=othProps.length;if(objLength!=othLength&&!isLoose){return false}var index=objLength;while(index--){var key=objProps[index];if(!(isLoose?key in other:hasOwnProperty.call(other,key))){return false}}var skipCtor=isLoose;while(++index<objLength){key=objProps[index];var objValue=object[key],othValue=other[key],result=customizer?customizer(isLoose?othValue:objValue,isLoose?objValue:othValue,key):undefined;if(!(result===undefined?equalFunc(objValue,othValue,customizer,isLoose,stackA,stackB):result)){return false}skipCtor||(skipCtor=key=="constructor")}if(!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;if(objCtor!=othCtor&&("constructor"in object&&"constructor"in other)&&!(typeof objCtor=="function"&&objCtor instanceof objCtor&&typeof othCtor=="function"&&othCtor instanceof othCtor)){return false}}return true}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=baseIsEqual},{"lodash.isarray":15,"lodash.istypedarray":4,"lodash.keys":5}],4:[function(require,module,exports){var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]";var arrayBufferTag="[object ArrayBuffer]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=true;typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=false;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var objToString=objectProto.toString;var MAX_SAFE_INTEGER=9007199254740991;function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[objToString.call(value)]}module.exports=isTypedArray},{}],5:[function(require,module,exports){var getNative=require("lodash._getnative"),isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray");var reIsUint=/^\d+$/;var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var nativeKeys=getNative(Object,"keys");var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function shimKeys(object){var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length;var allowIndexes=!!length&&isLength(length)&&(isArray(object)||isArguments(object));var index=-1,result=[];while(++index<propsLength){var key=props[index];if(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key)){result.push(key)}}return result}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}var keys=!nativeKeys?shimKeys:function(object){var Ctor=object==null?undefined:object.constructor;if(typeof Ctor=="function"&&Ctor.prototype===object||typeof object!="function"&&isArrayLike(object)){return shimKeys(object)}return isObject(object)?nativeKeys(object):[]};function keysIn(object){if(object==null){return[]}if(!isObject(object)){object=Object(object)}var length=object.length;length=length&&isLength(length)&&(isArray(object)||isArguments(object))&&length||0;var Ctor=object.constructor,index=-1,isProto=typeof Ctor=="function"&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;while(++index<length){result[index]=index+""}for(var key in object){if(!(skipIndexes&&isIndex(key,length))&&!(key=="constructor"&&(isProto||!hasOwnProperty.call(object,key)))){result.push(key)}}return result}module.exports=keys},{"lodash._getnative":6,"lodash.isarguments":7,"lodash.isarray":15}],6:[function(require,module,exports){var funcTag="[object Function]";var reIsHostCtor=/^\[object .+?Constructor\]$/;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function getNative(object,key){var value=object==null?undefined:object[key];return isNative(value)?value:undefined}function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}module.exports=getNative},{}],7:[function(require,module,exports){function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var propertyIsEnumerable=objectProto.propertyIsEnumerable;var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isArguments(value){return isObjectLike(value)&&isArrayLike(value)&&hasOwnProperty.call(value,"callee")&&!propertyIsEnumerable.call(value,"callee")}module.exports=isArguments},{}],8:[function(require,module,exports){function bindCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(thisArg===undefined){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function identity(value){return value}module.exports=bindCallback},{}],9:[function(require,module,exports){var keys=require("lodash.keys");function toObject(value){return isObject(value)?value:Object(value)}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function pairs(object){object=toObject(object);var index=-1,props=keys(object),length=props.length,result=Array(length);while(++index<length){var key=props[index];result[index]=[key,object[key]]}return result}module.exports=pairs},{"lodash.keys":10}],10:[function(require,module,exports){arguments[4][5][0].apply(exports,arguments)},{dup:5,"lodash._getnative":11,"lodash.isarguments":12,"lodash.isarray":15}],11:[function(require,module,exports){arguments[4][6][0].apply(exports,arguments)},{dup:6}],12:[function(require,module,exports){arguments[4][7][0].apply(exports,arguments)},{dup:7}],13:[function(require,module,exports){var binaryIndexBy=require("lodash._binaryindexby");var MAX_ARRAY_LENGTH=4294967295,HALF_MAX_ARRAY_LENGTH=MAX_ARRAY_LENGTH>>>1;function binaryIndex(array,value,retHighest){var low=0,high=array?array.length:low;if(typeof value=="number"&&value===value&&high<=HALF_MAX_ARRAY_LENGTH){while(low<high){var mid=low+high>>>1,computed=array[mid];if((retHighest?computed<=value:computed<value)&&computed!==null){low=mid+1}else{high=mid}}return high}return binaryIndexBy(array,value,identity,retHighest)}function identity(value){return value}module.exports=binaryIndex},{"lodash._binaryindexby":14}],14:[function(require,module,exports){var nativeFloor=Math.floor,nativeMin=Math.min;var MAX_ARRAY_LENGTH=4294967295,MAX_ARRAY_INDEX=MAX_ARRAY_LENGTH-1;function binaryIndexBy(array,value,iteratee,retHighest){value=iteratee(value);var low=0,high=array?array.length:0,valIsNaN=value!==value,valIsNull=value===null,valIsUndef=value===undefined;while(low<high){var mid=nativeFloor((low+high)/2),computed=iteratee(array[mid]),isDef=computed!==undefined,isReflexive=computed===computed;if(valIsNaN){var setLow=isReflexive||retHighest}else if(valIsNull){setLow=isReflexive&&isDef&&(retHighest||computed!=null)}else if(valIsUndef){setLow=isReflexive&&(retHighest||isDef)}else if(computed==null){setLow=false}else{setLow=retHighest?computed<=value:computed<value}if(setLow){low=mid+1}else{high=mid}}return nativeMin(high,MAX_ARRAY_INDEX)}module.exports=binaryIndexBy},{}],15:[function(require,module,exports){var arrayTag="[object Array]",funcTag="[object Function]";var reIsHostCtor=/^\[object .+?Constructor\]$/;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var nativeIsArray=getNative(Array,"isArray");var MAX_SAFE_INTEGER=9007199254740991;function getNative(object,key){var value=object==null?undefined:object[key];return isNative(value)?value:undefined}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}var isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag};function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}module.exports=isArray},{}],16:[function(require,module,exports){"use strict";var _sortedIndex=require("lodash.sortedindex");var defaults={heightFn:function(){return 10},availableNodes:100};var ScrollableTable=function(opts){if(!opts.el){throw new Error("Need to pass `el` into ScrollableTable.")}if(!opts.data){throw new Error("Need to pass `data` into ScrollableTable.")}if(!opts.buildRow){throw new Error("Need to pass `buildRow` into ScrollableTable.")}if(!opts.updateRow){throw new Error("Need to pass `updateRow` into ScrollableTable.")}for(var key in defaults){this[key]=defaults[key]}for(var key in opts){this[key]=opts[key]}this.rowsWithNodes=[];this.tops=[];this.reset()};ScrollableTable.prototype.reset=function(){this.yPosition=0;this.setHeights();while(this.el.firstChild){this.el.remove(this.el.firstChild)}for(var ndx=0;ndx<this.data.length;ndx++){this.data[ndx].__node=null}this.rowsWithNodes=[];var nodesToBuild=Math.min(this.availableNodes,this.data.length);for(ndx=0;ndx<nodesToBuild;ndx++){var newRow=this.buildRow(this.data[ndx]);newRow.style.top=this.data[ndx].__top+"px";this.el.appendChild(newRow);this.rowsWithNodes.push(ndx);this.data[ndx].__node=newRow}this.bottomEl=document.createElement("div");this.bottomEl.innerText=".";this.bottomEl.style.position="absolute";this.bottomEl.style.top=this.totalHeight+"px";this.el.appendChild(this.bottomEl);this.el.addEventListener("scroll",this.updateVisibleRows.bind(this))};ScrollableTable.prototype.updateVisibleRows=function(evt){if(this.isUpdating){return}this.isUpdating=true;var screenMidpoint=this.el.scrollTop+this.el.clientHeight/2,midNdx=_sortedIndex(this.tops,screenMidpoint),freeSearchNdx=0,fillStart=Math.max(0,midNdx-Math.ceil(this.availableNodes/2)),fillEnd=Math.min(this.data.length,midNdx+Math.ceil(this.availableNodes/2));if(this.lastMidNdx===midNdx){this.isUpdating=false;return}this.lastMidNdx=midNdx;for(var rowNdx=fillStart;rowNdx<fillEnd;rowNdx++){if(!this.data[rowNdx].__node){while(this.rowsWithNodes[freeSearchNdx]>fillStart&&this.rowsWithNodes[freeSearchNdx]<fillEnd){freeSearchNdx++}this.data[rowNdx].__node=this.data[this.rowsWithNodes[freeSearchNdx]].__node;this.updateRow(this.data[rowNdx],this.data[rowNdx].__node);this.data[rowNdx].__node.style.top=this.data[rowNdx].__top+"px";this.data[this.rowsWithNodes[freeSearchNdx]].__node=null;this.rowsWithNodes[freeSearchNdx]=rowNdx;freeSearchNdx++}}this.isUpdating=false};ScrollableTable.prototype.setHeights=function(){this.totalHeight=0;this.tops=[];for(var ndx=0;ndx<this.data.length;ndx++){this.data[ndx].__top=this.totalHeight;this.tops.push(this.totalHeight);this.totalHeight+=this.heightFn(this.data[ndx])}return this.totalHeight};module.exports=ScrollableTable},{"lodash.sortedindex":1}]},{},[16])(16)}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SmartTableScroll=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var baseCallback=require("lodash._basecallback"),binaryIndex=require("lodash._binaryindex"),binaryIndexBy=require("lodash._binaryindexby");function createSortedIndex(retHighest){return function(array,value,iteratee,thisArg){return iteratee==null?binaryIndex(array,value,retHighest):binaryIndexBy(array,value,baseCallback(iteratee,thisArg,1),retHighest)}}var sortedIndex=createSortedIndex();module.exports=sortedIndex},{"lodash._basecallback":2,"lodash._binaryindex":13,"lodash._binaryindexby":14}],2:[function(require,module,exports){var baseIsEqual=require("lodash._baseisequal"),bindCallback=require("lodash._bindcallback"),isArray=require("lodash.isarray"),pairs=require("lodash.pairs");var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;var reEscapeChar=/\\(\\)?/g;function baseToString(value){return value==null?"":value+""}function baseCallback(func,thisArg,argCount){var type=typeof func;if(type=="function"){return thisArg===undefined?func:bindCallback(func,thisArg,argCount)}if(func==null){return identity}if(type=="object"){return baseMatches(func)}return thisArg===undefined?property(func):baseMatchesProperty(func,thisArg)}function baseGet(object,path,pathKey){if(object==null){return}if(pathKey!==undefined&&pathKey in toObject(object)){path=[pathKey]}var index=0,length=path.length;while(object!=null&&index<length){object=object[path[index++]]}return index&&index==length?object:undefined}function baseIsMatch(object,matchData,customizer){var index=matchData.length,length=index,noCustomizer=!customizer;if(object==null){return!length}object=toObject(object);while(index--){var data=matchData[index];if(noCustomizer&&data[2]?data[1]!==object[data[0]]:!(data[0]in object)){return false}}while(++index<length){data=matchData[index];var key=data[0],objValue=object[key],srcValue=data[1];if(noCustomizer&&data[2]){if(objValue===undefined&&!(key in object)){return false}}else{var result=customizer?customizer(objValue,srcValue,key):undefined;if(!(result===undefined?baseIsEqual(srcValue,objValue,customizer,true):result)){return false}}}return true}function baseMatches(source){var matchData=getMatchData(source);if(matchData.length==1&&matchData[0][2]){var key=matchData[0][0],value=matchData[0][1];return function(object){if(object==null){return false}return object[key]===value&&(value!==undefined||key in toObject(object))}}return function(object){return baseIsMatch(object,matchData)}}function baseMatchesProperty(path,srcValue){var isArr=isArray(path),isCommon=isKey(path)&&isStrictComparable(srcValue),pathKey=path+"";path=toPath(path);return function(object){if(object==null){return false}var key=pathKey;object=toObject(object);if((isArr||!isCommon)&&!(key in object)){object=path.length==1?object:baseGet(object,baseSlice(path,0,-1));if(object==null){return false}key=last(path);object=toObject(object)}return object[key]===srcValue?srcValue!==undefined||key in object:baseIsEqual(srcValue,object[key],undefined,true)}}function baseProperty(key){return function(object){return object==null?undefined:object[key]}}function basePropertyDeep(path){var pathKey=path+"";path=toPath(path);return function(object){return baseGet(object,path,pathKey)}}function baseSlice(array,start,end){var index=-1,length=array.length;start=start==null?0:+start||0;if(start<0){start=-start>length?0:length+start}end=end===undefined||end>length?length:+end||0;if(end<0){end+=length}length=start>end?0:end-start>>>0;start>>>=0;var result=Array(length);while(++index<length){result[index]=array[index+start]}return result}function getMatchData(object){var result=pairs(object),length=result.length;while(length--){result[length][2]=isStrictComparable(result[length][1])}return result}function isKey(value,object){var type=typeof value;if(type=="string"&&reIsPlainProp.test(value)||type=="number"){return true}if(isArray(value)){return false}var result=!reIsDeepProp.test(value);return result||object!=null&&value in toObject(object)}function isStrictComparable(value){return value===value&&!isObject(value)}function toObject(value){return isObject(value)?value:Object(value)}function toPath(value){if(isArray(value)){return value}var result=[];baseToString(value).replace(rePropName,function(match,number,quote,string){result.push(quote?string.replace(reEscapeChar,"$1"):number||match)});return result}function last(array){var length=array?array.length:0;return length?array[length-1]:undefined}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function identity(value){return value}function property(path){return isKey(path)?baseProperty(path):basePropertyDeep(path)}module.exports=baseCallback},{"lodash._baseisequal":3,"lodash._bindcallback":8,"lodash.isarray":15,"lodash.pairs":9}],3:[function(require,module,exports){var isArray=require("lodash.isarray"),isTypedArray=require("lodash.istypedarray"),keys=require("lodash.keys");var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",stringTag="[object String]";function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;function arraySome(array,predicate){var index=-1,length=array.length;while(++index<length){if(predicate(array[index],index,array)){return true}}return false}function baseIsEqual(value,other,customizer,isLoose,stackA,stackB){if(value===other){return true}if(value==null||other==null||!isObject(value)&&!isObjectLike(other)){return value!==value&&other!==other}return baseIsEqualDeep(value,other,baseIsEqual,customizer,isLoose,stackA,stackB)}function baseIsEqualDeep(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=arrayTag,othTag=arrayTag;if(!objIsArr){objTag=objToString.call(object);if(objTag==argsTag){objTag=objectTag}else if(objTag!=objectTag){objIsArr=isTypedArray(object)}}if(!othIsArr){othTag=objToString.call(other);if(othTag==argsTag){othTag=objectTag}else if(othTag!=objectTag){othIsArr=isTypedArray(other)}}var objIsObj=objTag==objectTag,othIsObj=othTag==objectTag,isSameTag=objTag==othTag;if(isSameTag&&!(objIsArr||objIsObj)){return equalByTag(object,other,objTag)}if(!isLoose){var objIsWrapped=objIsObj&&hasOwnProperty.call(object,"__wrapped__"),othIsWrapped=othIsObj&&hasOwnProperty.call(other,"__wrapped__");if(objIsWrapped||othIsWrapped){return equalFunc(objIsWrapped?object.value():object,othIsWrapped?other.value():other,customizer,isLoose,stackA,stackB)}}if(!isSameTag){return false}stackA||(stackA=[]);stackB||(stackB=[]);var length=stackA.length;while(length--){if(stackA[length]==object){return stackB[length]==other}}stackA.push(object);stackB.push(other);var result=(objIsArr?equalArrays:equalObjects)(object,other,equalFunc,customizer,isLoose,stackA,stackB);stackA.pop();stackB.pop();return result}function equalArrays(array,other,equalFunc,customizer,isLoose,stackA,stackB){var index=-1,arrLength=array.length,othLength=other.length;if(arrLength!=othLength&&!(isLoose&&othLength>arrLength)){return false}while(++index<arrLength){var arrValue=array[index],othValue=other[index],result=customizer?customizer(isLoose?othValue:arrValue,isLoose?arrValue:othValue,index):undefined;if(result!==undefined){if(result){continue}return false}if(isLoose){if(!arraySome(other,function(othValue){return arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB)})){return false}}else if(!(arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB))){return false}}return true}function equalByTag(object,other,tag){switch(tag){case boolTag:case dateTag:return+object==+other;case errorTag:return object.name==other.name&&object.message==other.message;case numberTag:return object!=+object?other!=+other:object==+other;case regexpTag:case stringTag:return object==other+""}return false}function equalObjects(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objProps=keys(object),objLength=objProps.length,othProps=keys(other),othLength=othProps.length;if(objLength!=othLength&&!isLoose){return false}var index=objLength;while(index--){var key=objProps[index];if(!(isLoose?key in other:hasOwnProperty.call(other,key))){return false}}var skipCtor=isLoose;while(++index<objLength){key=objProps[index];var objValue=object[key],othValue=other[key],result=customizer?customizer(isLoose?othValue:objValue,isLoose?objValue:othValue,key):undefined;if(!(result===undefined?equalFunc(objValue,othValue,customizer,isLoose,stackA,stackB):result)){return false}skipCtor||(skipCtor=key=="constructor")}if(!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;if(objCtor!=othCtor&&("constructor"in object&&"constructor"in other)&&!(typeof objCtor=="function"&&objCtor instanceof objCtor&&typeof othCtor=="function"&&othCtor instanceof othCtor)){return false}}return true}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=baseIsEqual},{"lodash.isarray":15,"lodash.istypedarray":4,"lodash.keys":5}],4:[function(require,module,exports){var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]";var arrayBufferTag="[object ArrayBuffer]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=true;typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=false;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var objToString=objectProto.toString;var MAX_SAFE_INTEGER=9007199254740991;function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[objToString.call(value)]}module.exports=isTypedArray},{}],5:[function(require,module,exports){var getNative=require("lodash._getnative"),isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray");var reIsUint=/^\d+$/;var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var nativeKeys=getNative(Object,"keys");var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function shimKeys(object){var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length;var allowIndexes=!!length&&isLength(length)&&(isArray(object)||isArguments(object));var index=-1,result=[];while(++index<propsLength){var key=props[index];if(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key)){result.push(key)}}return result}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}var keys=!nativeKeys?shimKeys:function(object){var Ctor=object==null?undefined:object.constructor;if(typeof Ctor=="function"&&Ctor.prototype===object||typeof object!="function"&&isArrayLike(object)){return shimKeys(object)}return isObject(object)?nativeKeys(object):[]};function keysIn(object){if(object==null){return[]}if(!isObject(object)){object=Object(object)}var length=object.length;length=length&&isLength(length)&&(isArray(object)||isArguments(object))&&length||0;var Ctor=object.constructor,index=-1,isProto=typeof Ctor=="function"&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;while(++index<length){result[index]=index+""}for(var key in object){if(!(skipIndexes&&isIndex(key,length))&&!(key=="constructor"&&(isProto||!hasOwnProperty.call(object,key)))){result.push(key)}}return result}module.exports=keys},{"lodash._getnative":6,"lodash.isarguments":7,"lodash.isarray":15}],6:[function(require,module,exports){var funcTag="[object Function]";var reIsHostCtor=/^\[object .+?Constructor\]$/;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function getNative(object,key){var value=object==null?undefined:object[key];return isNative(value)?value:undefined}function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}module.exports=getNative},{}],7:[function(require,module,exports){function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var propertyIsEnumerable=objectProto.propertyIsEnumerable;var MAX_SAFE_INTEGER=9007199254740991;function baseProperty(key){return function(object){return object==null?undefined:object[key]}}var getLength=baseProperty("length");function isArrayLike(value){return value!=null&&isLength(getLength(value))}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}function isArguments(value){return isObjectLike(value)&&isArrayLike(value)&&hasOwnProperty.call(value,"callee")&&!propertyIsEnumerable.call(value,"callee")}module.exports=isArguments},{}],8:[function(require,module,exports){function bindCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(thisArg===undefined){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function identity(value){return value}module.exports=bindCallback},{}],9:[function(require,module,exports){var keys=require("lodash.keys");function toObject(value){return isObject(value)?value:Object(value)}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function pairs(object){object=toObject(object);var index=-1,props=keys(object),length=props.length,result=Array(length);while(++index<length){var key=props[index];result[index]=[key,object[key]]}return result}module.exports=pairs},{"lodash.keys":10}],10:[function(require,module,exports){arguments[4][5][0].apply(exports,arguments)},{dup:5,"lodash._getnative":11,"lodash.isarguments":12,"lodash.isarray":15}],11:[function(require,module,exports){arguments[4][6][0].apply(exports,arguments)},{dup:6}],12:[function(require,module,exports){arguments[4][7][0].apply(exports,arguments)},{dup:7}],13:[function(require,module,exports){var binaryIndexBy=require("lodash._binaryindexby");var MAX_ARRAY_LENGTH=4294967295,HALF_MAX_ARRAY_LENGTH=MAX_ARRAY_LENGTH>>>1;function binaryIndex(array,value,retHighest){var low=0,high=array?array.length:low;if(typeof value=="number"&&value===value&&high<=HALF_MAX_ARRAY_LENGTH){while(low<high){var mid=low+high>>>1,computed=array[mid];if((retHighest?computed<=value:computed<value)&&computed!==null){low=mid+1}else{high=mid}}return high}return binaryIndexBy(array,value,identity,retHighest)}function identity(value){return value}module.exports=binaryIndex},{"lodash._binaryindexby":14}],14:[function(require,module,exports){var nativeFloor=Math.floor,nativeMin=Math.min;var MAX_ARRAY_LENGTH=4294967295,MAX_ARRAY_INDEX=MAX_ARRAY_LENGTH-1;function binaryIndexBy(array,value,iteratee,retHighest){value=iteratee(value);var low=0,high=array?array.length:0,valIsNaN=value!==value,valIsNull=value===null,valIsUndef=value===undefined;while(low<high){var mid=nativeFloor((low+high)/2),computed=iteratee(array[mid]),isDef=computed!==undefined,isReflexive=computed===computed;if(valIsNaN){var setLow=isReflexive||retHighest}else if(valIsNull){setLow=isReflexive&&isDef&&(retHighest||computed!=null)}else if(valIsUndef){setLow=isReflexive&&(retHighest||isDef)}else if(computed==null){setLow=false}else{setLow=retHighest?computed<=value:computed<value}if(setLow){low=mid+1}else{high=mid}}return nativeMin(high,MAX_ARRAY_INDEX)}module.exports=binaryIndexBy},{}],15:[function(require,module,exports){var arrayTag="[object Array]",funcTag="[object Function]";var reIsHostCtor=/^\[object .+?Constructor\]$/;function isObjectLike(value){return!!value&&typeof value=="object"}var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var nativeIsArray=getNative(Array,"isArray");var MAX_SAFE_INTEGER=9007199254740991;function getNative(object,key){var value=object==null?undefined:object[key];return isNative(value)?value:undefined}function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}var isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag};function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}module.exports=isArray},{}],16:[function(require,module,exports){"use strict";var _sortedIndex=require("lodash.sortedindex");var defaults={heightFn:function(){return 10},availableNodes:100};var ScrollableTable=function(opts){if(!opts.el){throw new Error("Need to pass `el` into ScrollableTable.")}if(!opts.data){throw new Error("Need to pass `data` into ScrollableTable.")}if(!opts.buildRow){throw new Error("Need to pass `buildRow` into ScrollableTable.")}if(!opts.updateRow){throw new Error("Need to pass `updateRow` into ScrollableTable.")}for(var key in defaults){this[key]=defaults[key]}for(var key in opts){this[key]=opts[key]}this.rowsWithNodes=[];this.tops=[];this.el.className=this.el.className+" sts-container";this.reset()};ScrollableTable.prototype.reset=function(){this.yPosition=0;this.setHeights();while(this.el.firstChild){this.el.remove(this.el.firstChild)}for(var ndx=0;ndx<this.data.length;ndx++){this.data[ndx].__node=null}this.rowsWithNodes=[];var nodesToBuild=Math.min(this.availableNodes,this.data.length);for(ndx=0;ndx<nodesToBuild;ndx++){var newRow=this.buildRow(this.data[ndx]);newRow.style.top=this.data[ndx].__top+"px";newRow.className=newRow.className+" sts-row";this.el.appendChild(newRow);this.rowsWithNodes.push(ndx);this.data[ndx].__node=newRow}this.bottomEl=document.createElement("div");this.bottomEl.className="sts-bottom-anchor";this.bottomEl.style.top=this.totalHeight+"px";this.el.appendChild(this.bottomEl);this.el.addEventListener("scroll",this.updateVisibleRows.bind(this))};ScrollableTable.prototype.updateVisibleRows=function(evt){if(this.isUpdating){return}this.isUpdating=true;var screenMidpoint=this.el.scrollTop+this.el.clientHeight/2,midNdx=_sortedIndex(this.tops,screenMidpoint),freeSearchNdx=0,fillStart=Math.max(0,midNdx-Math.ceil(this.availableNodes/2)),fillEnd=Math.min(this.data.length,midNdx+Math.ceil(this.availableNodes/2));if(this.lastMidNdx===midNdx){this.isUpdating=false;return}this.lastMidNdx=midNdx;for(var rowNdx=fillStart;rowNdx<fillEnd;rowNdx++){if(!this.data[rowNdx].__node){while(this.rowsWithNodes[freeSearchNdx]>fillStart&&this.rowsWithNodes[freeSearchNdx]<fillEnd){freeSearchNdx++}this.data[rowNdx].__node=this.data[this.rowsWithNodes[freeSearchNdx]].__node;this.updateRow(this.data[rowNdx],this.data[rowNdx].__node);this.data[rowNdx].__node.style.top=this.data[rowNdx].__top+"px";this.data[this.rowsWithNodes[freeSearchNdx]].__node=null;this.rowsWithNodes[freeSearchNdx]=rowNdx;freeSearchNdx++}}this.isUpdating=false};ScrollableTable.prototype.setHeights=function(){this.totalHeight=0;this.tops=[];for(var ndx=0;ndx<this.data.length;ndx++){this.data[ndx].__top=this.totalHeight;this.tops.push(this.totalHeight);this.totalHeight+=this.heightFn(this.data[ndx])}return this.totalHeight};module.exports=ScrollableTable},{"lodash.sortedindex":1}]},{},[16])(16)}); |
@@ -47,2 +47,3 @@ // | ||
this.tops = []; // css `top` values for each data row - in seperate array for faster _sortedIndex call | ||
this.el.className = this.el.className + ' sts-container'; | ||
this.reset(); | ||
@@ -71,2 +72,3 @@ }; | ||
newRow.style.top = this.data[ndx].__top + 'px'; | ||
newRow.className = newRow.className + ' sts-row'; | ||
this.el.appendChild(newRow); | ||
@@ -79,4 +81,3 @@ this.rowsWithNodes.push(ndx); | ||
this.bottomEl = document.createElement('div'); | ||
this.bottomEl.innerText = '.'; | ||
this.bottomEl.style.position = 'absolute'; | ||
this.bottomEl.className = 'sts-bottom-anchor'; | ||
this.bottomEl.style.top = this.totalHeight + 'px'; | ||
@@ -83,0 +84,0 @@ this.el.appendChild(this.bottomEl); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1695146
12
2077