@egjs/deview-recycle
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,2 +0,2 @@ | ||
import { InfiniteOptions } from "./types"; | ||
export declare const DEFAULT_OPTIONS: InfiniteOptions; | ||
import { RecycleOptions } from "./types"; | ||
export declare const DEFAULT_OPTIONS: RecycleOptions; |
@@ -1,4 +0,4 @@ | ||
import Infinite from "./Infinite"; | ||
export default Infinite; | ||
import DeviewRecycle from "./DeviewRecycle"; | ||
export default DeviewRecycle; | ||
export * from "./consts"; | ||
export * from "./types"; |
@@ -1,2 +0,2 @@ | ||
import Infinite from "./Infinite"; | ||
export default Infinite; | ||
import DeviewRecycle from "./DeviewRecycle"; | ||
export default DeviewRecycle; |
@@ -1,2 +0,2 @@ | ||
export interface InfiniteOptions { | ||
export interface RecycleOptions { | ||
renderExternal: boolean; | ||
@@ -8,5 +8,8 @@ overflow: boolean; | ||
export interface Item { | ||
key: any; | ||
pos: number; | ||
size: number; | ||
el: HTMLElement; | ||
el: HTMLElement | null; | ||
mounted: boolean; | ||
updated: boolean; | ||
} |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/NAVER-FEPlatform/deview2019-demo.git | ||
version: 0.0.1 | ||
version: 0.0.2 | ||
*/ | ||
@@ -372,8 +372,7 @@ 'use strict'; | ||
overflow: false | ||
}; //# sourceMappingURL=consts.js.map | ||
}; | ||
DeviewRecycle.DEFAULT_OPTIONS = DEFAULT_OPTIONS; | ||
//# sourceMappingURL=index.umd.js.map | ||
exports.default = DeviewRecycle; | ||
//# sourceMappingURL=recycle.cjs.js.map |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/NAVER-FEPlatform/deview2019-demo.git | ||
version: 0.0.1 | ||
version: 0.0.2 | ||
*/ | ||
@@ -370,8 +370,6 @@ import Component from '@egjs/component'; | ||
overflow: false | ||
}; //# sourceMappingURL=consts.js.map | ||
}; | ||
//# sourceMappingURL=index.js.map | ||
export default DeviewRecycle; | ||
export { DEFAULT_OPTIONS }; | ||
//# sourceMappingURL=recycle.esm.js.map |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/NAVER-FEPlatform/deview2019-demo.git | ||
version: 0.0.1 | ||
version: 0.0.2 | ||
*/ | ||
@@ -357,3 +357,2 @@ (function (global, factory) { | ||
}(); | ||
//# sourceMappingURL=component.esm.js.map | ||
@@ -685,3 +684,2 @@ /* | ||
} | ||
//# sourceMappingURL=list-differ.esm.js.map | ||
@@ -994,6 +992,5 @@ function makeElement(html) { | ||
overflow: false | ||
}; //# sourceMappingURL=consts.js.map | ||
}; | ||
DeviewRecycle.DEFAULT_OPTIONS = DEFAULT_OPTIONS; | ||
//# sourceMappingURL=index.umd.js.map | ||
@@ -1000,0 +997,0 @@ return DeviewRecycle; |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/NAVER-FEPlatform/deview2019-demo.git | ||
version: 0.0.1 | ||
version: 0.0.2 | ||
*/ | ||
!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}(),E="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 x=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 a=n.call(this)||this;return a.container=t,a.items=[],a.containerOffset=0,a.containerHeight=0,a.scrollHeight=0,a.timer=0,a.startCursor=-1,a.endCursor=-1,a.onScroll=function(){var t=a.options,i=t.threshold,o=t.overflow?a.container.scrollTop:document.documentElement.scrollTop,e=o-a.containerOffset,n=a.items,r=n.length;if(r){var s=e+a.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),a.setCursor(c,u),u!==r-1)return}e>a.scrollHeight-a.containerHeight-i&&(clearTimeout(a.timer),a.timer=window.setTimeout(function(){a.trigger("append",{requestIndex:a.items.length})},60))},a.onResize=function(){var t=a.options.overflow;a.containerOffset=t?0:a.container.getBoundingClientRect().top,a.containerHeight=t?a.container.offsetHeight:window.innerHeight,a.items.forEach(function(t){t.updated=!1}),a.layout()},a.options=i({threshold:100,margin:0,renderExternal:!1,overflow:!1},e),e.overflow&&(t.style.overflow="scroll"),(e.overflow?t:window).addEventListener("scroll",a.onScroll),window.addEventListener("resize",a.onResize),a.onResize(),a.onScroll(),a}!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.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.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=E?Map:n?w:y,i=n||function(t){return t},o=[],s=[],c=[],u=t.map(i),a=e.map(i),f=new r,h=new r,d=[],l=[],v={},p=[],g=0,m=0;return u.forEach(function(t,e){f.set(t,e)}),a.forEach(function(t,e){h.set(t,e)}),u.forEach(function(t,e){var n=h.get(t);void 0===n?(++m,s.push(e)):v[n]=m}),a.forEach(function(t,e){var n=f.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 x(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,1,r)}),t.added.forEach(function(t){n.insert(t,"",e[t])})},e.sync=function(n){return this.items.splice(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.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 a=r[c+1],f=a&&a.mounted?a.el:null;i||n.insertBefore(u.el,f),u.mounted=!0}}i||o===t&&s===e||this.layout(),this.trigger("visibleChange")},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.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.1", | ||
"version": "0.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/recycle.cjs.js", |
@@ -1,6 +0,6 @@ | ||
import Infinite from "./DeviewRecycle"; | ||
import DeviewRecycle from "./DeviewRecycle"; | ||
export default Infinite; | ||
export default DeviewRecycle; | ||
export * from "./consts"; | ||
export * from "./types"; |
@@ -1,6 +0,6 @@ | ||
import Infinite from "./DeviewRecycle"; | ||
import DeviewRecycle from "./DeviewRecycle"; | ||
import { DEFAULT_OPTIONS } from "./consts"; | ||
(Infinite as any).DEFAULT_OPTIONS = DEFAULT_OPTIONS; | ||
(DeviewRecycle as any).DEFAULT_OPTIONS = DEFAULT_OPTIONS; | ||
export default Infinite; | ||
export default DeviewRecycle; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
197262
25
1917