@egjs/deview-recycle
Advanced tools
Comparing version 0.0.4 to 0.1.0
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/NAVER-FEPlatform/deview2019-demo.git | ||
version: 0.0.4 | ||
version: 0.1.0 | ||
*/ | ||
@@ -10,0 +10,0 @@ 'use strict'; |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/NAVER-FEPlatform/deview2019-demo.git | ||
version: 0.0.4 | ||
version: 0.1.0 | ||
*/ | ||
@@ -10,0 +10,0 @@ import Component from '@egjs/component'; |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/NAVER-FEPlatform/deview2019-demo.git | ||
version: 0.0.4 | ||
version: 0.1.0 | ||
*/ | ||
@@ -10,0 +10,0 @@ (function (global, factory) { |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/NAVER-FEPlatform/deview2019-demo.git | ||
version: 0.0.4 | ||
version: 0.1.0 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).DeviewRecycle=e()}(this,function(){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function c(t){return void 0===t}var t=function(){var t=function(){function t(){this._eventHandler={},this.options={}}var e=t.prototype;return e.trigger=function(t,e){void 0===e&&(e={});var n=this._eventHandler[t]||[];if(!(0<n.length))return!0;n=n.concat(),e.eventType=t;var r=!1,i=[e],o=0;e.stop=function(){r=!0},e.currentTarget=this;for(var s=arguments.length,c=new Array(2<s?s-2:0),u=2;u<s;u++)c[u-2]=arguments[u];for(1<=c.length&&(i=i.concat(c)),o=0;n[o];o++)n[o].apply(this,i);return!r},e.once=function(i,o){if("object"==typeof i&&c(o)){var t,e=i;for(t in e)this.once(t,e[t]);return this}if("string"==typeof i&&"function"==typeof o){var s=this;this.on(i,function t(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];o.apply(s,n),s.off(i,t)})}return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&c(e)){var n,r=t;for(n in r)this.on(n,r[n]);return this}if("string"==typeof t&&"function"==typeof e){var i=this._eventHandler[t];c(i)&&(this._eventHandler[t]=[],i=this._eventHandler[t]),i.push(e)}return this},e.off=function(t,e){if(c(t))return this._eventHandler={},this;if(c(e)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var n,r=t;for(n in r)this.off(n,r[n]);return this}var i,o,s=this._eventHandler[t];if(s)for(i=0;void 0!==(o=s[i]);i++)if(o===e){s=s.splice(i,1);break}return this},t}();return t.VERSION="2.1.2",t}(),y=function(){function t(){this.keys=[],this.values=[]}var e=t.prototype;return e.get=function(t){return this.values[this.keys.indexOf(t)]},e.set=function(t,e){var n=this.keys,r=this.values,i=n.indexOf(t),o=-1===i?n.length:i;n[o]=t,r[o]=e},t}(),w=function(){function t(){this.object={}}var e=t.prototype;return e.get=function(t){return this.object[t]},e.set=function(t,e){this.object[t]=e},t}(),C="function"==typeof Map,o=function(){function t(){}var e=t.prototype;return e.connect=function(t,e){this.prev=t,this.next=e,t&&(t.next=this),e&&(e.prev=this)},e.disconnect=function(){var t=this.prev,e=this.next;t&&(t.next=e),e&&(e.prev=t)},e.getIndex=function(){for(var t=this,e=-1;t;)t=t.prev,++e;return e},t}();var E=function(){function t(t,e,n,r,i,o,s,c){this.prevList=t,this.list=e,this.added=n,this.removed=r,this.changed=i,this.maintained=o,this.changedBeforeAdded=s,this.fixed=c}var e=t.prototype;return Object.defineProperty(e,"ordered",{get:function(){return this.cacheOrdered||this.caculateOrdered(),this.cacheOrdered},enumerable:!0,configurable:!0}),Object.defineProperty(e,"pureChanged",{get:function(){return this.cachePureChanged||this.caculateOrdered(),this.cachePureChanged},enumerable:!0,configurable:!0}),e.caculateOrdered=function(){var t=function(t,n){var c=[],u=[];return t.forEach(function(t){var e=t[0],n=t[1],r=new o;c[e]=r,u[n]=r}),c.forEach(function(t,e){t.connect(c[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],r=t[1];if(n===r)return[0,0];var i=c[n],o=u[r-1],s=i.getIndex();return i.disconnect(),o?i.connect(o,o.next):i.connect(void 0,c[0]),[s,i.getIndex()]})}(this.changedBeforeAdded,this.fixed),c=this.changed,u=[];this.cacheOrdered=t.filter(function(t,e){var n=t[0],r=t[1],i=c[e],o=i[0],s=i[1];if(n!==r)return u.push([o,s]),!0}),this.cachePureChanged=u},t}();var e=function(n){function t(t,e){void 0===e&&(e={});var h=n.call(this)||this;return h.container=t,h.items=[],h.containerOffset=0,h.containerHeight=0,h.scrollHeight=0,h.timer=0,h.startCursor=-1,h.endCursor=-1,h.onScroll=function(){var t=h.options,i=t.threshold,o=t.overflow?h.container.scrollTop:document.documentElement.scrollTop,e=o-h.containerOffset,n=h.items,r=n.length;if(r){var s=e+h.containerHeight,c=-1,u=-1;if(n.filter(function(t,e){var n=t.pos,r=n+t.size;return n-i<=s&&o<=r+i&&(c<0&&(c=e),u=e,!0)}).length||(u=c=n[r-1].pos<o?r-1:0),h.setCursor(c,u),u!==r-1)return}e>h.scrollHeight-h.containerHeight-i&&(clearTimeout(h.timer),h.timer=window.setTimeout(function(){h.trigger("append",{requestIndex:h.items.length})},60))},h.onResize=function(){var t=h.options.overflow;h.containerOffset=t?0:h.container.getBoundingClientRect().top-document.body.getBoundingClientRect().top,h.containerHeight=t?h.container.offsetHeight:window.innerHeight,h.items.forEach(function(t){t.updated=!1}),h.layout()},h.options=i({threshold:100,margin:0,renderExternal:!1,overflow:!1},e),e.overflow&&(t.style.overflow="scroll"),(e.overflow?t:window).addEventListener("scroll",h.onScroll),window.addEventListener("resize",h.onResize),h.onResize(),h.onScroll(),h}!function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(t,n);var e=t.prototype;return e.insert=function(t,e,n){var r=this.options.renderExternal,i=this.items,o={el:r?null:"object"==typeof e?e:function(t){var e=document.createElement("div");return e.innerHTML=t,e.children[0]}(e),key:n,size:0,pos:0,mounted:!1,updated:!1};return i.splice(t,0,o),r||(this.refreshCursor(),this.layout()),o},e.remove=function(t){var e=this.options,n=this.items.splice(t,1)[0];return e.renderExternal||(n.mounted&&this.container.removeChild(n.el),this.refreshCursor(),this.layout()),n},e.layout=function(){var t=this.options,e=t.overflow,n=t.margin,r=void 0===n?0:n,i=0;return this.items.forEach(function(t){t.mounted&&!t.updated&&(t.size=t.el.offsetHeight,t.updated=!0),t.pos=i,i+=t.size+r}),e||(this.container.style.height=i+"px"),this.scrollHeight=i,this.items.forEach(function(t){t.mounted&&(t.el.style.cssText+="position: absolute;top: "+t.pos+"px;")}),this.onScroll(),this},e.beforeSync=function(e){var n=this,i=this.items,t=function(t,e,n){var r=C?Map:n?w:y,i=n||function(t){return t},o=[],s=[],c=[],u=t.map(i),h=e.map(i),a=new r,f=new r,d=[],l=[],v={},p=[],g=0,m=0;return u.forEach(function(t,e){a.set(t,e)}),h.forEach(function(t,e){f.set(t,e)}),u.forEach(function(t,e){var n=f.get(t);void 0===n?(++m,s.push(e)):v[n]=m}),h.forEach(function(t,e){var n=a.get(t);void 0===n?(o.push(e),++g):(c.push([n,e]),m=v[e]||0,d.push([n-m,e-g]),l.push(e===n),n!==e&&p.push([n,e]))}),s.reverse(),new E(t,e,o,s,p,c,d,l)}(this.items.map(function(t){return t.key}),e,function(t){return t});t.removed.forEach(function(t){n.remove(t)}),t.ordered.forEach(function(t){var e=t[0],n=t[1],r=i.splice(e,1)[0];i.splice(n,0,r)}),t.added.forEach(function(t){n.insert(t,"",e[t])}),this.refreshCursor()},e.sync=function(n){return this.items.slice(this.startCursor,this.endCursor+1).forEach(function(t,e){t.el=n[e],t.mounted=!0}),this.layout(),this},e.append=function(t){return this.insert(this.items.length,t,""),this},e.destroy=function(){(this.options.overflow?this.container:window).removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize)},e.getRenderingIndexes=function(){return{start:this.startCursor,end:this.endCursor}},e.refreshCursor=function(){var n=-1,r=-1;this.items.forEach(function(t,e){t.mounted&&(n<0&&(n=e),r=e)}),this.startCursor=n,this.endCursor=r},e.setCursor=function(t,e){var n=this.container,r=this.items,i=this.options.renderExternal;this.recycle([{start:0,end:t-1},{start:e+1,end:r.length}]);var o=this.startCursor,s=this.endCursor;this.startCursor=t;for(var c=this.endCursor=e;t<=c;--c){var u=r[c];if(!u.mounted){var h=r[c+1],a=h&&h.mounted?h.el:null;i||n.insertBefore(u.el,a),u.mounted=!0}}i||o===t&&s===e||this.layout(),this.trigger("visibleChange",{startCursor:t,endCursor:e})},e.recycle=function(t){var o=this,s=this.items,c=this.options.renderExternal;t.forEach(function(t){for(var e=t.start,n=t.end,r=e;r<=n;++r){var i=s[r];i&&i.mounted&&(i.mounted=!1,c||o.container.removeChild(i.el))}})},t}(t);return e.DEFAULT_OPTIONS={threshold:100,margin:0,renderExternal:!1,overflow:!1},e}); | ||
//# sourceMappingURL=recycle.min.js.map |
{ | ||
"name": "@egjs/deview-recycle", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/recycle.cjs.js", |
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