{"version":3,"file":"infinitegrid.js","sources":["../src/browser.ts","../src/consts.ts","../src/utils.ts","../src/ItemManager.ts","../src/DOMRenderer.ts","../src/Infinite.ts","../src/RenderManager.ts","../src/Watcher.ts","../src/InfiniteGrid.ts","../src/layouts/GridLayout.ts","../src/layouts/FrameLayout.ts","../src/layouts/SquareLayout.ts","../src/layouts/lib/BoxModel.ts","../src/layouts/PackingLayout.ts","../src/layouts/lib/dijkstra.ts","../src/layouts/JustifiedLayout.ts","../src/index.umd.ts"],"sourcesContent":["let win: Window;\n\nif (typeof window === \"undefined\") {\n\t// window is undefined in node.js\n\twin = {\n\t\tdocument: {},\n\t\tnavigator: {\n\t\t\tuserAgent: \"\",\n\t\t},\n\t} as Window;\n} else {\n\twin = window;\n}\n\nexport { win as window };\nexport const document = win.document;\n","import { window, document } from \"./browser\";\nimport { IAlign, InfiniteGridMethodsKeys } from \"./types\";\n\nconst ua = window.navigator.userAgent;\n\nexport const SUPPORT_COMPUTEDSTYLE = !!(\"getComputedStyle\" in window);\nexport const SUPPORT_ADDEVENTLISTENER = !!(\"addEventListener\" in document);\nexport const SUPPORT_PASSIVE = (() => {\n\tlet supportsPassiveOption = false;\n\n\ttry {\n\t\tif (SUPPORT_ADDEVENTLISTENER && Object.defineProperty) {\n\t\t\t// tslint:disable-next-line: no-empty\n\t\t\tdocument.addEventListener(\"test\", () => { }, Object.defineProperty({},\n\t\t\t\t\"passive\", {\n\t\t\t\tget() {\n\t\t\t\t\tsupportsPassiveOption = true;\n\t\t\t\t},\n\t\t\t}));\n\t\t}\n\t} catch (e) {\n\t\t//\n\t}\n\treturn supportsPassiveOption;\n})();\n\nexport const IS_IE = /MSIE|Trident|Windows Phone|Edge/.test(ua);\nexport const IS_IOS = /iPhone|iPad/.test(ua);\nexport const IS_ANDROID2 = /Android 2\\./.test(ua);\nexport const CONTAINER_CLASSNAME = \"_eg-infinitegrid-container_\";\nexport const IGNORE_CLASSNAME = \"_eg-infinitegrid-ignore_\";\nexport const TRANSITION_NAME = \"_INFINITEGRID_TRANSITION\";\n\nexport const VERTICAL = \"vertical\";\nexport const HORIZONTAL = \"horizontal\";\n\nexport const DUMMY_POSITION = -100000;\nexport const GROUPKEY_ATT = \"data-groupkey\";\n\nexport const DEFAULT_OPTIONS = {\n\titemSelector: \"*\",\n\tisOverflowScroll: false,\n\tthreshold: 100,\n\tisEqualSize: false,\n\tisConstantSize: false,\n\tuseRecycle: true,\n\thorizontal: false,\n\ttransitionDuration: 0,\n\tuseFit: true,\n\tattributePrefix: \"data-\",\n\trenderExternal: false,\n};\n\nexport const DEFAULT_LAYOUT_OPTIONS = {\n\thorizontal: false,\n\tmargin: 0,\n};\n\nexport const agent = ua.toLowerCase();\nexport const isMobile = /mobi|ios|android/.test(agent);\n\nexport const ALIGN: IAlign = {\n\tSTART: \"start\",\n\tCENTER: \"center\",\n\tEND: \"end\",\n\tJUSTIFY: \"justify\",\n};\n\nexport const IDLE = 0;\nexport const LOADING_APPEND = 1;\nexport const LOADING_PREPEND = 2;\nexport const PROCESSING = 4;\n\nconst webkit = /applewebkit\\/([\\d|.]*)/g.exec(agent);\n\nexport const WEBKIT_VERSION = (webkit && parseInt(webkit[1], 10)) || 0;\nexport const DEFENSE_BROWSER = (WEBKIT_VERSION && WEBKIT_VERSION < 537);\n\nexport const ITEM_KEYS = [\"content\", \"groupKey\", \"itemKey\", \"orgSize\", \"mounted\", \"prevRect\", \"rect\", \"size\"];\ninterface ITransitionEnd {\n\ttransitionend: string;\n\twebkitTransitionEnd: string;\n\tMSTransitionEnd: string;\n\toTransitionEnd: string;\n\tmozTransitionEnd: string;\n}\n\nexport const [TRANSFORM, TRANSITION, TRANSITION_END] = (() => {\n\tconst properties: ITransitionEnd = {\n\t\ttransitionend: \"\",\n\t\twebkitTransitionEnd: \"-webkit-\",\n\t\tMSTransitionEnd: \"-ms-\",\n\t\toTransitionEnd: \"-o-\",\n\t\tmozTransitionEnd: \"-moz-\",\n\t};\n\n\tfor (const property in properties) {\n\t\tconst prefix = properties[property as keyof ITransitionEnd];\n\n\t\tif (`on${property.toLowerCase()}` in window) {\n\t\t\treturn [`${prefix}transform`, `${prefix}transition`, property];\n\t\t}\n\t}\n\treturn [];\n})() as [\"transform\", \"transition\", \"transitionend\"];\n\nexport const INFINITEGRID_EVENTS = [\"append\", \"prepend\", \"imageError\", \"change\", \"layoutComplete\"];\n\n// It's for making mistakes.\n// Whenever you add a public method, you must add the corresponding method name to an array or object.\n// An additional error may occur if not added.\nexport const INFINITEGRID_METHODS: { [key in InfiniteGridMethodsKeys]: true } = {\n\tgetLoadingBar: true,\n\tgetItem: true,\n\tgetItems: true,\n\tlayout: true,\n\tgetGroupKeys: true,\n\tgetStatus: true,\n\tsetStatus: true,\n\tisProcessing: true,\n\tstartLoading: true,\n\tendLoading: true,\n\tisLoading: true,\n\tupdateItem: true,\n\tupdateItems: true,\n\tmoveTo: true,\n};\n","\nimport { window, document } from \"./browser\";\nimport {\n\tSUPPORT_COMPUTEDSTYLE,\n\tSUPPORT_ADDEVENTLISTENER,\n\tSUPPORT_PASSIVE,\n\tVERTICAL,\n\tHORIZONTAL,\n\tDEFAULT_LAYOUT_OPTIONS,\n\tDUMMY_POSITION,\n\tINFINITEGRID_METHODS,\n} from \"./consts\";\nimport InfiniteGrid from \"./InfiniteGrid\";\nimport { IJQuery, IRectlProperties, InnerSizeType, ClientSizeType, ScrollSizeType, OffsetSizeType, IItem, IGroup, IArrayFormat, IInfiniteGridItem } from \"./types\";\nexport function toArray(nodes: HTMLCollection): HTMLElement[];\nexport function toArray<T extends Node>(nodes: IArrayFormat<T>): T[];\nexport function toArray<T extends Node>(nodes: IArrayFormat<T>): T[] {\n\t// SCRIPT5014 in IE8\n\tconst array: T[] = [];\n\n\tif (nodes) {\n\t\tconst length = nodes.length;\n\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tarray.push(nodes[i]);\n\t\t}\n\t}\n\treturn array;\n}\nexport function matchHTML(html: string) {\n\treturn html.match(/^<([A-z]+)\\s*([^>]*)>/);\n}\n/**\n * Select or create element\n * @param {String|HTMLElement|jQuery} param\n *  when string given is as HTML tag, then create element\n *  otherwise it returns selected elements\n * @param {Boolean} multi\n * @returns {HTMLElement}\n */\nexport function $(param: Window, multi?: false): Window;\nexport function $(\n\tparam: string | HTMLElement | Array<string | HTMLElement> | IJQuery,\n\tmulti: true,\n): HTMLElement[];\nexport function $(\n\tparam: string | HTMLElement | Array<string | HTMLElement> | IJQuery,\n\tmulti?: false,\n): HTMLElement;\nexport function $(\n\tparam: string | HTMLElement | Window | IJQuery,\n\tmulti?: false,\n): HTMLElement | Window;\nexport function $(\n\tparam: string | Window | HTMLElement | Array<string | HTMLElement> | IJQuery,\n\tmulti = false,\n): HTMLElement | Window | HTMLElement[] {\n\tlet el: Window | HTMLElement | HTMLElement[] | NodeListOf<HTMLElement> | undefined;\n\n\tif (typeof param === \"string\") { // String (HTML, Selector)\n\t\t// check if string is HTML tag format\n\t\tconst match = matchHTML(param);\n\n\t\t// creating element\n\t\tif (match) { // HTML\n\t\t\tconst dummy = document.createElement(\"div\");\n\n\t\t\tdummy.innerHTML = param;\n\t\t\tel = dummy.childNodes as NodeListOf<HTMLElement>;\n\t\t} else { // Selector\n\t\t\tel = document.querySelectorAll<HTMLElement>(param);\n\t\t}\n\t\tif (multi) {\n\t\t\treturn toArray(el as NodeListOf<HTMLElement>);\n\t\t} else {\n\t\t\treturn el && (el as NodeListOf<HTMLElement>)[0];\n\t\t}\n\t} else if (isWindow(param)) { // window\n\t\tel = param;\n\t} else if (isJQuery(param)) { // jQuery\n\t\tel = multi ? $(param.toArray(), true) :\n\t\t\t$(param.get(0), false);\n\t} else if (Array.isArray(param)) {\n\t\tel = param.map(v => $(v));\n\t\tif (!multi) {\n\t\t\tel = el.length >= 1 ? (el as HTMLElement[])[0] : undefined;\n\t\t}\n\t} else if (param.nodeName &&\n\t\t(param.nodeType === 1 || param.nodeType === 9)) { // HTMLElement, Document\n\t\tel = param;\n\t} else {\n\t\tel = [].slice.call(el);\n\t}\n\treturn el as Window | HTMLElement | HTMLElement[];\n}\nexport function addEvent(\n\telement: Element | Window,\n\ttype: string,\n\thandler: (...args: any[]) => any,\n\teventListenerOptions?: boolean | { [key: string]: any },\n) {\n\tif (SUPPORT_ADDEVENTLISTENER) {\n\t\tlet options = eventListenerOptions || false;\n\n\t\tif (typeof eventListenerOptions === \"object\") {\n\t\t\toptions = SUPPORT_PASSIVE ? eventListenerOptions : false;\n\t\t}\n\t\telement.addEventListener(type, handler, options);\n\t} else if ((element as any).attachEvent) {\n\t\t(element as any).attachEvent(`on${type}`, handler);\n\t} else {\n\t\t(element as any)[`on${type}`] = handler;\n\t}\n}\nexport function removeEvent(\n\telement: Element | Window,\n\ttype: string,\n\thandler: (...args: any[]) => any,\n) {\n\tif (element.removeEventListener) {\n\t\telement.removeEventListener(type, handler, false);\n\t} else if ((element as any).detachEvent) {\n\t\t(element as any).detachEvent(`on${type}`, handler);\n\t} else {\n\t\t(element as any)[`on${type}`] = null;\n\t}\n}\nexport function addOnceEvent(\n\telement: Element,\n\ttype: string,\n\thandler: (...args: any[]) => any,\n\teventListenerOptions?: boolean | { [key: string]: any },\n) {\n\tconst callback = (e: any) => {\n\t\tremoveEvent(element, type, callback);\n\t\thandler(e);\n\t};\n\n\taddEvent(element, type, callback, eventListenerOptions);\n}\nexport function scroll(el: HTMLElement | Window, horizontal = false) {\n\tconst prop = `scroll${horizontal ? \"Left\" : \"Top\"}` as \"scrollLeft\" | \"scrollTop\";\n\n\tif (isWindow(el)) {\n\t\treturn window[horizontal ? \"pageXOffset\" : \"pageYOffset\"] || document.body[prop] || document.documentElement[prop];\n\t} else {\n\t\treturn el[prop];\n\t}\n}\nexport function scrollTo(el: Window | Element, x: number, y: number) {\n\tif (isWindow(el)) {\n\t\tel.scroll(x, y);\n\t} else {\n\t\tel.scrollLeft = x;\n\t\tel.scrollTop = y;\n\t}\n}\nexport function scrollBy(el: Window | Element, x: number, y: number) {\n\tif (isWindow(el)) {\n\t\tel.scrollBy(x, y);\n\t} else {\n\t\tel.scrollLeft += x;\n\t\tel.scrollTop += y;\n\t}\n}\nexport function getStyles(el: Element) {\n\treturn (SUPPORT_COMPUTEDSTYLE ?\n\t\twindow.getComputedStyle(el) : (el as any).currentStyle) || {};\n}\nfunction _getSize(el: Window | Document | HTMLElement, name: \"Width\" | \"Height\", isOffset?: boolean) {\n\tif (isWindow(el)) { // WINDOW\n\t\treturn window[`inner${name}` as InnerSizeType] || document.body[`client${name}` as ClientSizeType];\n\t} else if (isDocument(el)) { // DOCUMENT_NODE\n\t\tconst doc = (el as Document).documentElement;\n\t\tconst body = (el as Document).body;\n\n\t\treturn Math.max(\n\t\t\tbody[`scroll${name}` as ScrollSizeType], doc[`scroll${name}` as ScrollSizeType],\n\t\t\tbody[`offset${name}` as OffsetSizeType], doc[`offset${name}` as OffsetSizeType],\n\t\t\tdoc[`client${name}` as ClientSizeType],\n\t\t);\n\t} else { // NODE\n\t\tlet size = 0;\n\n\t\tif (isOffset) {\n\t\t\tconst clientRect = el.getBoundingClientRect();\n\n\t\t\tsize = name === \"Width\" ? clientRect.right - clientRect.left : clientRect.bottom - clientRect.top;\n\t\t} else {\n\t\t\tsize = el[`client${name}` as ClientSizeType] || el[`offset${name}` as OffsetSizeType];\n\t\t}\n\t\tif (size) {\n\t\t\treturn size;\n\t\t}\n\t\tconst cssSize = getStyles(el)[name.toLowerCase()];\n\n\t\treturn (~cssSize.indexOf(\"px\") && parseFloat(cssSize)) || 0;\n\t}\n}\n\nexport function innerWidth(el: Window | Document | HTMLElement) {\n\treturn _getSize(el, \"Width\", false);\n}\nexport function innerHeight(el: Window | Document | HTMLElement) {\n\treturn _getSize(el, \"Height\", false);\n}\nexport function outerWidth(el: Window | Document | HTMLElement) {\n\treturn _getSize(el, \"Width\", true);\n}\nexport function outerHeight(el: Window | Document | HTMLElement) {\n\treturn _getSize(el, \"Height\", true);\n}\nexport function getSize(el: HTMLElement) {\n\treturn {\n\t\twidth: outerWidth(el),\n\t\theight: outerHeight(el),\n\t};\n}\nexport const STYLE: {\n\tvertical: IRectlProperties,\n\thorizontal: IRectlProperties,\n} = {\n\tvertical: {\n\t\tstartPos1: \"top\",\n\t\tendPos1: \"bottom\",\n\t\tsize1: \"height\",\n\t\tstartPos2: \"left\",\n\t\tendPos2: \"right\",\n\t\tsize2: \"width\",\n\t},\n\thorizontal: {\n\t\tstartPos1: \"left\",\n\t\tendPos1: \"right\",\n\t\tsize1: \"width\",\n\t\tstartPos2: \"top\",\n\t\tendPos2: \"bottom\",\n\t\tsize2: \"height\",\n\t},\n};\n\nexport function getStyleNames(isHorizontal: boolean): IRectlProperties {\n\treturn STYLE[isHorizontal ? HORIZONTAL : VERTICAL];\n}\nexport function assign<A, B>(target: A, source: B): A & B;\nexport function assign<A, B, C>(target: A, source1: B, source2: C): A & B & C;\nexport function assign<A, B, C, D>(target: A, source1: B, source2: C, source3: D): A & B & C & D;\nexport function assign(target: { [key: string]: any }, ...sources: Array<{ [key: string]: any }>): { [key: string]: any };\nexport function assign(target: { [key: string]: any }, ...sources: Array<{ [key: string]: any }>) {\n\tsources.forEach(source => {\n\t\tfor (const key in source) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t});\n\treturn target;\n}\nexport function assignOptions<A extends { [key: string]: any }, B extends { [key: string]: any }>(\n\tdefaultOptions: A, options: B): typeof DEFAULT_LAYOUT_OPTIONS & A & B {\n\treturn assign({},\n\t\tDEFAULT_LAYOUT_OPTIONS,\n\t\tdefaultOptions,\n\t\toptions);\n}\n\nexport function toZeroArray(outline?: number[]) {\n\tif (!outline || !outline.length) {\n\t\treturn [0];\n\t}\n\treturn outline;\n}\nexport function cloneItems<T extends { [key: string]: any }>(items: T[]) {\n\treturn items.map(item => assign({}, item));\n}\nexport function isJQuery(el: any): el is IJQuery {\n\treturn (typeof (window as any).jQuery === \"function\" && el instanceof (window as any).jQuery) ||\n\t\tel.constructor.prototype.jquery && el.toArray;\n}\nexport function isWindow(el: any): el is Window {\n\treturn el === window;\n}\nexport function isDocument(el: Node): el is Document {\n\treturn el.nodeType === 9;\n}\n\nexport function fill<T>(arr: T[], value: T) {\n\tconst length = arr.length;\n\n\tfor (let i = length - 1; i >= 0; --i) {\n\t\tarr[i] = value;\n\t}\n\n\treturn arr;\n}\n\nexport function isUndefined(target: any): target is undefined {\n\treturn typeof target === \"undefined\";\n}\n\nexport function find<T>(arr: T[], callback: (target: T) => any) {\n\tconst length = arr.length;\n\n\tfor (let i = 0; i < length; ++i) {\n\t\tif (callback(arr[i])) {\n\t\t\treturn arr[i];\n\t\t}\n\t}\n\treturn null;\n}\nexport function findLast<T>(arr: T[], callback: (target: T) => any) {\n\tconst length = arr.length;\n\n\tfor (let i = length - 1; i >= 0; --i) {\n\t\tif (callback(arr[i])) {\n\t\t\treturn arr[i];\n\t\t}\n\t}\n\treturn null;\n}\nexport function categorize(newItems: IItem[]) {\n\tconst newGroups: IGroup[] = [];\n\tconst groupKeys: { [key: string]: IGroup } = {};\n\n\tnewItems.forEach(item => {\n\t\tconst { groupKey } = item;\n\t\tlet group = groupKeys[groupKey];\n\n\t\tif (!group) {\n\t\t\tgroup = {\n\t\t\t\tgroupKey,\n\t\t\t\titems: [],\n\t\t\t};\n\t\t\tgroupKeys[groupKey] = group;\n\t\t\tnewGroups.push(group);\n\t\t}\n\n\t\tgroup.items.push(item);\n\t});\n\n\treturn newGroups;\n}\n\nexport function resetSize(item: IInfiniteGridItem) {\n\titem.orgSize = null;\n\titem.size = null;\n}\n\nexport function makeItem(groupKey: string | number, el?: HTMLElement) {\n\treturn {\n\t\tel,\n\t\tgroupKey,\n\t\tmounted: false,\n\t\tcontent: el ? el.outerHTML : \"\",\n\t\trect: {\n\t\t\ttop: DUMMY_POSITION,\n\t\t\tleft: DUMMY_POSITION,\n\t\t},\n\t};\n}\n\n/**\n * Decorator that makes the method of infinitegrid available in the framework.\n * @ko 프레임워크에서 인피니트그리드의 메소드를 사용할 수 있게 하는 데코레이터.\n * @memberof eg.InfiniteGrid\n * @private\n * @example\n * ```js\n * import NativeInfiniteGrid, { withInfiniteGridMethods } from \"@egjs/infinitegrid\";\n *\n * class InfiniteGrid extends React.Component<Partial<InfiniteGridProps & InfiniteGridOptions>> {\n *   &#64;withInfiniteGridMethods\n *   private infinitegrid: NativeInfiniteGrid;\n * }\n * ```\n */\nexport function withInfiniteGridMethods(prototype: any, infinitegridName: string) {\n\tObject.keys(INFINITEGRID_METHODS).forEach((name: keyof InfiniteGrid) => {\n\t\tif (prototype[name]) {\n\t\t\treturn;\n\t\t}\n\t\tprototype[name] = function(...args) {\n\t\t\tconst result = this[infinitegridName][name](...args);\n\n\t\t\t// fix `this` type to return your own `infinitegrid` instance to the instance using the decorator.\n\t\t\tif (result === this[infinitegridName]) {\n\t\t\t\treturn this;\n\t\t\t} else {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t};\n\t});\n}\n\nexport function hasClass(element: HTMLElement, className: string) {\n\tif (element.classList) {\n\t\treturn element.classList.contains(className);\n\t}\n\treturn !!element.className.match(new RegExp(`(\\\\s|^)${className}(\\\\s|$)`));\n}\n\nexport function addClass(element: HTMLElement, className: string) {\n\tif (element.classList) {\n\t\telement.classList.add(className);\n\t} else {\n\t\telement.className += ` ${className}`;\n\t}\n}\n","import { diff, DiffResult } from \"@egjs/list-differ\";\nimport { GROUPKEY_ATT, DUMMY_POSITION, ITEM_KEYS } from \"./consts\";\nimport { isUndefined, assign, categorize, makeItem } from \"./utils\";\nimport { CursorType, IInfiniteGridGroup, IInfiniteGridItem, IItemManagerStatus, IItem, IGroup } from \"./types\";\n\nexport default class ItemManager {\n\tpublic static toItems(elements: HTMLElement[], groupKey: string | number): IInfiniteGridItem[] {\n\t\treturn elements.map(el => makeItem(groupKey, el));\n\t}\n\tpublic static pluck<A extends { [key: string]: any }, B extends keyof A>(data: A[], property: B):\n\t\tA[B] extends any[] ? A[B] : Array<A[B]> {\n\t\treturn data.reduce((acc, v) => acc.concat(v[property]), []) as any;\n\t}\n\t// groups\n\tprivate _groups: IInfiniteGridGroup[] = [];\n\t// group keys\n\tprivate _groupKeys: { [key: string]: IInfiniteGridGroup } = {};\n\n\tpublic clear() {\n\t\tthis._groups = [];\n\t\tthis._groupKeys = {};\n\t}\n\tpublic getStatus(startKey?: string | number, endKey?: string | number): IItemManagerStatus {\n\t\tconst datas = this._groups;\n\t\tconst startIndex = Math.max(this.indexOf(startKey), 0);\n\t\tconst endIndex = this.indexOf(endKey) + 1 || datas.length;\n\n\t\treturn {\n\t\t\t_data: datas.slice(startIndex, endIndex).map(data => {\n\t\t\t\tconst items = data.items.map(item => {\n\t\t\t\t\tconst item2 = {} as IInfiniteGridItem;\n\n\t\t\t\t\tITEM_KEYS.forEach(key => {\n\t\t\t\t\t\tif (key in item) {\n\t\t\t\t\t\t\titem2[key] = item[key];\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\treturn item2;\n\t\t\t\t});\n\t\t\t\tconst data2 = assign({}, data);\n\n\t\t\t\tdata2.items = items;\n\t\t\t\treturn data2;\n\t\t\t}),\n\t\t};\n\t}\n\tpublic setStatus(status: IItemManagerStatus) {\n\t\tconst data = status._data;\n\n\t\tthis.clear();\n\n\t\tdata.forEach((group, i) => {\n\t\t\tthis.insertGroup(group, i);\n\t\t});\n\t}\n\tpublic size() {\n\t\treturn this._groups.length;\n\t}\n\tpublic fit(base: number, horizontal: boolean) {\n\t\tconst groups = this._groups;\n\t\tif (!groups.length) {\n\t\t\treturn;\n\t\t}\n\t\tconst property = horizontal ? \"left\" : \"top\";\n\n\t\tif (base !== 0) {\n\t\t\tgroups.forEach(group => {\n\t\t\t\tconst { items, outlines } = group;\n\n\t\t\t\titems.forEach(item => {\n\t\t\t\t\titem.rect[property] -= base;\n\t\t\t\t});\n\t\t\t\toutlines.start = outlines.start.map(start => start - base);\n\t\t\t\toutlines.end = outlines.end.map(end => end - base);\n\t\t\t});\n\t\t}\n\t}\n\tpublic pluck<T extends keyof IInfiniteGridGroup>(property: T, start?: number, end?: number) {\n\t\tconst data = isUndefined(start) ? this._groups : this.sliceGroups(start, (isUndefined(end) ? start : end) + 1);\n\n\t\treturn ItemManager.pluck(data, property);\n\t}\n\tpublic getOutline(index: number, property: keyof IInfiniteGridGroup[\"outlines\"]) {\n\t\tconst data = this._groups[index];\n\n\t\treturn data ? data.outlines[property] : [];\n\t}\n\tpublic getEdgeIndex(cursor: CursorType, start: number, end: number) {\n\t\tconst prop = cursor === \"start\" ? \"min\" : \"max\";\n\t\tlet index = -1;\n\t\tlet targetValue = cursor === \"start\" ? Infinity : -Infinity;\n\n\t\tfor (let i = start; i <= end; i++) {\n\t\t\tconst value = Math[prop](...this.getOutline(i, cursor));\n\n\t\t\tif ((cursor === \"start\" && targetValue > value) ||\n\t\t\t\t(cursor === \"end\" && targetValue < value)) {\n\t\t\t\ttargetValue = value;\n\t\t\t\tindex = i;\n\t\t\t}\n\t\t}\n\t\treturn index;\n\t}\n\tpublic getEdgeValue(cursor: CursorType, start: number, end: number) {\n\t\tconst group = this.getGroup(this.getEdgeIndex(cursor, start, end));\n\n\t\tif (group) {\n\t\t\tconst outlines = group.outlines[cursor];\n\n\t\t\tif (outlines.length) {\n\t\t\t\treturn Math[cursor === \"start\" ? \"min\" : \"max\"](...outlines);\n\t\t\t}\n\t\t}\n\t\treturn 0;\n\t}\n\tpublic clearOutlines(startCursor = -1, endCursor = -1) {\n\t\tconst datas = this.getGroups();\n\n\t\tdatas.forEach((group, cursor) => {\n\t\t\tif (startCursor <= cursor && cursor <= endCursor) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgroup.items.forEach(item => {\n\t\t\t\titem.rect.top = DUMMY_POSITION;\n\t\t\t\titem.rect.left = DUMMY_POSITION;\n\t\t\t});\n\t\t\tgroup.outlines.start = [];\n\t\t\tgroup.outlines.end = [];\n\t\t});\n\t}\n\tpublic getMaxEdgeValue() {\n\t\tconst groups = this._groups;\n\t\tconst length = groups.length;\n\n\t\tfor (let i = length - 1; i >= 0; --i) {\n\t\t\tconst end = groups[i].outlines.end;\n\n\t\t\tif (end.length) {\n\t\t\t\tconst pos = Math.max(...end);\n\n\t\t\t\treturn pos;\n\t\t\t}\n\t\t}\n\t\treturn 0;\n\t}\n\tpublic prependGroup(group: IGroup): IInfiniteGridGroup | null {\n\t\treturn this.insertGroup(group, 0);\n\t}\n\tpublic appendGroup(group: IGroup): IInfiniteGridGroup | null {\n\t\treturn this.insertGroup(group, this._groups.length);\n\t}\n\tpublic insertGroup(group: IGroup, groupIndex: number): IInfiniteGridGroup | null {\n\t\tif (groupIndex < 0) {\n\t\t\treturn null;\n\t\t}\n\t\tconst prevItems: IItem[] = group.items || [];\n\t\tconst newGroup: IInfiniteGridGroup = {\n\t\t\toutlines: {\n\t\t\t\tstart: [],\n\t\t\t\tend: [],\n\t\t\t},\n\t\t\t...group,\n\t\t\titems: [],\n\t\t};\n\t\tthis._groups.splice(groupIndex, 0, newGroup);\n\t\tthis._groupKeys[newGroup.groupKey] = newGroup;\n\n\t\tprevItems.forEach((item, i) => {\n\t\t\tthis.insert(item, groupIndex, i);\n\t\t});\n\t\treturn newGroup;\n\t}\n\tpublic sync(items: IItem[]): DiffResult<IGroup> {\n\t\tconst groups = this._groups;\n\t\tconst groupKeys = this._groupKeys;\n\t\tconst newGroups = categorize(items);\n\t\tconst result = diff(groups, newGroups, group => group.groupKey);\n\t\tconst {\n\t\t\tremoved,\n\t\t\tadded,\n\t\t\tmaintained,\n\t\t} = result;\n\n\t\tremoved.forEach(removedIndex => {\n\t\t\tconst group = groups[removedIndex];\n\n\t\t\tif (!group) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdelete groupKeys[group.groupKey];\n\t\t});\n\t\tconst nextGroups: IInfiniteGridGroup[] = [];\n\t\tmaintained.forEach(([fromIndex]) => {\n\t\t\tnextGroups.push(groups[fromIndex]);\n\t\t});\n\t\tthis._groups = nextGroups;\n\n\t\tadded.forEach(addedIndex => {\n\t\t\tthis.insertGroup(newGroups[addedIndex], addedIndex);\n\t\t});\n\t\tmaintained.reverse().forEach(([, toIndex]) => {\n\t\t\tthis.syncItems(toIndex, newGroups[toIndex].items);\n\t\t});\n\t\treturn result;\n\t}\n\tpublic insert(newItem: IItem, groupIndex = -1, itemIndex = -1): IInfiniteGridItem | null {\n\t\tconst { groupKey } = newItem;\n\t\tconst groups = this._groups;\n\t\tconst groupKeys = this._groupKeys;\n\t\tconst group = (groupIndex > -1 ? groups[groupIndex] : groupKeys[groupKey])\n\t\t\t|| this.insertGroup({ groupKey }, groupIndex);\n\n\t\tif (!group) {\n\t\t\treturn null;\n\t\t}\n\t\tconst groupItem: IInfiniteGridItem = {\n\t\t\tcontent: \"\",\n\t\t\tmounted: false,\n\t\t\trect: {\n\t\t\t\ttop: DUMMY_POSITION,\n\t\t\t\tleft: DUMMY_POSITION,\n\t\t\t},\n\t\t\t...newItem,\n\t\t};\n\t\tconst groupItems = group.items;\n\n\t\tif (itemIndex === -1) {\n\t\t\tgroupItems.push(groupItem);\n\t\t} else {\n\t\t\tgroupItems.splice(itemIndex, 0, groupItem);\n\t\t}\n\n\t\treturn groupItem;\n\t}\n\tpublic removeGroup(groupIndex: number): IInfiniteGridGroup | null {\n\t\tconst group = this._groups.splice(groupIndex, 1)[0];\n\n\t\tif (!group) {\n\t\t\treturn null;\n\t\t}\n\t\tdelete this._groupKeys[group.groupKey];\n\n\t\treturn group;\n\t}\n\tpublic remove(groupIndex: number, itemIndex: number) {\n\t\tconst data = this.getGroup(groupIndex);\n\t\tlet group: IInfiniteGridGroup | null = null;\n\t\tlet items: IInfiniteGridItem[] = [];\n\n\t\tif (!data) {\n\t\t\treturn { items, group };\n\t\t}\n\t\t// remove item information\n\t\titems = data.items.splice(itemIndex, 1);\n\n\t\tif (!data.items.length) {\n\t\t\tgroup = this.removeGroup(groupIndex);\n\t\t}\n\t\treturn { items, group };\n\t}\n\tpublic indexOf(data: { groupKey: string | number } | string | number | undefined) {\n\t\tif (typeof data === \"undefined\") {\n\t\t\treturn -1;\n\t\t}\n\t\tconst groupKey = `${typeof data === \"object\" ? data.groupKey : data}`;\n\t\tconst datas = this._groups;\n\t\tconst length = datas.length;\n\n\t\tfor (let i = 0; i < length; ++i) {\n\t\t\tif (groupKey === `${datas[i].groupKey}`) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\tpublic indexesOfElement(element: HTMLElement) {\n\t\tconst groupKey = element.getAttribute(GROUPKEY_ATT)!;\n\t\tconst groupIndex = this.indexOf({ groupKey });\n\t\tlet itemIndex = -1;\n\n\t\tif (groupIndex > -1) {\n\t\t\tconst data = this.getGroup(groupIndex);\n\n\t\t\tconst length = data.items.length;\n\n\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\tif (data.items[i].el === element) {\n\t\t\t\t\titemIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn { groupIndex, itemIndex };\n\t}\n\tpublic sliceGroups(start?: number, end?: number) {\n\t\treturn this._groups.slice(start, end);\n\t}\n\tpublic getGroups() {\n\t\treturn this._groups;\n\t}\n\tpublic getGroupByKey(key: number | string) {\n\t\treturn this._groupKeys[key];\n\t}\n\tpublic getGroup(index: number) {\n\t\treturn this._groups[index];\n\t}\n\tprivate syncItems(groupIndex: number, newItems: IItem[]) {\n\t\tif (!newItems.length) {\n\t\t\tthis.removeGroup(groupIndex);\n\t\t\treturn;\n\t\t}\n\t\tconst items = this.getGroup(groupIndex).items;\n\t\tconst {\n\t\t\tadded,\n\t\t\tmaintained,\n\t\t} = diff(items, newItems, item => item.itemKey);\n\n\t\tconst group = this._groups[groupIndex];\n\t\tconst nextItems: IInfiniteGridItem[] = [];\n\t\tmaintained.forEach(([fromIndex, nextIndex]) => {\n\t\t\tconst item = items[fromIndex];\n\t\t\tconst newItem = newItems[nextIndex];\n\n\t\t\tassign(item, newItem);\n\t\t\tnextItems.push(item);\n\t\t});\n\n\t\tgroup.items = nextItems;\n\t\tadded.forEach(addedIndex => {\n\t\t\tthis.insert(newItems[addedIndex], groupIndex, addedIndex);\n\t\t});\n\n\t}\n}\n","import {\n\tDUMMY_POSITION,\n\tGROUPKEY_ATT,\n\tCONTAINER_CLASSNAME,\n\tTRANSITION_NAME,\n\tTRANSITION,\n\tTRANSITION_END,\n\tTRANSFORM,\n} from \"./consts\";\nimport { window, document } from \"./browser\";\nimport {\n\t$,\n\tinnerHeight,\n\tinnerWidth,\n\tgetSize,\n\tgetStyles,\n\taddOnceEvent,\n\tassign,\n} from \"./utils\";\nimport { RectType, IPosition, IJQuery, IInfiniteGridItem, IDOMRendererStatus, IDOMRendererSize, IDOMRendererOptions, IDOMRendererOrgStyle } from \"./types\";\n\nfunction removeTransition(styles: HTMLElement[\"style\"]) {\n\tstyles[`${TRANSITION}-property`] = \"\";\n\tstyles[`${TRANSITION}-duration`] = \"\";\n\tstyles[TRANSFORM] = \"\";\n}\nfunction setTransition(styles: HTMLElement[\"style\"], transitionDuration: number, pos1: IPosition, pos2: IPosition) {\n\tif (!transitionDuration) {\n\t\tremoveTransition(styles);\n\t\treturn false;\n\t}\n\tif (pos1.left === pos2.left && pos1.top === pos2.top) {\n\t\treturn false;\n\t}\n\tstyles[`${TRANSITION}-property`] = `${TRANSFORM},width,height`;\n\tstyles[`${TRANSITION}-duration`] = `${transitionDuration}s`;\n\tstyles[TRANSFORM] = `translate(${pos1.left - pos2.left}px,${pos1.top - pos2.top}px)`;\n\treturn true;\n}\n\nfunction createContainer(element: HTMLElement) {\n\tconst selectContainer = element.querySelector<HTMLElement>(`.${CONTAINER_CLASSNAME}`);\n\n\tif (selectContainer) {\n\t\tselectContainer.style.position = \"relative\";\n\t\tselectContainer.style.height = \"100%\";\n\n\t\treturn selectContainer;\n\t}\n\tconst container = document.createElement(\"div\");\n\n\tcontainer.className = CONTAINER_CLASSNAME;\n\tcontainer.style.position = \"relative\";\n\tcontainer.style.height = \"100%\";\n\n\tconst children = element.children;\n\tconst length = children.length;\t// for IE8\n\n\tfor (let i = 0; i < length; i++) {\n\t\tcontainer.appendChild(children[0]);\n\t}\n\telement.appendChild(container);\n\treturn container;\n}\nfunction render(properties: RectType[], rect: IInfiniteGridItem[\"rect\"], styles: HTMLElement[\"style\"]) {\n\tproperties.forEach(p => {\n\t\t(p in rect) && (styles[p] = `${rect[p]}px`);\n\t});\n}\n\nexport default class DOMRenderer {\n\tpublic static renderItem(item: IInfiniteGridItem, rect: IInfiniteGridItem[\"rect\"], transitionDuration?: number) {\n\t\tif (!item.el) {\n\t\t\treturn;\n\t\t}\n\t\tconst { el, prevRect } = item;\n\t\tconst styles = el.style;\n\n\t\t// for debugging\n\t\tel.setAttribute(GROUPKEY_ATT, `${item.groupKey}`);\n\t\tstyles.position = \"absolute\";\n\t\trender([\"width\", \"height\"], rect, styles);\n\t\tif (transitionDuration && TRANSITION && prevRect) {\n\t\t\tsetTransition(styles, transitionDuration, rect, prevRect);\n\t\t\tif ((el as any)[TRANSITION_NAME]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tel[TRANSITION_NAME] = true;\n\t\t\taddOnceEvent(el, TRANSITION_END, () => {\n\t\t\t\tconst itemRect = item.rect;\n\n\t\t\t\tremoveTransition(styles);\n\t\t\t\trender([\"left\", \"top\"], itemRect, styles);\n\t\t\t\titem.prevRect = itemRect;\n\t\t\t\tel[TRANSITION_NAME] = false;\n\t\t\t});\n\t\t} else {\n\t\t\trender([\"left\", \"top\"], rect, styles);\n\t\t\titem.prevRect = rect;\n\t\t}\n\t}\n\tpublic static renderItems(items: IInfiniteGridItem[], transitionDuration?: number) {\n\t\titems.forEach(item => {\n\t\t\tDOMRenderer.renderItem(item, item.rect, transitionDuration);\n\t\t});\n\t}\n\tpublic static removeItems(items: IInfiniteGridItem[]) {\n\t\titems.forEach(item => {\n\t\t\tif (item.el) {\n\t\t\t\tDOMRenderer.removeElement(item.el);\n\t\t\t\titem.el = null;\n\t\t\t}\n\t\t});\n\t}\n\tpublic static removeElement(element: HTMLElement) {\n\t\tconst parentNode = element && element.parentNode;\n\n\t\tif (!parentNode) {\n\t\t\treturn;\n\t\t}\n\t\tparentNode.removeChild(element);\n\t}\n\tpublic static createElements(items: IInfiniteGridItem[]) {\n\t\tif (!items.length) {\n\t\t\treturn;\n\t\t}\n\t\tconst noElementItems = items.filter(item => !item.el);\n\n\t\tif (!noElementItems.length) {\n\t\t\treturn;\n\t\t}\n\t\tconst elements = $(\n\t\t\tnoElementItems.map(({ content }) => content.replace(/^[\\s\\uFEFF]+|[\\s\\uFEFF]+$/g, \"\")).join(\"\"),\n\t\t\ttrue,\n\t\t);\n\n\t\tnoElementItems.forEach((item, index) => {\n\t\t\titem.el = elements[index];\n\t\t});\n\t}\n\tpublic container: HTMLElement;\n\tpublic view: Window | HTMLElement;\n\tpublic options: IDOMRendererOptions = {\n\t\tisEqualSize: false,\n\t\tisConstantSize: false,\n\t\thorizontal: false,\n\t\tcontainer: false,\n\t};\n\tpublic _size: IDOMRendererSize = {\n\t\tcontainer: -1,\n\t\tview: -1,\n\t\tviewport: -1,\n\t\titem: null,\n\t};\n\tpublic _orgStyle: IDOMRendererOrgStyle = {};\n\tconstructor(element: string | HTMLElement | IJQuery, options: IDOMRendererOptions) {\n\t\tassign(this.options, options);\n\t\tthis._init(element);\n\t\tthis.resize();\n\t}\n\tpublic getStatus() {\n\t\treturn {\n\t\t\tcssText: this.container.style.cssText,\n\t\t\t_size: assign({}, this._size),\n\t\t};\n\t}\n\tpublic setStatus(status: IDOMRendererStatus) {\n\t\tthis.container.style.cssText = status.cssText;\n\t\tassign(this._size, status._size);\n\t}\n\tpublic updateSize(items: IInfiniteGridItem[]) {\n\t\tconst { isEqualSize, isConstantSize } = this.options;\n\t\tconst size = this._size;\n\n\t\treturn items.map(item => {\n\t\t\tif (!item.el) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t\tif (isEqualSize && !size.item) {\n\t\t\t\tsize.item = getSize(item.el);\n\t\t\t}\n\t\t\titem.size = (isEqualSize && assign({}, size.item)) ||\n\t\t\t\t(isConstantSize && item.orgSize && item.orgSize.width && assign({}, item.orgSize)) ||\n\t\t\t\tgetSize(item.el);\n\t\t\tif (!item.orgSize || !item.orgSize.width || !item.orgSize.height) {\n\t\t\t\titem.orgSize = assign({}, item.size);\n\t\t\t}\n\t\t\treturn item;\n\t\t});\n\t}\n\tpublic createAndInsert(items: IInfiniteGridItem[], isAppend?: boolean) {\n\t\tDOMRenderer.createElements(items);\n\n\t\tDOMRenderer.renderItems(items);\n\t\tthis._insert(items, isAppend);\n\t}\n\tpublic getViewSize() {\n\t\treturn this._size.view;\n\t}\n\tpublic getViewportSize() {\n\t\treturn this._size.viewport;\n\t}\n\tpublic getContainerSize() {\n\t\treturn this._size.container;\n\t}\n\tpublic setContainerSize(size: number) {\n\t\tthis._size.container = size;\n\t\tthis.container.style[this.options.horizontal ? \"width\" : \"height\"] = `${size}px`;\n\t}\n\tpublic resize() {\n\t\tconst horizontal = this.options.horizontal;\n\t\tconst view = this.view;\n\t\tconst size = this._calcSize();\n\n\t\tif (size === 0) {\n\t\t\treturn;\n\t\t}\n\t\tconst isResize = size !== this._size.viewport;\n\n\t\tif (isResize) {\n\t\t\tthis._size = {\n\t\t\t\tview: -1,\n\t\t\t\tcontainer: -1,\n\t\t\t\tviewport: size,\n\t\t\t\titem: null,\n\t\t\t};\n\t\t}\n\t\tthis._size.view = horizontal ? innerWidth(view) : innerHeight(view);\n\t\treturn isResize;\n\t}\n\tpublic isNeededResize() {\n\t\treturn this._calcSize() !== this._size.viewport;\n\t}\n\tpublic clear() {\n\t\tthis.container.innerHTML = \"\";\n\t\tthis.container.style[this.options.horizontal ? \"width\" : \"height\"] = \"\";\n\n\t\tthis._size = {\n\t\t\titem: null,\n\t\t\tviewport: -1,\n\t\t\tcontainer: -1,\n\t\t\tview: -1,\n\t\t};\n\t}\n\tpublic destroy() {\n\t\tthis.clear();\n\t\tconst container = this.options.container;\n\t\tlet property: keyof IDOMRendererOrgStyle;\n\n\t\tfor (property in this._orgStyle) {\n\t\t\t(this[container ? \"view\" : \"container\"] as HTMLElement).style[property] = this._orgStyle[property]!;\n\t\t}\n\t\tcontainer && this.container.parentNode!.removeChild(this.container);\n\t}\n\tprivate _init(el: HTMLElement | IJQuery | string) {\n\t\tconst element = $(el);\n\t\tconst style = getStyles(element);\n\t\tconst { container, horizontal } = this.options;\n\n\t\tif (style.position === \"static\") {\n\t\t\tthis._orgStyle.position = element.style.position;\n\t\t\telement.style.position = \"relative\";\n\t\t}\n\t\tif (container) {\n\t\t\tconst target = horizontal ? [\"X\", \"Y\"] : [\"Y\", \"X\"];\n\n\t\t\tthis._orgStyle.overflowX = element.style.overflowX;\n\t\t\tthis._orgStyle.overflowY = element.style.overflowY;\n\t\t\telement.style[`overflow${target[0]}` as \"overflowX\" | \"overflowY\"] = \"scroll\";\n\t\t\telement.style[`overflow${target[1]}` as \"overflowX\" | \"overflowY\"] = \"hidden\";\n\t\t\tthis.view = element;\n\t\t\tthis.container = container === true ? createContainer(this.view as HTMLElement) : container;\n\t\t} else {\n\t\t\tthis.view = window;\n\t\t\tthis.container = element;\n\t\t}\n\t}\n\tprivate _insert(items: IInfiniteGridItem[], isAppend?: boolean, styles?: IInfiniteGridItem[\"rect\"]) {\n\t\tconst container = this.container;\n\t\tconst df = document.createDocumentFragment();\n\n\t\titems.forEach(item => {\n\t\t\tstyles && DOMRenderer.renderItem(item, styles);\n\t\t\tisAppend ? df.appendChild(item.el!) : df.insertBefore(item.el!, df.firstChild);\n\t\t});\n\t\tisAppend ?\n\t\t\tcontainer.appendChild(df) :\n\t\t\tcontainer.insertBefore(df, container.firstChild);\n\t}\n\tprivate _calcSize() {\n\t\treturn this.options.horizontal ?\n\t\t\tinnerHeight(this.container) : innerWidth(this.container);\n\t}\n}\n","import ItemManager from \"./ItemManager\";\nimport { assign, find, findLast } from \"./utils\";\nimport { CursorType, IInfiniteGridGroup, IInfiniteStatus, IRemoveResult, IItem, IInfiniteOptions, IInfiniteGridItem } from \"./types\";\nimport { diff } from \"@egjs/list-differ\";\n\nfunction isVisible(group: IInfiniteGridGroup, threshold: number, scrollPos: number, endScrollPos: number) {\n\tconst { items, outlines } = group;\n\tconst start = outlines.start;\n\tconst end = outlines.end;\n\n\tif (start.length === 0 || end.length === 0 || !items.length || !items[0].el) {\n\t\treturn 2;\n\t}\n\tconst min = Math.min(...start);\n\tconst max = Math.max(...end);\n\n\tif ((endScrollPos + threshold < min)) {\n\t\treturn +1;\n\t} else if ((scrollPos - threshold > max)) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\nclass Infinite {\n\tpublic options: Required<IInfiniteOptions>;\n\tprivate _itemManager: ItemManager;\n\tprivate _status: IInfiniteStatus;\n\tconstructor(itemManger: ItemManager, options: IInfiniteOptions) {\n\t\tthis.options = assign({\n\t\t\tuseRecycle: true,\n\t\t\tthreshold: 100,\n\t\t\tappend: () => void 0,\n\t\t\tprepend: () => void 0,\n\t\t\trecycle: () => void 0,\n\t\t}, options);\n\n\t\tthis._itemManager = itemManger;\n\t\tthis.clear();\n\t}\n\tpublic setSize(size: number) {\n\t\tthis._status.size = size;\n\t}\n\tpublic sync(items: IItem[]) {\n\t\tconst status = this._status;\n\t\tconst { startCursor, endCursor } = status;\n\t\tconst itemManager = this._itemManager;\n\t\tconst prevVisisbleGroups = itemManager.sliceGroups(startCursor, endCursor + 1);\n\t\tconst prevVisibleItems = ItemManager.pluck(prevVisisbleGroups, \"items\");\n\t\tconst result = itemManager.sync(items);\n\t\tconst startGroup = find(\n\t\t\tprevVisisbleGroups,\n\t\t\t({ groupKey }) => itemManager.getGroupByKey(groupKey),\n\t\t);\n\t\tconst endGroup = findLast(\n\t\t\tprevVisisbleGroups,\n\t\t\t({ groupKey }) => itemManager.getGroupByKey(groupKey),\n\t\t);\n\t\tlet nextStartCursor = startGroup ? itemManager.indexOf(startGroup) : -1;\n\t\tlet nextEndCursor = endGroup ? itemManager.indexOf(endGroup) : -1;\n\n\t\tif (nextStartCursor > -1 && nextEndCursor > -1) {\n\t\t\t// This is when the arrangement is inverted.\n\t\t\t// prevVisisbleGroups is [0, 1, 2, 3]\n\t\t\t// but currentGroups is [3, 2, 1, 0]\n\t\t\t// so, nextStartCursor is 3, and nextEndCursor is 0\n\t\t\tconst minCursor = Math.min(nextStartCursor, nextEndCursor);\n\t\t\tconst maxCursor = Math.max(nextStartCursor, nextEndCursor);\n\n\t\t\tnextStartCursor = minCursor;\n\t\t\tnextEndCursor = maxCursor;\n\t\t} else if (nextEndCursor > -1) {\n\t\t\tnextStartCursor = nextEndCursor;\n\t\t} else if (nextStartCursor > -1) {\n\t\t\tnextEndCursor = nextStartCursor;\n\t\t}\n\n\t\tstatus.startCursor = nextStartCursor;\n\t\tstatus.endCursor = nextEndCursor;\n\n\t\tif (result.removed.length > 0) {\n\t\t\treturn \"relayout\";\n\t\t} else {\n\t\t\tconst nextVisibleItems = itemManager.pluck(\"items\", startCursor, endCursor);\n\t\t\tconst visibleDiffResult = diff(prevVisibleItems, nextVisibleItems, ({ itemKey }) => itemKey);\n\n\t\t\tif (visibleDiffResult.removed.length > 0) {\n\t\t\t\treturn \"layout\";\n\t\t\t} else {\n\t\t\t\treturn \"\";\n\t\t\t}\n\t\t}\n\t}\n\tpublic recycle(scrollPos: number | null, isForward?: boolean) {\n\t\tif (!this.options.useRecycle || typeof scrollPos !== \"number\") {\n\t\t\treturn;\n\t\t}\n\t\tconst { startCursor, endCursor, size } = this._status;\n\n\t\tif (startCursor === -1 || endCursor === -1) {\n\t\t\treturn;\n\t\t}\n\t\tconst endScrollPos = scrollPos + size;\n\t\tconst { threshold, recycle } = this.options;\n\t\tconst visibles = this._itemManager.sliceGroups(startCursor, endCursor + 1)\n\t\t\t.map(group => isVisible(group, threshold, scrollPos, endScrollPos));\n\t\tconst length = visibles.length;\n\t\tlet start = isForward ? 0 : visibles.lastIndexOf(0);\n\t\tlet end = isForward ? visibles.indexOf(0) - 1 : visibles.length - 1;\n\n\t\tif (!isForward && start !== -1) {\n\t\t\tstart += 1;\n\t\t}\n\t\tif (start < 0 || end < 0 || start > end || end - start + 1 >= length) {\n\t\t\treturn;\n\t\t}\n\t\tstart = startCursor + start;\n\t\tend = startCursor + end;\n\n\t\tif (isForward) {\n\t\t\tthis.setCursor(\"start\", end + 1);\n\t\t} else {\n\t\t\tthis.setCursor(\"end\", start - 1);\n\t\t}\n\t\trecycle({ start, end });\n\t}\n\tpublic scroll(scrollPos: number | null) {\n\t\tconst [startCursor, endCursor] = this.getCursors();\n\t\tconst items = this._itemManager;\n\n\t\tif (typeof scrollPos !== \"number\" || startCursor === -1 ||\n\t\t\tendCursor === -1 || !items.size()) {\n\t\t\treturn;\n\t\t}\n\t\tconst size = this._status.size;\n\t\tconst { threshold, append, prepend } = this.options;\n\t\tconst datas = items.getGroups();\n\t\tconst endScrollPos = scrollPos + size;\n\t\tconst startEdgePos = Math.max(...datas[startCursor].outlines.start);\n\t\tconst endEdgePos = Math.min(...datas[endCursor].outlines.end);\n\t\tconst visibles = datas.map((group, i) => {\n\t\t\tconst { start, end } = group.outlines;\n\n\t\t\tif (!start.length || !end.length) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst startPos = Math.min(...start);\n\t\t\tconst endPos = Math.max(...end);\n\n\t\t\tif (startPos - threshold <= endScrollPos && scrollPos <= endPos + threshold) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\t\tconst startIndex = visibles.indexOf(true);\n\t\tconst endIndex = visibles.lastIndexOf(true);\n\n\t\tif (~startIndex && startIndex < startCursor) {\n\t\t\tprepend({ cache: datas.slice(startIndex, Math.min(startCursor, endIndex + 1)) });\n\t\t} else if (endCursor < endIndex) {\n\t\t\tappend({ cache: datas.slice(Math.max(startIndex, endCursor + 1), endIndex + 1) });\n\t\t} else {\n\t\t\t// if you have data(no cachedAppendData, has cachedPrependData) to pepend, request it.\n\t\t\tconst cachedAppendData = datas.slice(endCursor + 1, endCursor + 2);\n\t\t\tconst cachedPrependData = datas.slice(startCursor - 1, startCursor);\n\t\t\tconst isPrepend = scrollPos <= startEdgePos + threshold;\n\n\t\t\tif (\n\t\t\t\tendScrollPos >= endEdgePos - threshold\n\t\t\t\t&& (!isPrepend || cachedAppendData.length || !cachedPrependData.length)\n\t\t\t) {\n\t\t\t\tappend({ cache: cachedAppendData });\n\t\t\t} else if (isPrepend) {\n\t\t\t\tprepend({ cache: cachedPrependData });\n\t\t\t}\n\t\t}\n\t}\n\tpublic setCursor(cursor: CursorType, index: number) {\n\t\tconst status = this._status;\n\t\tconst items = this._itemManager;\n\t\tconst size = items.size();\n\n\t\tif (!this.options.useRecycle) {\n\t\t\tstatus.startCursor = 0;\n\t\t\tif (items.getOutline(size - 1, \"end\").length) {\n\t\t\t\tstatus.endCursor = size - 1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (cursor !== \"end\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (cursor === \"start\") {\n\t\t\tstatus.startCursor = index;\n\t\t} else {\n\t\t\tstatus.endCursor = Math.min(size - 1, index);\n\t\t}\n\t\tstatus.startCursor = Math.max(0, status.startCursor);\n\t}\n\tpublic setStatus(status: IInfiniteStatus) {\n\t\tthis._status = assign(this._status, status);\n\t}\n\tpublic getStatus(startKey?: string | number, endKey?: string | number): IInfiniteStatus {\n\t\tconst { startCursor, endCursor, size } = this._status;\n\t\tconst startIndex = Math.max(this._itemManager.indexOf(startKey), 0);\n\t\tconst endIndex = (this._itemManager.indexOf(endKey) + 1 || this._itemManager.size()) - 1;\n\t\tconst start = Math.max(startCursor - startIndex, ~startCursor ? 0 : -1);\n\t\tconst end = Math.max(Math.min(endCursor - startIndex, endIndex - startIndex), start);\n\n\t\treturn {\n\t\t\tstartCursor: start,\n\t\t\tendCursor: end,\n\t\t\tsize,\n\t\t};\n\t}\n\tpublic getEdgeOutline(cursor: CursorType) {\n\t\tconst { startCursor, endCursor } = this._status;\n\n\t\tif (startCursor === -1 || endCursor === -1) {\n\t\t\treturn [];\n\t\t}\n\t\treturn this._itemManager.getOutline(cursor === \"start\" ? startCursor : endCursor, cursor);\n\t}\n\tpublic getEdgeValue(cursor: CursorType) {\n\t\tconst outlines = this.getEdgeOutline(cursor);\n\n\t\treturn outlines.length ? Math[cursor === \"start\" ? \"min\" : \"max\"](...outlines) : 0;\n\t}\n\tpublic getVisibleItems(): IInfiniteGridItem[] {\n\t\tconst { startCursor, endCursor } = this._status;\n\n\t\treturn this._itemManager.pluck(\"items\", startCursor, endCursor);\n\t}\n\tpublic getCursors() {\n\t\tconst status = this._status;\n\n\t\treturn [\n\t\t\tstatus.startCursor,\n\t\t\tstatus.endCursor,\n\t\t];\n\t}\n\tpublic getCursor(cursor: CursorType) {\n\t\treturn this._status[cursor === \"start\" ? \"startCursor\" : \"endCursor\"];\n\t}\n\tpublic getVisibleData() {\n\t\tconst { startCursor, endCursor } = this._status;\n\n\t\treturn this._itemManager.sliceGroups(startCursor, endCursor + 1);\n\t}\n\n\tpublic remove(groupIndex: number, itemIndex: number): IRemoveResult {\n\t\tconst status = this._status;\n\t\tconst items = this._itemManager;\n\t\tconst { startCursor, endCursor } = status;\n\t\tconst result = items.remove(groupIndex, itemIndex);\n\n\t\tif (result.group) {\n\t\t\tif (groupIndex < startCursor) {\n\t\t\t\tthis.setCursor(\"start\", startCursor - 1);\n\t\t\t}\n\t\t\tif (groupIndex <= endCursor) {\n\t\t\t\tthis.setCursor(\"end\", endCursor - 1);\n\t\t\t}\n\t\t}\n\t\tif (!items.size()) {\n\t\t\tstatus.startCursor = -1;\n\t\t\tstatus.endCursor = -1;\n\t\t}\n\t\treturn result;\n\t}\n\tpublic clear() {\n\t\tthis._status = {\n\t\t\tstartCursor: -1,\n\t\t\tendCursor: -1,\n\t\t\tsize: -1,\n\t\t};\n\t}\n}\n\nexport default Infinite;\n","import ItemManager from \"./ItemManager\";\nimport { matchHTML, $, assign } from \"./utils\";\nimport DOMRenderer from \"./DOMRenderer\";\nimport { ILayout, IInfiniteGridItem, IInfiniteGridGroup } from \"./types\";\nimport { check, removeAutoSizer } from \"@egjs/lazyloaded\";\nimport Infinite from \"./Infinite\";\nimport Component from \"@egjs/component\";\n\nfunction hasTarget<T>(target: T[], value: T) {\n\treturn ~target.indexOf(value);\n}\n\nexport default class RenderManager {\n\tprivate _layout: ILayout;\n\tconstructor(\n\t\tprivate _infinite: Infinite,\n\t\tprivate _itemManager: ItemManager,\n\t\tprivate _renderer: DOMRenderer,\n\t\tprivate options: {\n\t\t\tattributePrefix: string;\n\t\t\tisEqualSize: boolean;\n\t\t\tisConstantSize: boolean;\n\t\t\thorizontal: boolean;\n\t\t},\n\t) { }\n\tpublic setLayout(layout: ILayout) {\n\t\tthis._layout = layout;\n\t}\n\tpublic render(\n\t\tcallbackComponent: Component,\n\t\tgroups: IInfiniteGridGroup[],\n\t\titems = ItemManager.pluck(groups, \"items\"),\n\t\tisAppend?: boolean,\n\t) {\n\t\tconst checkGroups = isAppend ? groups : groups.reverse();\n\t\tconst replaceTarget: number[] = [];\n\t\tconst removeTarget: HTMLElement[] = [];\n\t\tconst elements = items.map(item => item.el!);\n\t\tconst prefix = this.options.attributePrefix;\n\n\t\tcheck(\n\t\t\telements,\n\t\t\tprefix,\n\t\t).on(\"ready\", () => {\n\t\t\tif (!this._itemManager) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._complete(callbackComponent, checkGroups, items, isAppend);\n\t\t}).on(\"error\", ({\n\t\t\ttarget,\n\t\t\titemIndex,\n\t\t}) => {\n\t\t\tif (!this._itemManager) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._error(callbackComponent, removeTarget, replaceTarget, target, items, itemIndex);\n\t\t}).on(\"finish\", () => {\n\t\t\tif (!this._itemManager) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._end(callbackComponent, removeTarget, replaceTarget, items);\n\t\t});\n\n\t\treturn callbackComponent;\n\t}\n\tprivate _complete(\n\t\tcallbackComponent: Component,\n\t\tgroups: IInfiniteGridGroup[],\n\t\titems: IInfiniteGridItem[],\n\t\tisAppend?: boolean,\n\t) {\n\t\tconst infinite = this._infinite;\n\t\tconst layout = this._layout;\n\t\tconst itemManager = this._itemManager;\n\t\tconst cursor = isAppend ? \"end\" : \"start\";\n\t\tconst groupIndex = itemManager.indexOf(groups[0]);\n\t\tconst prevGroup = itemManager.getGroup(groupIndex + (isAppend ? -1 : 1));\n\t\tlet outline = prevGroup ? prevGroup.outlines[cursor] : [0];\n\n\t\tthis._renderer.updateSize(items);\n\t\tgroups.forEach(group => {\n\t\t\tconst groupOutline = group.outlines[isAppend ? \"start\" : \"end\"];\n\t\t\tconst isRelayout = !outline.length || (outline.length === groupOutline.length ?\n\t\t\t\t!outline.every((v, index) => v === groupOutline[index]) : true);\n\n\t\t\tif (!isRelayout) {\n\t\t\t\toutline = group.outlines[isAppend ? \"end\" : \"start\"];\n\t\t\t\tDOMRenderer.renderItems(group.items);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst groupItems = group.items;\n\t\t\tconst groupInfo = layout[isAppend ? \"append\" : \"prepend\"](groupItems, outline, true);\n\n\t\t\tassign(group, groupInfo);\n\t\t\tDOMRenderer.renderItems(groupInfo.items);\n\t\t\toutline = groupInfo.outlines[isAppend ? \"end\" : \"start\"];\n\t\t});\n\n\t\tconst startCursor = Math.max(infinite.getCursor(\"start\"), 0);\n\t\tconst endCursor = Math.max(infinite.getCursor(\"end\"), 0);\n\t\tlet requestStartCursor = itemManager.indexOf(groups[0].groupKey);\n\t\tlet requestEndCursor = itemManager.indexOf(groups[groups.length - 1].groupKey);\n\t\tlet isInCursor = true;\n\n\t\tif (requestStartCursor > endCursor + 1 || requestEndCursor < startCursor - 1) {\n\t\t\tisInCursor = false;\n\t\t}\n\t\tif (isInCursor) {\n\t\t\tif (isAppend) {\n\t\t\t\trequestStartCursor = startCursor;\n\t\t\t\trequestEndCursor = Math.max(endCursor, requestEndCursor);\n\t\t\t} else {\n\t\t\t\trequestStartCursor = Math.max(Math.min(startCursor, requestStartCursor), 0);\n\t\t\t\trequestEndCursor = endCursor;\n\t\t\t}\n\t\t}\n\t\tif (requestStartCursor > requestEndCursor) {\n\t\t\tconst tempCursor = requestStartCursor;\n\n\t\t\trequestStartCursor = requestEndCursor;\n\t\t\trequestEndCursor = tempCursor;\n\t\t}\n\t\tcallbackComponent.trigger(\"renderComplete\", {\n\t\t\tstart: requestStartCursor,\n\t\t\tend: requestEndCursor,\n\t\t});\n\t\tcallbackComponent.trigger(\"layoutComplete\", {\n\t\t\titems: ItemManager.pluck(groups, \"items\"),\n\t\t\tisAppend,\n\t\t});\n\t}\n\tprivate _error(\n\t\tcallbackComponent: Component,\n\t\tremoveTarget: HTMLElement[],\n\t\treplaceTarget: number[],\n\t\ttarget: HTMLImageElement,\n\t\titems: IInfiniteGridItem[],\n\t\terrorIndex: number,\n\t) {\n\t\tconst itemManager = this._itemManager;\n\t\tconst item = items[errorIndex];\n\t\tconst element = item.el!;\n\t\tconst prefix = this.options.attributePrefix;\n\n\t\t// remove item\n\t\tconst removeItem = () => {\n\t\t\tif (hasTarget(removeTarget, element)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tremoveTarget.push(element);\n\t\t\tconst index = replaceTarget.indexOf(errorIndex);\n\n\t\t\tindex !== -1 && replaceTarget.splice(index, 1);\n\t\t};\n\t\t// remove image\n\t\tconst remove = () => {\n\t\t\tif (target === element) {\n\t\t\t\tremoveItem();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (hasTarget(removeTarget, element)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttarget.parentNode!.removeChild(target);\n\t\t\titem.content = element.outerHTML;\n\t\t\tif (hasTarget(replaceTarget, errorIndex)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treplaceTarget.push(errorIndex);\n\t\t};\n\t\t// replace image\n\t\tconst replace = (src: string) => {\n\t\t\tif (hasTarget(removeTarget, element)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (src) {\n\t\t\t\tif (matchHTML(src) || typeof src === \"object\") {\n\t\t\t\t\tconst parentNode = target.parentNode!;\n\n\t\t\t\t\tparentNode.insertBefore($(src), target);\n\t\t\t\t\tparentNode.removeChild(target);\n\t\t\t\t\titem.content = element.outerHTML;\n\t\t\t\t} else {\n\t\t\t\t\ttarget.src = src;\n\t\t\t\t\tif (target.getAttribute(`${prefix}width`)) {\n\t\t\t\t\t\tremoveAutoSizer(target, prefix);\n\t\t\t\t\t\ttarget.removeAttribute(`${prefix}width`);\n\t\t\t\t\t\ttarget.removeAttribute(`${prefix}height`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\titem.content = element.outerHTML;\n\t\t\tif (hasTarget(replaceTarget, errorIndex)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treplaceTarget.push(errorIndex);\n\t\t};\n\t\t// replace item\n\t\tconst replaceItem = (content: string) => {\n\t\t\tif (hasTarget(removeTarget, element)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telement.innerHTML = content;\n\t\t\titem.content = element.outerHTML;\n\t\t\tif (hasTarget(replaceTarget, errorIndex)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treplaceTarget.push(errorIndex);\n\t\t};\n\t\tconst totalIndex = itemManager.pluck(\"items\").indexOf(item);\n\n\t\tcallbackComponent.trigger(\"imageError\", {\n\t\t\ttarget,\n\t\t\telement,\n\t\t\titems,\n\t\t\titem,\n\t\t\titemIndex: errorIndex,\n\t\t\treplace,\n\t\t\treplaceItem,\n\t\t\tremove,\n\t\t\tremoveItem,\n\t\t\ttotalIndex,\n\t\t});\n\t}\n\tprivate _end(\n\t\tcallbackComponent: Component,\n\t\tremoveTarget: HTMLElement[],\n\t\treplaceTarget: number[],\n\t\titems: IInfiniteGridItem[],\n\t) {\n\t\tconst { attributePrefix } = this.options;\n\t\tconst removeTargetLength = removeTarget.length;\n\t\tconst replaceTargetLength = replaceTarget.length;\n\n\t\tif (!removeTargetLength && !replaceTargetLength) {\n\t\t\tcallbackComponent.trigger(\"finish\", { remove: [] });\n\t\t\treturn;\n\t\t}\n\t\tconst layoutedItems = replaceTarget.map(itemIndex => items[itemIndex]);\n\n\t\tif (!replaceTargetLength) {\n\t\t\tcallbackComponent.trigger(\"finish\", { remove: removeTarget, layout: true });\n\t\t\treturn;\n\t\t}\n\t\t// wait layoutComplete beacause of error event.\n\t\tcheck(layoutedItems.map(v => v.el!), attributePrefix).on(\"ready\", () => {\n\t\t\tthis._renderer.updateSize(layoutedItems);\n\t\t\tcallbackComponent.trigger(\"finish\", { remove: removeTarget, layout: true });\n\t\t});\n\t}\n}\n","import {\n\tIS_IOS,\n} from \"./consts\";\nimport {\n\twindow,\n} from \"./browser\";\nimport {\n\taddEvent,\n\tremoveEvent,\n\tscroll,\n\tscrollTo,\n\tscrollBy,\n\tassign,\n} from \"./utils\";\nimport { IWatchStatus, IWatcherOptions } from \"./types\";\n\nexport default class Watcher {\n\tpublic options: IWatcherOptions;\n\tprivate _timer: {\n\t\tresize: any;\n\t};\n\tprivate _containerOffset: number = 0;\n\tprivate _view: Window | HTMLElement;\n\tprivate _isScrollIssue: boolean = IS_IOS;\n\t//  When InfiniteGrid is initialized.\n\t// The initial value is null to block the scroll event when returning from browser behavior.\n\tprivate _prevPos: number | null = null;\n\tconstructor(view: Window | HTMLElement, options: Partial<IWatcherOptions> = {}) {\n\t\tassign(this.options = {\n\t\t\tcontainer: view as HTMLElement,\n\t\t\tresize: () => void 0,\n\t\t\tcheck: () => void 0,\n\t\t\tisOverflowScroll: false,\n\t\t\thorizontal: false,\n\t\t}, options);\n\t\tthis._timer = {\n\t\t\tresize: null,\n\t\t};\n\t\tthis._view = view;\n\t\tthis.attachEvent();\n\t\tthis.resize();\n\t\tthis.setScrollPos();\n\t}\n\tpublic getStatus(): IWatchStatus {\n\t\treturn {\n\t\t\t_prevPos: this._prevPos,\n\t\t\tscrollPos: this.getOrgScrollPos(),\n\t\t};\n\t}\n\tpublic setStatus(status: IWatchStatus, applyScrollPos = true) {\n\t\tthis._prevPos = status._prevPos;\n\t\tapplyScrollPos && this.scrollTo(status.scrollPos);\n\t}\n\tpublic scrollBy(pos: number) {\n\t\tconst arrPos = this.options.horizontal ? [pos, 0] : [0, pos];\n\n\t\tscrollBy(this._view, arrPos[0], arrPos[1]);\n\t\tthis.setScrollPos();\n\t}\n\tpublic scrollTo(pos: number) {\n\t\tconst arrPos = this.options.horizontal ? [pos, 0] : [0, pos];\n\n\t\tscrollTo(this._view, arrPos[0], arrPos[1]);\n\t}\n\tpublic getScrollPos() {\n\t\treturn this._prevPos;\n\t}\n\tpublic setScrollPos(pos = this.getOrgScrollPos()) {\n\t\tthis._prevPos = pos - this.getContainerOffset();\n\t}\n\tpublic attachEvent() {\n\t\taddEvent(this._view, \"scroll\", this._onCheck);\n\t\taddEvent(window, \"resize\", this._onResize);\n\t}\n\tpublic getOrgScrollPos() {\n\t\treturn scroll(this._view, this.options.horizontal);\n\t}\n\tpublic reset() {\n\t\tthis._prevPos = null;\n\t}\n\tpublic getContainerOffset() {\n\t\treturn this._containerOffset;\n\t}\n\tpublic resize() {\n\t\tthis._containerOffset = this.options.isOverflowScroll ? 0 : this._getOffset();\n\t}\n\tpublic detachEvent() {\n\t\tremoveEvent(this._view, \"scroll\", this._onCheck);\n\t\tremoveEvent(window, \"resize\", this._onResize);\n\t}\n\tpublic destroy() {\n\t\tthis.detachEvent();\n\t\tthis.reset();\n\t}\n\tprivate _getOffset() {\n\t\tconst { container, horizontal } = this.options;\n\t\tconst rect = container.getBoundingClientRect();\n\n\t\treturn rect[horizontal ? \"left\" : \"top\"] + this.getOrgScrollPos();\n\t}\n\tprivate _onCheck = () => {\n\t\tconst prevPos = this.getScrollPos();\n\t\tconst orgScrollPos = this.getOrgScrollPos();\n\n\t\tthis.setScrollPos(orgScrollPos);\n\t\tconst scrollPos = this.getScrollPos()!;\n\n\t\tif (prevPos === null || (this._isScrollIssue && orgScrollPos === 0) || prevPos === scrollPos) {\n\t\t\torgScrollPos && (this._isScrollIssue = false);\n\t\t\treturn;\n\t\t}\n\t\tthis._isScrollIssue = false;\n\t\tthis.options.check({\n\t\t\tisForward: prevPos < scrollPos,\n\t\t\tscrollPos,\n\t\t\torgScrollPos,\n\t\t\thorizontal: this.options.horizontal,\n\t\t});\n\t}\n\tprivate _onResize = () => {\n\t\tif (this._timer.resize) {\n\t\t\tclearTimeout(this._timer.resize);\n\t\t}\n\t\tthis._timer.resize = setTimeout(() => {\n\t\t\tthis.resize();\n\t\t\tthis.options.resize();\n\t\t\tthis._timer.resize = null;\n\t\t}, 100);\n\t}\n}\n","/**\n * Copyright (c) 2017 NAVER Corp.\n * egjs projects are licensed under the MIT license\n*/\nimport Component from \"@egjs/component\";\nimport ItemManager from \"./ItemManager\";\nimport DOMRenderer from \"./DOMRenderer\";\nimport {\n\tIS_ANDROID2,\n\tIDLE,\n\tLOADING_APPEND,\n\tLOADING_PREPEND,\n\tPROCESSING,\n\tDEFENSE_BROWSER,\n\tIGNORE_CLASSNAME,\n\tDUMMY_POSITION,\n\tIS_IOS,\n\tDEFAULT_OPTIONS,\n} from \"./consts\";\nimport Infinite from \"./Infinite\";\nimport { toArray, $, outerHeight, outerWidth, assign, resetSize, hasClass, addClass } from \"./utils\";\nimport {\n\tIJQuery, ILayout,\n\tCursorType, StyleType,\n\tIInfiniteGridItem,\n\tIInfiniteGridGroup, IInfiniteGridStatus, IItem, IArrayFormat, IInfiniteGridOptions\n} from \"./types\";\nimport RenderManager from \"./RenderManager\";\nimport Watcher from \"./Watcher\";\n\n// IE8\n// https://stackoverflow.com/questions/43216659/babel-ie8-inherit-issue-with-object-create\n/* eslint-disable */\n// if (typeof Object.create !== \"function\") {\n//   // tslint:disable\n//   Object.create = (o: any, properties: any) => {\n//     if (typeof o !== \"object\" && typeof o !== \"function\") {\n//       throw new TypeError(\"Object prototype may only be an Object: \" + o);\n//     } else if (o === null) {\n//       throw new Error(\"This browser's implementation of Object.create is a shim and doesn't support 'null' as the first argument.\");\n//     }\n//     function F() { }\n//     F.prototype = o;\n//     return new F();\n//   };\n//   // tslint:enable\n// }\n/* eslint-enable */\n\n/**\n * A module used to arrange card elements including content infinitely according to layout type. With this module, you can implement various layouts composed of different card elements whose sizes vary. It guarantees performance by maintaining the number of DOMs the module is handling under any circumstance\n * @ko 콘텐츠가 있는 카드 엘리먼트를 레이아웃 타입에 따라 무한으로 배치하는 모듈. 다양한 크기의 카드 엘리먼트를 다양한 레이아웃으로 배치할 수 있다. 카드 엘리먼트의 개수가 계속 늘어나도 모듈이 처리하는 DOM의 개수를 일정하게 유지해 최적의 성능을 보장한다\n * @alias eg.InfiniteGrid\n * @extends eg.Component\n *\n * @example\n```\n<ul id=\"grid\">\n  <li class=\"card\">\n    <div>test1</div>\n  </li>\n  <li class=\"card\">\n    <div>test2</div>\n  </li>\n  <li class=\"card\">\n    <div>test3</div>\n  </li>\n  <li class=\"card\">\n    <div>test4</div>\n  </li>\n  <li class=\"card\">\n    <div>test5</div>\n  </li>\n  <li class=\"card\">\n    <div>test6</div>\n  </li>\n</ul>\n<script>\nvar some = new eg.InfiniteGrid(\"#grid\").on(\"layoutComplete\", function(e) {\n  // ...\n});\n\n// If you already have items in the container, call \"layout\" method.\nsome.layout();\n</script>\n```\n *\n * @support {\"ie\": \"8+\", \"ch\" : \"latest\", \"ff\" : \"latest\",  \"sf\" : \"latest\", \"edge\" : \"latest\", \"ios\" : \"7+\", \"an\" : \"2.1+ (except 3.x)\"}\n **/\nclass InfiniteGrid extends Component {\n\t/**\n\t * Version info string\n\t * @ko 버전정보 문자열\n\t * @name VERSION\n\t * @static\n\t * @type {String}\n\t * @example\n\t * eg.InfiniteGrid.VERSION;  // ex) 3.3.3\n\t * @memberof eg.InfiniteGrid\n\t */\n\tpublic static VERSION = \"#__VERSION__#\";\n\n\tpublic options: IInfiniteGridOptions;\n\tprivate _loadingBar: {\n\t\tappend?: HTMLElement,\n\t\tprepend?: HTMLElement,\n\t} = {};\n\tprivate _itemManager: ItemManager;\n\tprivate _renderer: DOMRenderer;\n\tprivate _renderManager: RenderManager;\n\tprivate _layout: ILayout;\n\tprivate _watcher: Watcher;\n\tprivate _infinite: Infinite;\n\tprivate _status: IInfiniteGridStatus[\"_status\"];\n\tprivate _requestGroups: IInfiniteGridGroup[] = [];\n\n\t/**\n\t * @param {HTMLElement|String|jQuery} element A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>\n\t * @param {Object} [options] The option object of the eg.InfiniteGrid module <ko>eg.InfiniteGrid 모듈의 옵션 객체</ko>\n\t * @param {String} [options.itemSelector] A selector to select card elements that make up the layout<ko>레이아웃을 구성하는 카드 엘리먼트를 선택할 선택자(selector)</ko>\n\t * @param {Boolean} [options.useRecycle=true] Indicates whether keep the number of DOMs is maintained. If the useRecycle value is 'true', keep the number of DOMs is maintained. If the useRecycle value is 'false', the number of DOMs will increase as card elements are added. <ko>DOM의 수를 유지할지 여부를 나타낸다. useRecycle 값이 'true'이면 DOM 개수를 일정하게 유지한다. useRecycle 값이 'false' 이면 카드 엘리먼트가 추가될수록 DOM 개수가 계속 증가한다.</ko>\n\t * @param {Boolean} [options.isOverflowScroll=false] Indicates whether overflow:scroll is applied<ko>overflow:scroll 적용여부를 결정한다.</ko>\n\t * @param {Boolean} [options.horizontal=false] Direction of the scroll movement (true: horizontal, false: vertical) <ko>스크롤 이동 방향 (true 가로방향, false 세로방향)</ko>\n\t * @param {Boolean} [options.useFit=true] The useFit option scrolls upwards so that no space is visible until an item is added <ko>위로 스크롤할 시 아이템을 추가하는 동안 보이는 빈 공간을 안보이게 한다.</ko>\n\t * @param {Boolean} [options.isEqualSize=false] Indicates whether sizes of all card elements are equal to one another. If sizes of card elements to be arranged are all equal and this option is set to \"true\", the performance of layout arrangement can be improved. <ko>카드 엘리먼트의 크기가 동일한지 여부. 배치될 카드 엘리먼트의 크기가 모두 동일할 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다</ko>\n\t * @param {Boolean} [options.isConstantSize=false] Indicates whether sizes of all card elements does not change, the performance of layout arrangement can be improved. <ko>모든 카드 엘리먼트의 크기가 불변일 때 이 옵션을 'true'로 설정하면 레이아웃 배치 성능을 높일 수 있다</ko>\n\t * @param {Number} [options.transitionDruation=0] Indicates how many seconds a transition effect takes to complete. <ko>트랜지션 효과를 완료하는데 걸리는 시간을 나타낸다.</ko>\n\t * @param {Number} [options.threshold=100] The threshold size of an event area where card elements are added to a layout.<ko>레이아웃에 카드 엘리먼트를 추가하는 이벤트가 발생하는 기준 영역의 크기.</ko>\n\t * @param {String} [options.attributePrefix=\"data-\"] The prefix to use element's data attribute.<ko>엘리먼트의 데이타 속성에 사용할 접두사.</ko>\n\t * @param {boolean} [options.renderExternal=false] Whether to use external rendering. It will delegate DOM manipulation and can synchronize the rendered state by calling `sync()` method. You can use this option to use in frameworks like React, Vue, Angular, which has its states and rendering methods.<ko>외부 렌더링을 사용할 지의 여부. 이 옵션을 사용시 렌더링을 외부에 위임할 수 있고, `sync()`를 호출하여 그 상태를 동기화할 수 있다. 이 옵션을 사용하여, React, Vue, Angular 등 자체적인 상태와 렌더링 방법을 갖는 프레임워크에 대응할 수 있다.</ko>\n\t */\n\tconstructor(element: HTMLElement | string | IJQuery, options?: Partial<IInfiniteGridOptions>) {\n\t\tsuper();\n\t\tassign(this.options = {\n\t\t\t...DEFAULT_OPTIONS,\n\t\t}, options);\n\t\tDEFENSE_BROWSER && (this.options.useFit = false);\n\t\tIS_ANDROID2 && (this.options.isOverflowScroll = false);\n\t\tthis._reset();\n\n\t\tconst {\n\t\t\tisOverflowScroll,\n\t\t\tisEqualSize,\n\t\t\tisConstantSize,\n\t\t\thorizontal,\n\t\t\tthreshold,\n\t\t\tuseRecycle,\n\t\t\tattributePrefix,\n\t\t} = this.options;\n\n\t\tthis._itemManager = new ItemManager();\n\t\tthis._renderer = new DOMRenderer(element, {\n\t\t\tisEqualSize,\n\t\t\tisConstantSize,\n\t\t\thorizontal,\n\t\t\tcontainer: isOverflowScroll,\n\t\t});\n\t\tthis._watcher = new Watcher(\n\t\t\tthis._renderer.view,\n\t\t\t{\n\t\t\t\tisOverflowScroll,\n\t\t\t\thorizontal,\n\t\t\t\tcontainer: this._renderer.container,\n\t\t\t\tresize: () => this._onResize(),\n\t\t\t\tcheck: param => this._onCheck(param),\n\t\t\t});\n\n\t\tthis._infinite = new Infinite(this._itemManager, {\n\t\t\tuseRecycle,\n\t\t\tthreshold,\n\t\t\tappend: param => this._requestAppend(param),\n\t\t\tprepend: param => this._requestPrepend(param),\n\t\t\trecycle: param => this._recycle([param]),\n\t\t});\n\n\t\tthis._renderManager = new RenderManager(\n\t\t\tthis._infinite,\n\t\t\tthis._itemManager,\n\t\t\tthis._renderer,\n\t\t\t{\n\t\t\t\tattributePrefix,\n\t\t\t\tisEqualSize,\n\t\t\t\tisConstantSize,\n\t\t\t\thorizontal,\n\t\t\t},\n\t\t);\n\t}\n\t/**\n\t * Adds a card element at the bottom of a layout. This method is available only if the isProcessing() method returns false.\n\t * @ko 카드 엘리먼트를 레이아웃 아래에 추가한다. isProcessing() 메서드의 반환값이 'false'일 때만 이 메서드를 사용할 수 있다\n\t * 이 메소드는 isProcessing()의 반환값이 false일 경우에만 사용 가능하다.\n\t * @param {Array|jQuery} elements Array of the card elements to be added <ko>추가할 카드 엘리먼트의 배열</ko>\n\t * @param {Number|String} [groupKey] The group key to be configured in a card element. It is automatically generated by default.\n\t * <ko>추가할 카드 엘리먼트에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * infinitegrid.append(\"&lt;div class='item'&gt;test1&lt;/div&gt;&lt;div class='item'&gt;test2&lt;/div&gt;\");\n\t * infinitegrid.append([\"&lt;div class='item'&gt;test1&lt;/div&gt;\", \"&lt;div class='item'&gt;test2&lt;/div&gt;\"]);\n\t * infinitegrid.append([HTMLElement1, HTMLElement2]);\n\t * infinitegrid.append(jQuery([\"&lt;div class='item'&gt;test1&lt;/div&gt;\", \"&lt;div class='item'&gt;test2&lt;/div&gt;\"]));\n\t */\n\tpublic append(elements: HTMLElement[] | IJQuery | string[] | string, groupKey?: string | number) {\n\t\tthis._layout && this._insert({\n\t\t\telements,\n\t\t\tisAppend: true,\n\t\t\tgroupKey,\n\t\t});\n\t\treturn this;\n\t}\n\t/**\n\t * Adds a card element at the top of a layout. This method is available only if the isProcessing() method returns false.\n\t * @ko 카드 엘리먼트를 레이아웃의 위에 추가한다. isProcessing() 메서드의 반환값이 'false'일 때만 이 메서드를 사용할 수 있다\n\t * @param {Array|jQuery} elements Array of the card elements to be added <ko>추가할 카드 엘리먼트 배열</ko>\n\t * @param {Number|String} [groupKey] The group key to be configured in a card element. It is automatically generated by default.\n\t * <ko>추가할 카드 엘리먼트에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * infinitegrid.prepend(\"&lt;div class='item'&gt;test1&lt;/div&gt;&lt;div class='item'&gt;test2&lt;/div&gt;\");\n\t * infinitegrid.prepend([\"&lt;div class='item'&gt;test1&lt;/div&gt;\", \"&lt;div class='item'&gt;test2&lt;/div&gt;\"]);\n\t * infinitegrid.prepend([HTMLElement1, HTMLElement2]);\n\t * infinitegrid.prepend(jQuery([\"&lt;div class='item'&gt;test1&lt;/div&gt;\", \"&lt;div class='item'&gt;test2&lt;/div&gt;\"]));\n\t */\n\tpublic prepend(elements: HTMLElement[] | IJQuery | string[] | string, groupKey?: string | number) {\n\t\tthis._layout && this._insert({\n\t\t\telements,\n\t\t\tisAppend: false,\n\t\t\tgroupKey,\n\t\t});\n\t\treturn this;\n\t}\n\t/**\n\t * Specifies the Layout class to use.\n\t * @ko 사용할 Layout 클래스를 지정한다.\n\t * @param {Class|Object} LayoutKlass The Layout class to use or an instance of a layout moudle<ko>사용할 Layout 클래스 또는 레이아웃 모듈의 인스턴스</ko>\n\t * @param {Object} options Options to apply to the Layout.<ko>Layout에 적용할 옵션</ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * infinitegrid.setLayout(eg.InfiniteGrid.GridLayout, {\n\t *  margin: 10,\n\t *  align: \"start\"\n\t * });\n\t * infinitegrid.setLayout(eg.InfiniteGrid.JustifiedLayout, {\n\t *  margin: 10,\n\t *  minSize: 100,\n\t *  maxSize: 200\n\t * });\n\t * infinitegrid.setLayout(eg.InfiniteGrid.SquareLayout, {\n\t *  margin: 10,\n\t *  column: 2\n\t * });\n\t * infinitegrid.setLayout(eg.InfiniteGrid.FrameLayout, {\n\t *  margin: 10,\n\t *  frame: [\n\t *   [1, 2],\n\t *   [4, 3],\n\t *  ]\n\t * });\n\t * infinitegrid.setLayout(eg.InfiniteGrid.PackingLayout, {\n\t *  margin: 10,\n\t *  aspectRatio: 1.5\n\t * });\n\t * var layout = new eg.InfiniteGrid.GridLayout({\n\t *   margin: 10,\n\t *  align: \"start\"\n\t * });\n\t * infinitegrid.setLayout(layout);\n\t */\n\tpublic setLayout(LayoutKlass: ILayout | (new (...args: any[]) => ILayout), options = {}) {\n\t\tconst { horizontal } = this.options;\n\n\t\tif (typeof LayoutKlass === \"function\") {\n\t\t\tthis._layout = new LayoutKlass(assign(options, {\n\t\t\t\thorizontal,\n\t\t\t}));\n\t\t} else {\n\t\t\tLayoutKlass.options.horizontal = horizontal;\n\t\t\tthis._layout = LayoutKlass;\n\t\t}\n\n\t\tthis._renderManager.setLayout(this._layout);\n\t\tthis._renderer.resize();\n\t\tthis._setSize(this._renderer.getViewportSize());\n\t\treturn this;\n\t}\n\t/**\n\t * Returns the layouted items.\n\t * @ko 레이아웃된 아이템들을 반환한다.\n\t * @param {Boolean} includeCached Indicates whether to include the cached items. <ko>캐싱된 아이템을 포함할지 여부를 나타낸다.</ko>\n\t * @returns List of items <ko>아이템의 목록</ko>\n\t */\n\tpublic getItems(includeCached = false): IInfiniteGridItem[] {\n\t\treturn includeCached ? this._itemManager.pluck(\"items\") : this._infinite.getVisibleItems();\n\t}\n\t/**\n\t * @param - Get items to render on screen.\n     * @ko 화면에 렌더될 아이템들 가져온다.\n     * @private\n\t * @param - The groups currently being added by request.<ko>요청에 의해 지금 추가중인 그룹들.</ko>\n\t * @return - The items to be rendered on screen. <ko>화면레 렌더될 아이템들.</ko>\n     */\n\tpublic getRenderingItems(): IInfiniteGridItem[] {\n\t\tconst items = this.getItems();\n\t\tconst itemKeys: { [key: string]: any } = {};\n\n\t\titems.forEach(item => {\n\t\t\titemKeys[item.itemKey!] = true;\n\t\t});\n\t\tconst nextVisisbleItems = ItemManager.pluck(this._requestGroups, \"items\").filter(item => {\n\t\t\tif (itemKeys[item.itemKey!]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\titemKeys[item.itemKey!] = true;\n\t\t\treturn true;\n\t\t});\n\n\t\treturn items.concat(nextVisisbleItems);\n\t}\n\t/**\n     * Synchronize info of items with info given by external rendering.\n     * @ko 외부 렌더링 방식에 의해 아이템의 정보들을 동기화한다.\n     * @private\n     * @param - all item infos to synchronize <ko>동기화할 전체 아이템 정보들.</ko>\n     */\n\tpublic beforeSync(items: IItem[]) {\n\t\treturn this._infinite.sync(items);\n\t}\n\t/**\n\t * Synchronize info of items with DOM info given by external rendering.\n\t * @ko 외부 렌더링 방식에 의해 입력받은 DOM의 정보와 현재 아이템 정보를 동기화 한다.\n\t * @private\n\t * @param - The DOM elements that are currently visible.<ko>현재 보여지고 있는 DOM 엘리먼트들.</ko>\n\t * @param - The groups currently being added by request.<ko>요청에 의해 지금 추가중인 그룹들.</ko>\n\t */\n\tpublic sync(elements: IArrayFormat<HTMLElement>) {\n\t\tconst itemManager = this._itemManager;\n\t\tconst infinite = this._infinite;\n\t\tconst items = this.getRenderingItems();\n\n\t\titems.forEach((item, i) => {\n\t\t\tconst isChange = item.el !== elements[i];\n\t\t\titem.el = elements[i];\n\n\t\t\tif (isChange) {\n\t\t\t\tDOMRenderer.renderItem(item, item.rect);\n\t\t\t}\n\t\t});\n\t\tif (this._isProcessing()) {\n\t\t\treturn;\n\t\t}\n\t\tconst newItems = items.filter(item => !item.orgSize || !item.orgSize.width);\n\n\t\tif (newItems.length) {\n\t\t\tthis._postLayout({\n\t\t\t\tfromCache: false,\n\t\t\t\tgroups: infinite.getVisibleData(),\n\t\t\t\tnewItems,\n\t\t\t\tisAppend: true,\n\t\t\t\tisTrusted: false,\n\t\t\t});\n\t\t} else {\n\t\t\tconst size = itemManager.size();\n\n\t\t\tif (!size) {\n\t\t\t\tthis._requestAppend({});\n\t\t\t} else if (infinite.getCursor(\"start\") < 0) {\n\t\t\t\tconst firstGroup = itemManager.getGroup(0);\n\n\t\t\t\tthis._postLayout({\n\t\t\t\t\tgroups: [firstGroup],\n\t\t\t\t\thasChildren: false,\n\t\t\t\t\tfromCache: false,\n\t\t\t\t\tisAppend: true,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis._infinite.scroll(this._watcher.getScrollPos());\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Rearranges a layout.\n\t * @ko 레이아웃을 다시 배치한다.\n\t * @param {Boolean} [isRelayout=true] Indicates whether a card element is being relayouted <ko>카드 엘리먼트 재배치 여부</ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t */\n\tpublic layout(isRelayout = true) {\n\t\tif (!this._layout) {\n\t\t\treturn this;\n\t\t}\n\t\tconst renderer = this._renderer;\n\t\tconst itemManager = this._itemManager;\n\t\tconst infinite = this._infinite;\n\t\tconst isResize = renderer.resize();\n\t\tconst items = this.getItems();\n\t\tconst { isEqualSize, isConstantSize, transitionDuration } = this.options;\n\t\tconst isLayoutAll = isRelayout && (isEqualSize || isConstantSize);\n\t\tconst size = itemManager.size();\n\n\t\tthis._watcher.resize();\n\n\t\tif (isRelayout) {\n\t\t\tif (isResize) {\n\t\t\t\tthis._setSize(renderer.getViewportSize());\n\t\t\t}\n\t\t}\n\t\t// check childElement\n\t\tif (!items.length) {\n\t\t\tconst children = toArray(renderer.container.children).filter(el => {\n\t\t\t\treturn el.className.indexOf(IGNORE_CLASSNAME) === -1;\n\t\t\t});\n\t\t\tconst hasChildren = children.length > 0;\n\n\t\t\tif (size) {\n\t\t\t\tconst firstGroup = itemManager.getGroup(0);\n\n\t\t\t\tif (hasChildren) {\n\t\t\t\t\tfirstGroup.items.forEach((item, i) => {\n\t\t\t\t\t\titem.el = children[i];\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t// has items, no visible items\n\t\t\t\tthis._postLayout({\n\t\t\t\t\tgroups: [firstGroup],\n\t\t\t\t\thasChildren,\n\t\t\t\t\tfromCache: false,\n\t\t\t\t\tisAppend: true,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// no items, no visible items\n\t\t\t\tif (hasChildren) {\n\t\t\t\t\tlet groupKey: string | null | undefined = children[0].getAttribute(\"data-groupkey\");\n\n\t\t\t\t\tif (typeof groupKey !== \"string\") {\n\t\t\t\t\t\tgroupKey = undefined;\n\t\t\t\t\t}\n\t\t\t\t\tthis._insert({\n\t\t\t\t\t\telements: children,\n\t\t\t\t\t\tisAppend: true,\n\t\t\t\t\t\thasChildren: true,\n\t\t\t\t\t\tgroupKey,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tif (renderer.getContainerSize()) {\n\t\t\t\t\t\trenderer.setContainerSize(0);\n\t\t\t\t\t}\n\t\t\t\t\tthis._requestAppend({});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\n\t\t// layout datas\n\t\tconst [startCursor, endCursor] = infinite.getCursors();\n\t\tconst data = isLayoutAll || !(isRelayout && isResize) ? itemManager.getGroups() :\n\t\t\titemManager.sliceGroups(startCursor, endCursor + 1);\n\n\t\t// LayoutManger interface\n\t\tthis._relayout(isRelayout, data, isResize ? items : []);\n\n\t\tif (isLayoutAll) {\n\t\t\tthis._fit();\n\t\t} else if (isRelayout && isResize) {\n\t\t\titemManager.clearOutlines(startCursor, endCursor);\n\t\t}\n\t\tDOMRenderer.renderItems(items, transitionDuration);\n\t\tisRelayout && this._watcher.setScrollPos();\n\t\tthis._onLayoutComplete({\n\t\t\titems,\n\t\t\tisAppend: true,\n\t\t\tfromCache: true,\n\t\t\tisTrusted: false,\n\t\t\tuseRecycle: false,\n\t\t\tisLayout: true,\n\t\t});\n\t\treturn this;\n\t}\n\t/**\n\t * Removes a item corresponding to an index on a grid layout.\n\t * @ko 그리드 레이아웃에서 인덱스에 해당하는 아이템 삭제한다.\n\t * @param - Index of group corresponding to item to remove <ko>삭제할 아이템에 해당하는 그룹의 인덱스</ko>\n\t * @param - Index of item to remove on group <ko>그룹에서 삭제할 아이템의 인덱스</ko>\n\t * @return {Object}  Removed items information <ko>삭제된 아이템들 정보</ko>\n\t */\n\tpublic removeByIndex(groupIndex: number, itemIndex: number, isLayout = true) {\n\t\tconst { items, group } = this._infinite.remove(groupIndex, itemIndex);\n\n\t\titems.forEach(item => {\n\t\t\tDOMRenderer.removeElement(item.el!);\n\t\t});\n\n\t\tif (items.length) {\n\t\t\tisLayout && this.layout(!!group);\n\n\t\t\treturn items;\n\t\t}\n\t\treturn [];\n\t}\n\t/**\n\t * Removes a item element on a grid layout.\n\t * @ko 그리드 레이아웃의 카드 엘리먼트를 삭제한다.\n\t * @param {HTMLElement} item element to be removed <ko>삭제될 아이템 엘리먼트</ko>\n\t * @return {Object}  Removed items information <ko>삭제된 아이템들 정보</ko>\n\t */\n\tpublic remove(element: HTMLElement, isLayout = true) {\n\t\tconst { groupIndex, itemIndex } = this._itemManager.indexesOfElement(element);\n\n\t\treturn this.removeByIndex(groupIndex, itemIndex, isLayout);\n\t}\n\t/**\n\t * Returns the list of group keys which belongs to card elements currently being maintained. You can use the append() or prepend() method to configure group keys so that multiple card elements can be managed at once. If you do not use these methods to configure group keys, groupkey is automatically generated.\n\t * @ko 현재 유지하고 있는 카드 엘리먼트의 그룹 키 목록을 반환한다. 여러 개의 카드 엘리먼트를 묶어서 관리할 수 있도록 append() 메서드나 prepend() 메서드에서 그룹 키를 지정할 수 있다. append() 메서드나 prepend() 메서드에서 그룹 키를 지정하지 않았다면 자동으로 그룹키가 생성된다.\n\t * @param {Boolean} includeCached Indicates whether to include the cached groups. <ko>캐싱된 그룹을 포함할지 여부를 나타낸다.</ko>\n\t * @return {Array} List of group keys <ko>그룹 키의 목록</ko>\n\t */\n\tpublic getGroupKeys(includeCached?: boolean) {\n\t\tconst data = includeCached ?\n\t\t\tthis._itemManager.getGroups() : this._infinite.getVisibleData();\n\n\t\treturn data.map(v => v.groupKey);\n\t}\n\t/**\n\t * Returns the current state of a module such as location information. You can use the setStatus() method to restore the information returned through a call to this method.\n\t * @ko 카드의 위치 정보 등 모듈의 현재 상태 정보를 반환한다. 이 메서드가 반환한 정보를 저장해 두었다가 setStatus() 메서드로 복원할 수 있다\n\t * @return {Object} State object of the eg.InfiniteGrid module<ko>eg.InfiniteGrid 모듈의 상태 객체</ko>\n\t */\n\tpublic getStatus(startKey?: string | number, endKey?: string | number): IInfiniteGridStatus {\n\t\treturn {\n\t\t\t_status: assign({}, this._status),\n\t\t\t_itemManager: this._itemManager.getStatus(startKey, endKey),\n\t\t\t_renderer: this._renderer.getStatus(),\n\t\t\t_watcher: this._watcher.getStatus(),\n\t\t\t_infinite: this._infinite.getStatus(startKey, endKey),\n\t\t};\n\t}\n\t/**\n\t * Sets the state of the eg.InfiniteGrid module with the information returned through a call to the getStatue() method.\n\t * @ko getStatue() 메서드가 저장한 정보로 eg.InfiniteGrid 모듈의 상태를 설정한다.\n\t * @param {Object} status State object of the eg.InfiniteGrid module <ko>eg.InfiniteGrid 모듈의 상태 객체</ko>\n\t * @param {boolean} [applyScrollPos=true] Checks whether to scroll<ko>스크롤의 위치를 복원할지 결정한다.</ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t */\n\tpublic setStatus(status: IInfiniteGridStatus, applyScrollPos = true, syncElements?: HTMLElement[]) {\n\t\tif (!status) {\n\t\t\treturn this;\n\t\t}\n\t\tconst { _status, _renderer, _itemManager, _watcher, _infinite } = status;\n\n\t\tif (!_status ||\n\t\t\t!_renderer || !_itemManager || !_watcher || !_infinite) {\n\t\t\treturn this;\n\t\t}\n\t\tconst renderExternal = this.options.renderExternal;\n\t\tconst items = this._itemManager;\n\t\tconst renderer = this._renderer;\n\t\tconst watcher = this._watcher;\n\t\tconst infinite = this._infinite;\n\n\t\twatcher.detachEvent();\n\t\tassign(this._status, _status);\n\t\tthis._status.processingStatus = IDLE;\n\t\titems.setStatus(_itemManager);\n\t\trenderer.setStatus(_renderer);\n\t\tinfinite.setStatus(_infinite);\n\n\t\tconst visibleItems = this.getItems();\n\t\tconst length = visibleItems.length;\n\n\t\tif (renderExternal) {\n\t\t\tvisibleItems.forEach((item, i) => {\n\t\t\t\titem.el = syncElements![i];\n\t\t\t});\n\t\t\tDOMRenderer.renderItems(visibleItems);\n\t\t} else {\n\t\t\trenderer.createAndInsert(visibleItems, true);\n\t\t}\n\t\tconst isReLayout = renderer.isNeededResize();\n\n\t\twatcher.setStatus(_watcher, applyScrollPos);\n\t\twatcher.attachEvent();\n\n\t\tconst { isConstantSize, isEqualSize } = this.options;\n\n\t\tif (!length) {\n\t\t\tthis._requestAppend({ cache: [] });\n\t\t} else if (isReLayout) {\n\t\t\trenderer.resize();\n\t\t\tthis._setSize(renderer.getViewportSize());\n\n\t\t\tif (isConstantSize) {\n\t\t\t\tthis.layout(true);\n\t\t\t} else {\n\t\t\t\tthis._itemManager.clearOutlines();\n\t\t\t\tthis._postLayout({\n\t\t\t\t\tfromCache: true,\n\t\t\t\t\tgroups: isEqualSize ? items.getGroups() : infinite.getVisibleData(),\n\t\t\t\t\titems: visibleItems,\n\t\t\t\t\tnewItems: visibleItems,\n\t\t\t\t\tisAppend: true,\n\t\t\t\t\tisTrusted: false,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tthis.layout(false);\n\t\t}\n\t\treturn this;\n\t}\n\t/**\n\t * Clears added card elements and data.\n\t * @ko 추가된 카드 엘리먼트와 데이터를 모두 지운다.\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t */\n\tpublic clear() {\n\t\tthis._itemManager.clear();\n\t\tthis._renderer.clear();\n\t\tthis._infinite.clear();\n\t\tthis._reset();\n\t\tthis._appendLoadingBar();\n\t\treturn this;\n\t}\n\t/**\n\t * Specifies the Loading Bar to use for append or prepend items.\n\t * @ko 아이템을 append 또는 prepend 하기 위해 사용할 로딩 바를 지정한다.\n\t * @param {String|Object} [userLoadingBar={}] The loading bar HTML markup or element or element selector <ko> 로딩 바 HTML 또는 element 또는 selector </ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t */\n\tpublic setLoadingBar(userLoadingBar: {\n\t\tappend?: string | HTMLElement,\n\t\tprepend?: string | HTMLElement,\n\t} | string = {}) {\n\t\tconst loadingBarObj: {\n\t\t\tappend?: string | HTMLElement,\n\t\t\tprepend?: string | HTMLElement,\n\t\t} = typeof userLoadingBar === \"object\" ? userLoadingBar : {\n\t\t\tappend: userLoadingBar,\n\t\t\tprepend: userLoadingBar,\n\t\t};\n\n\t\tthis._status.loadingSize = 0;\n\t\tthis._status.loadingStyle = {};\n\t\tconst loadingBar = this._loadingBar;\n\n\t\tlet isChangeLoadingBar = false;\n\n\t\tfor (const type in loadingBarObj) {\n\t\t\tconst loadingElement = $(loadingBarObj[type as \"append\" | \"prepend\"]!);\n\n\t\t\tif (loadingBar[type as \"append\" | \"prepend\"] !== loadingElement) {\n\t\t\t\tloadingBar[type as \"append\" | \"prepend\"] = loadingElement;\n\t\t\t\tisChangeLoadingBar = true;\n\t\t\t}\n\n\t\t\tif (!hasClass(loadingElement, IGNORE_CLASSNAME)) {\n\t\t\t\taddClass(loadingElement, IGNORE_CLASSNAME);\n\t\t\t}\n\t\t}\n\t\tif (isChangeLoadingBar) {\n\t\t\tthis._renderLoading();\n\t\t}\n\t\tthis._appendLoadingBar();\n\t\treturn this;\n\t}\n\t/**\n\t * Checks whether a card element or data is being added.\n\t * @ko 카드 엘리먼트 추가 또는 데이터 로딩이 진행 중인지 확인한다\n\t * @return {Boolean} Indicates whether a card element or data is being added <ko>카드 엘리먼트 추가 또는 데이터 로딩 진행 중 여부</ko>\n\t */\n\tpublic isProcessing() {\n\t\treturn this._isProcessing() || this.isLoading();\n\t}\n\t/**\n\t * Checks whether data is loading.\n\t * @ko 데이터 로딩 중인지 확인한다\n\t * @return {Boolean} Indicates whether data is loading <ko>데이터 로딩 진행 중 여부</ko>\n\t */\n\tpublic isLoading() {\n\t\treturn this._getLoadingStatus() > 0;\n\t}\n\t/**\n\t * Returns the element of loading bar.\n\t * @ko 로딩 바의 element를 반환한다.\n\t * @param {Boolean} [isAppend=currentLoadingBar|true] Checks whether the card element is added to the append () method. <ko>카드 엘리먼트가 append() 메서드로 추가 할 것인지 확인한다.</ko>\n\t * @return {Element} The element of loading bar. <ko>로딩 바의 element</ko>\n\t */\n\tpublic getLoadingBar(isAppend = this._getLoadingStatus() !== LOADING_PREPEND) {\n\t\treturn this._loadingBar[isAppend ? \"append\" : \"prepend\"];\n\t}\n\t/**\n\t * Start loading for append/prepend during loading data.\n\t * @ko 데이터가 로딩되는 동안 append/prepend하길 위해 로딩을 시작한다.\n\t * @param {Boolean} [isAppend=true] Checks whether the card element is added to the append () method. <ko>카드 엘리먼트가 append() 메서드로 추가 할 것인지 확인한다.</ko>\n\t * @param {Object} [userStyle = {display: \"block\"}] custom style to apply to this loading bar for start. <ko> 로딩 시작을 위한 로딩 바에 적용할 커스텀 스타일 </ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t */\n\tpublic startLoading(isAppend?: boolean, userStyle: StyleType = { display: \"block\" }) {\n\t\tif (this.isLoading()) {\n\t\t\treturn this;\n\t\t}\n\t\tconst type = isAppend ? \"append\" : \"prepend\";\n\n\t\tthis._process(isAppend ? LOADING_APPEND : LOADING_PREPEND);\n\t\tif (!this._loadingBar[type]) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst next = () => {\n\t\t\tthis._renderLoading(userStyle);\n\t\t\tthis._status.loadingStyle = userStyle;\n\t\t\tif (!isAppend) {\n\t\t\t\tthis._fit();\n\t\t\t} else {\n\t\t\t\tthis._setContainerSize(this._getEdgeValue(\"end\") + this._status.loadingSize);\n\t\t\t}\n\t\t};\n\t\tif (this.options.renderExternal) {\n\t\t\tthis.trigger(\"render\", {\n\t\t\t\tnext,\n\t\t\t});\n\t\t} else {\n\t\t\tnext();\n\t\t}\n\t\treturn this;\n\t}\n\t/**\n\t * End loading after startLoading() for append/prepend\n\t * @ko  append/prepend하길 위해 startLoading() 호출해선 걸었던 로딩을 끝낸다.\n\t * @param {Object} [userStyle = {display: \"none\"}] custom style to apply to this loading bar for end <ko> 로딩 시작을 위한 로딩 바에 적용할 커스텀 스타일 </ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t */\n\tpublic endLoading(userStyle: StyleType = { display: \"none\" }) {\n\t\tif (!this.isLoading()) {\n\t\t\treturn this;\n\t\t}\n\t\tconst isAppend = this._getLoadingStatus() === LOADING_APPEND;\n\t\tconst type = isAppend ? \"append\" : \"prepend\";\n\t\tconst el = this._loadingBar[type];\n\t\tconst status = this._status;\n\t\tconst size = status.loadingSize;\n\n\t\tthis._process(LOADING_APPEND | LOADING_PREPEND, false);\n\t\tstatus.loadingSize = 0;\n\t\tstatus.loadingStyle = {};\n\t\tif (el) {\n\t\t\tconst style: StyleType = assign({\n\t\t\t\t[this.options.horizontal ? \"left\" : \"top\"]: `${-size}px`,\n\t\t\t}, userStyle);\n\n\t\t\tfor (const property in style) {\n\t\t\t\tel.style[property as keyof StyleType] = style[property as keyof StyleType];\n\t\t\t}\n\t\t\tif (!isAppend) {\n\t\t\t\tthis._fitItems(size);\n\t\t\t} else {\n\t\t\t\tthis._setContainerSize(this._getEdgeValue(\"end\"));\n\t\t\t}\n\t\t\tif (this.options.renderExternal) {\n\t\t\t\tthis.trigger(\"render\", {\n\t\t\t\t\tnext: () => { },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (this.options.useRecycle && !this.isProcessing()) {\n\t\t\tthis._infinite.recycle(this._watcher.getScrollPos(), isAppend);\n\t\t}\n\t\treturn this;\n\t}\n\t/**\n\t * Retrieves the item via index or the element.\n\t * @ko index 또는 element를 통해 아이템을 가져온다.\n\t * @param {number | HTMLElement} [groupIndex=0] The element corresponding to item or the index of the group where the item is in position <ko> item에 해당하는 element 또는 해당 item이 있는 group의 index</ko>\n\t * @param {number} [itemIndex] If groupIndex is used, the index of the item in the group <ko> groupIndex를 사용할 경우 해당 group에 있는 Item의 index </ko>\n\t * @return The item containing the content, size and position,etc<ko>content, size, position 등이 담겨있는 item 정보</ko>\n\t * @example\n\n\t ig.getItem(0, 0);\n\t ig.getItem(element);\n\n\t {\n\t  el: HTMLElement,\n\t  content: \"<div>...</div>\",\n\t  size: {width: ..., height: ...},\n\t  rect: {top: ..., left: ..., width: ..., height: ...},\n\t }\n\t */\n\tpublic getItem(groupIndex: HTMLElement | number = 0, itemIndex?: number): IInfiniteGridItem | undefined {\n\t\tif (typeof groupIndex === \"object\") {\n\t\t\tif (!groupIndex) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst items = this.getItems();\n\t\t\tconst length = items.length;\n\n\t\t\tfor (let i = 0; i < length; ++i) {\n\t\t\t\tif (items[i].el === groupIndex) {\n\t\t\t\t\treturn items[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\tconst group = this._itemManager.getGroup(groupIndex);\n\n\t\t\treturn group && group.items[itemIndex || 0];\n\t\t}\n\t}\n\t/**\n\t * Updates the item via index or the element.\n\t * @ko index 또는 element를 통해 아이템을 업데이트한다.\n\t * @param {number | HTMLElement} [groupIndex=0] The element corresponding to item or the index of the group where the item is in position <ko> item에 해당하는 element 또는 해당 item이 있는 group의 index</ko>\n\t * @param {number} [itemIndex] If groupIndex is used, the index of the item in the group <ko> groupIndex를 사용할 경우 해당 group에 있는 Item의 index </ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\telement.innerHTML = \"2\";\n\telement.style.height = \"400px\";\n\tig.updateItem(element);\n\tig.updateItem(0, 0);\n\t */\n\tpublic updateItem(groupIndex?: number, itemIndex?: number) {\n\t\tconst item = this.getItem(groupIndex, itemIndex);\n\n\t\tthis._updateItem(item) && this.layout(false);\n\n\t\treturn this;\n\t}\n\t/**\n\t * Update the currently displayed items.\n\t * @ko 현재보여주는 아이템들을 업데이트한다.\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\telement.innerHTML = \"2\";\n\telement.style.height = \"400px\";\n\n\telement2.innerHTML = \"2\";\n\telement2.style.height = \"400px\";\n\n\tig.updateItems();\n\t */\n\tpublic updateItems() {\n\t\tthis.getItems().forEach(item => {\n\t\t\tthis._updateItem(item);\n\t\t});\n\t\tthis.layout(false);\n\t\treturn this;\n\t}\n\t/**\n\t * Move to some group or item position.\n\t * @ko 해당하는 그룹 또는 아이템의 위치로 이동한다.\n\t * @param {Number} [index] group's index <ko> 그룹의 index</ko>\n\t * @param {Number} [itemIndex=-1] item's index <ko> 그룹의 index</ko>\n\t * @return {eg.InfiniteGrid} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t */\n\tpublic moveTo(index: number, itemIndex = 0) {\n\t\tif (this.isProcessing()) {\n\t\t\treturn this;\n\t\t}\n\t\tconst data = this._itemManager.getGroup(index);\n\n\t\tif (!data) {\n\t\t\treturn this;\n\t\t}\n\t\tconst infinite = this._infinite;\n\t\tconst outlines = data.outlines;\n\t\tconst items = data.items;\n\t\tconst item = items[itemIndex];\n\t\tconst isResize = outlines.start && (outlines.start.length === 0);\n\t\tconst [startCursor, endCursor] = infinite.getCursors();\n\t\tconst isInCursor = startCursor <= index && index <= endCursor;\n\t\tconst { useRecycle, horizontal } = this.options;\n\n\t\tif (isInCursor || !useRecycle || !isResize) {\n\t\t\tlet pos = item ? item.rect[horizontal ? \"left\" : \"top\"] : Math.max(...outlines.start);\n\t\t\tconst fit = Math.min(...outlines.start);\n\n\t\t\tif (fit < 0) {\n\t\t\t\t// base < 0\n\t\t\t\tthis._fitItems(fit, 0);\n\t\t\t\tpos -= fit;\n\t\t\t}\n\t\t\tconst isAppend = index > startCursor;\n\n\t\t\tif (isInCursor || isAppend) {\n\t\t\t\tthis._scrollTo(pos);\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\tthis._postLayout({\n\t\t\t\tfromCache: true,\n\t\t\t\tgroups: [data],\n\t\t\t\titems,\n\t\t\t\tnewItems: [],\n\t\t\t\tisAppend,\n\t\t\t\tisTrusted: false,\n\t\t\t})!.on(\"renderComplete\", ({ start, end }) => {\n\t\t\t\tconst itemManager = this._itemManager;\n\n\t\t\t\tif (!itemManager) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst scrollPos = items[itemIndex].rect[horizontal ? \"left\" : \"top\"];\n\n\t\t\t\tif (!isInCursor) {\n\t\t\t\t\titemManager.clearOutlines(start, end);\n\t\t\t\t}\n\t\t\t\tthis._scrollTo(scrollPos);\n\t\t\t\tthis._setScrollPos(scrollPos);\n\t\t\t});\n\t\t\treturn this;\n\t\t} else {\n\t\t\tconst isAppend = index > endCursor || index < startCursor - 1;\n\n\t\t\tthis._postCache({\n\t\t\t\tisAppend,\n\t\t\t\tcache: [data],\n\t\t\t\tisTrusted: false,\n\t\t\t})!.on(\"renderComplete\", ({ start, end }) => {\n\t\t\t\tconst itemManager = this._itemManager;\n\n\t\t\t\tif (!itemManager) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst pos = items[itemIndex].rect[horizontal ? \"left\" : \"top\"];\n\n\t\t\t\titemManager.clearOutlines(start, end);\n\t\t\t\tthis._scrollTo(pos);\n\t\t\t\tthis._setScrollPos(pos);\n\t\t\t});\n\t\t}\n\t\treturn this;\n\t}\n\t/**\n   * Destroys elements, properties, and events used on a grid layout.\n   * @ko 그리드 레이아웃에 사용한 엘리먼트와 속성, 이벤트를 해제한다\n   */\n\tpublic destroy() {\n\t\tthis._infinite.clear();\n\t\tthis._watcher.destroy();\n\t\tthis._reset();\n\t\tthis._itemManager.clear();\n\t\tthis._renderer.destroy();\n\t}\n\tprivate _relayout(isRelayout: boolean, groups: IInfiniteGridGroup[], items: IInfiniteGridItem[]) {\n\t\tconst renderer = this._renderer;\n\t\tconst { isEqualSize, isConstantSize } = renderer.options;\n\t\tconst layoutGroups = groups.filter(group => {\n\t\t\tconst item = group.items[0];\n\n\t\t\treturn item.orgSize && item.rect.top > DUMMY_POSITION / 10;\n\t\t});\n\n\t\tif (!layoutGroups.length) {\n\t\t\treturn [];\n\t\t}\n\t\tlet outline = layoutGroups[0].outlines.start;\n\n\t\tif (isRelayout) {\n\t\t\toutline = [outline.length ? Math.min(...outline) : 0];\n\t\t\tif (!isConstantSize && items.length) {\n\t\t\t\trenderer.updateSize(items);\n\n\t\t\t\t// update invisible items' size\n\t\t\t\tif (isEqualSize && items[0].size) {\n\t\t\t\t\tItemManager.pluck(layoutGroups, \"items\").forEach(item => {\n\t\t\t\t\t\titem.size = assign({}, items[0].size);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis._layout.layout(layoutGroups, outline);\n\t}\n\tprivate _setContainerSize(size: number) {\n\t\tthis._renderer.setContainerSize(Math.max(this._itemManager.getMaxEdgeValue(), size));\n\t}\n\tprivate _appendLoadingBar() {\n\t\tif (!this.options.renderExternal) {\n\t\t\tconst loadingBar = this._loadingBar;\n\t\t\tconst container = this._renderer.container;\n\n\t\t\tfor (const type in loadingBar) {\n\t\t\t\tcontainer.appendChild(loadingBar[type as \"append\" | \"prepend\"]!);\n\t\t\t}\n\t\t}\n\t}\n\tprivate _setSize(size: number) {\n\t\tthis._infinite.setSize(this._renderer.getViewSize());\n\t\tthis._layout.setSize(size);\n\t}\n\tprivate _fitItems(base: number, margin = 0) {\n\t\tbase > 0 && this._watcher.scrollBy(-base);\n\t\tthis._itemManager.fit(base, this.options.horizontal);\n\t\tDOMRenderer.renderItems(this.getItems());\n\t\tthis._setContainerSize(this._getEdgeValue(\"end\") || margin);\n\t\tbase < 0 && this._watcher.scrollBy(-base);\n\t}\n\t// called by visible\n\tprivate _fit(useFit = this.options.useFit) {\n\t\tlet base = this._getEdgeValue(\"start\");\n\t\tconst margin = (this._getLoadingStatus() === LOADING_PREPEND && this._status.loadingSize) || 0;\n\t\tconst { isConstantSize, isEqualSize, useRecycle } = this.options;\n\n\t\tif (!useRecycle || !useFit || isConstantSize || isEqualSize) {\n\t\t\tif (base < margin) {\n\t\t\t\tthis._fitItems(base - margin, margin);\n\t\t\t}\n\t\t\tbase = 0;\n\t\t} else if (base !== 0 || margin) {\n\t\t\tthis._fitItems(base - margin, margin);\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t\tthis.isLoading() && this._renderLoading();\n\t\treturn base;\n\t}\n\tprivate _getEdgeValue(cursor: CursorType) {\n\t\treturn this._infinite.getEdgeValue(cursor);\n\t}\n\tprivate _isProcessing() {\n\t\treturn (this._status.processingStatus & PROCESSING) > 0;\n\t}\n\tprivate _getLoadingStatus() {\n\t\treturn this._status.processingStatus & (LOADING_APPEND | LOADING_PREPEND);\n\t}\n\tprivate _process(status: number, isAdd = true) {\n\t\tif (isAdd) {\n\t\t\tthis._status.processingStatus |= status;\n\t\t} else {\n\t\t\tthis._status.processingStatus -= this._status.processingStatus & status;\n\t\t}\n\t}\n\tprivate _insert({\n\t\telements,\n\t\tisAppend,\n\t\thasChildren,\n\t\tgroupKey = new Date().getTime() + Math.floor(Math.random() * 1000),\n\t}: {\n\t\telements: string | string[] | HTMLElement[] | IJQuery,\n\t\tisAppend?: boolean,\n\t\thasChildren?: boolean,\n\t\tgroupKey?: string | number,\n\t}) {\n\t\tif (this._isProcessing() || elements.length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tconst items = ItemManager.toItems($(elements, true), groupKey);\n\n\t\tthis._insertItems({\n\t\t\titems,\n\t\t\tisAppend,\n\t\t\thasChildren,\n\t\t\tgroupKey,\n\t\t});\n\t}\n\tprivate _insertItems({\n\t\titems,\n\t\tisAppend,\n\t\thasChildren,\n\t\tgroupKey = new Date().getTime() + Math.floor(Math.random() * 1000),\n\t}: {\n\t\titems: IInfiniteGridItem[],\n\t\tisAppend?: boolean,\n\t\thasChildren?: boolean,\n\t\tgroupKey?: string | number,\n\t}) {\n\t\tif (!items.length) {\n\t\t\treturn;\n\t\t}\n\t\tconst group = this._itemManager[isAppend ? \"appendGroup\" : \"prependGroup\"]({\n\t\t\tgroupKey,\n\t\t\titems,\n\t\t})!;\n\t\tif (!isAppend) {\n\t\t\tconst infinite = this._infinite;\n\t\t\tconst [startCursor, endCursor] = infinite.getCursors();\n\n\t\t\tinfinite.setCursor(\"start\", startCursor + 1);\n\t\t\tinfinite.setCursor(\"end\", endCursor + 1);\n\t\t}\n\t\tthis._postLayout({\n\t\t\tfromCache: false,\n\t\t\tgroups: [group],\n\t\t\titems: group.items,\n\t\t\tnewItems: group.items,\n\t\t\tisAppend,\n\t\t\thasChildren,\n\t\t\tisTrusted: false,\n\t\t});\n\t}\n\t// add items, and remove items for recycling\n\tprivate _recycle(ranges: Array<{ start: number, end: number }>) {\n\t\tconst { useRecycle, renderExternal } = this.options;\n\t\tif (!useRecycle) {\n\t\t\treturn false;\n\t\t}\n\t\tlet isRecycle = false;\n\t\tranges.forEach(({ start, end }) => {\n\t\t\tif (start === -1 || end === -1 || end < start) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst items = this._itemManager.pluck(\"items\", start, end);\n\n\t\t\tisRecycle = isRecycle || items.some(item => item.mounted);\n\t\t\titems.forEach(item => {\n\t\t\t\titem.mounted = false;\n\t\t\t});\n\t\t\tif (!renderExternal) {\n\t\t\t\tDOMRenderer.removeItems(items);\n\t\t\t}\n\t\t});\n\t\tif (isRecycle) {\n\t\t\tthis._requestGroups = [];\n\t\t\tthis.trigger(\"render\", {\n\t\t\t\tnext: () => { },\n\t\t\t});\n\t\t}\n\t\treturn isRecycle;\n\t}\n\tprivate _renderLoading(userStyle = this._status.loadingStyle) {\n\t\tif (!this.isLoading()) {\n\t\t\treturn;\n\t\t}\n\t\tconst isAppend = this._getLoadingStatus() === LOADING_APPEND;\n\t\tconst el = this._loadingBar[isAppend ? \"append\" : \"prepend\"];\n\n\t\tif (!el) {\n\t\t\treturn;\n\t\t}\n\t\tconst style = assign({\n\t\t\tposition: \"absolute\",\n\t\t}, userStyle);\n\n\t\tfor (const property in style) {\n\t\t\tel.style[property as keyof StyleType] = style[property as keyof StyleType];\n\t\t}\n\t\tthis._status.loadingSize = this.options.horizontal ? outerWidth(el) : outerHeight(el);\n\t\tconst posName = this.options.horizontal ? \"left\" : \"top\";\n\n\t\tif (!(posName in style)) {\n\t\t\tconst pos = isAppend ? this._getEdgeValue(\"end\") : this._getEdgeValue(\"start\") - this._status.loadingSize;\n\n\t\t\tel.style[posName] = `${pos}px`;\n\t\t}\n\t}\n\tprivate _updateItem(item?: IInfiniteGridItem) {\n\t\tif (item && item.el) {\n\t\t\titem.content = item.el.outerHTML;\n\n\t\t\t!this.options.isEqualSize && resetSize(item);\n\t\t\tthis._renderer.updateSize([item]);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tprivate _setScrollPos(pos: number) {\n\t\tthis._watcher.setScrollPos(this._watcher.getContainerOffset() + pos);\n\t}\n\tprivate _scrollTo(pos: number) {\n\t\tthis._watcher.scrollTo(this._watcher.getContainerOffset() + pos);\n\t}\n\tprivate _postCache({\n\t\tcache,\n\t\tisAppend,\n\t\tisTrusted = true,\n\t}: {\n\t\tcache: IInfiniteGridGroup[],\n\t\tisAppend?: boolean,\n\t\tisTrusted?: boolean,\n\t}) {\n\t\tconst { isConstantSize } = this.options;\n\t\tconst items = ItemManager.pluck(cache, \"items\");\n\t\tlet fromCache = true;\n\t\tconst newItems = items.filter(item => {\n\t\t\tif (!item.orgSize || !item.orgSize.width) {\n\t\t\t\tfromCache = false;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn !isConstantSize && item.rect.top < DUMMY_POSITION / 10;\n\t\t});\n\n\t\treturn this._postLayout({\n\t\t\tfromCache,\n\t\t\tgroups: cache,\n\t\t\titems,\n\t\t\tnewItems,\n\t\t\tisAppend,\n\t\t\tisTrusted,\n\t\t});\n\t}\n\tprivate _postLayout({\n\t\tfromCache,\n\t\tgroups,\n\t\titems = ItemManager.pluck(groups, \"items\"),\n\t\tnewItems,\n\t\tisAppend,\n\t\thasChildren,\n\t\tisTrusted,\n\t}: {\n\t\tfromCache: boolean,\n\t\tgroups: IInfiniteGridGroup[],\n\t\titems?: IInfiniteGridItem[],\n\t\tnewItems?: IInfiniteGridItem[],\n\t\tisAppend?: boolean,\n\t\thasChildren?: boolean,\n\t\tisTrusted?: boolean,\n\t}) {\n\t\tthis._process(PROCESSING);\n\n\t\tif (!groups.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst renderExternal = this.options.renderExternal;\n\t\tconst renderer = this._renderer;\n\t\tconst callbackComponent = new Component();\n\n\t\tconst next = () => {\n\t\t\titems.forEach(item => {\n\t\t\t\titem.mounted = true;\n\t\t\t});\n\t\t\tthis._renderManager\n\t\t\t\t.render(callbackComponent, groups, newItems, isAppend)\n\t\t\t\t.on(\"renderComplete\", ({ start, end }) => {\n\t\t\t\t\tthis._setCursor(start, end);\n\t\t\t\t}).on(\"imageError\", e => {\n\t\t\t\t\t/**\n\t\t\t\t\t * This event is fired when an error occurs in the image.\n\t\t\t\t\t * @ko 이미지 로드에 에러가 날 때 발생하는 이벤트.\n\t\t\t\t\t * @event eg.InfiniteGrid#imageError\n\t\t\t\t\t * @param {eg.InfiniteGrid.IErrorCallbackOptions} e The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>\n\t\t\t\t\t * @example\n\t\t\t\t\tig.on(\"imageError\", e => {\n\t\t\t\t\te.remove();\n\t\t\t\t\te.removeItem();\n\t\t\t\t\te.replace(\"http://...jpg\");\n\t\t\t\t\te.replace(imageElement);\n\t\t\t\t\te.replaceItem(\"item html\");\n\t\t\t\t\t});\n\t\t\t\t\t*/\n\t\t\t\t\tthis.trigger(\"imageError\", assign(e, { element: e.item.el }));\n\t\t\t\t}).on(\"layoutComplete\", ({\n\t\t\t\t\titems: layoutItems,\n\t\t\t\t}) => {\n\t\t\t\t\tthis._process(PROCESSING, false);\n\t\t\t\t\tthis._onLayoutComplete({\n\t\t\t\t\t\titems: layoutItems,\n\t\t\t\t\t\tisAppend,\n\t\t\t\t\t\tfromCache,\n\t\t\t\t\t\tisTrusted,\n\t\t\t\t\t\tuseRecycle: false,\n\t\t\t\t\t});\n\t\t\t\t}).on(\"finish\", ({ remove, layout }) => {\n\t\t\t\t\tremove.forEach(el => this.remove(el, false));\n\t\t\t\t\tif (layout) {\n\t\t\t\t\t\tthis.layout(false);\n\t\t\t\t\t} else if (!this.isProcessing() && this.options.useRecycle) {\n\t\t\t\t\t\tconst scroller = this._watcher;\n\t\t\t\t\t\tconst scrollPos = scroller.getScrollPos();\n\n\t\t\t\t\t\tthis._infinite.recycle(scrollPos, isAppend);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t};\n\n\t\tif (!hasChildren) {\n\t\t\tif (renderExternal) {\n\t\t\t\tif (items.every(item => item.mounted)) {\n\t\t\t\t\tnext();\n\t\t\t\t} else {\n\t\t\t\t\tthis._requestGroups = groups;\n\t\t\t\t\tthis.trigger(\"render\", {\n\t\t\t\t\t\tnext: () => {\n\t\t\t\t\t\t\t!hasChildren && DOMRenderer.renderItems(items);\n\t\t\t\t\t\t\tnext();\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn callbackComponent;\n\t\t\t} else {\n\t\t\t\t// If container has children, it does not render first.\n\t\t\t\trenderer.createAndInsert(items, isAppend);\n\t\t\t}\n\t\t}\n\t\tnext();\n\n\t\treturn callbackComponent;\n\t}\n\t// called by visible\n\tprivate _requestAppend({ cache }: { cache?: IInfiniteGridGroup[] }) {\n\t\tif (this._isProcessing()) {\n\t\t\treturn;\n\t\t}\n\t\tif (cache && cache.length) {\n\t\t\tthis._postCache({ cache, isAppend: true });\n\t\t} else {\n\t\t\t/**\n\t\t\t * This event is fired when a card element must be added at the bottom or right of a layout because there is no card to be displayed on screen when a user scrolls near bottom or right.\n\t\t\t * @ko 카드 엘리먼트가 레이아웃의 아래나 오른쪽에 추가돼야 할 때 발생하는 이벤트. 사용자가 아래나 오른쪽으로 스크롤해서 화면에 표시될 카드가 없을 때 발생한다\n\t\t\t * @event eg.InfiniteGrid#append\n\t\t\t * @param {Object} param The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>\n\t\t\t * @param {String|Number} groupKey The group key of the first group visible on the screen <ko>화면에 보여지는 마지막 그룹의 그룹키</ko>\n\t\t\t * @param {Boolean} param.isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>\n\t\t\t * @param {Function} param.startLoading Start loading for append loading data. <ko> 뒷쪽에 추가되는 데이터 로딩을 시작한다. </ko>\n\t\t\t * @param {Object} param.startLoading.userStyle The custom style to apply to this loading bar for start. <ko> 로딩을 시작할 때 로딩 바에 적용될 사용자 스타일 </ko>\n\t\t\t * @param {Function} param.endLoading End loading after startLoading() for append/prepend loading data. <ko>데이터 로딩을 위해 append/prepend startLoading() 호출 이후 로딩을 끝낸다.</ko>\n\t\t\t * @param {Object} param.endLoading.userStyle The custom style to apply to this loading bar for start. <ko> 로딩이 끝날 때 로딩 바에 적용될 사용자 스타일 </ko>\n\t\t\t */\n\t\t\tthis.trigger(\"append\", {\n\t\t\t\tisTrusted: true,\n\t\t\t\tgroupKey: this.getGroupKeys().pop() || \"\",\n\t\t\t\tstartLoading: (userStyle: StyleType) => {\n\t\t\t\t\tthis.startLoading(true, userStyle);\n\t\t\t\t},\n\t\t\t\tendLoading: (userStyle: StyleType) => {\n\t\t\t\t\tthis.endLoading(userStyle);\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\t// called by visible\n\tprivate _requestPrepend({ cache }: { cache?: IInfiniteGridGroup[] }) {\n\t\tthis._fit(this.options.useFit || !cache || !cache.length);\n\t\tif (this._isProcessing()) {\n\t\t\treturn;\n\t\t}\n\t\tif (cache && cache.length) {\n\t\t\tthis._postCache({ cache, isAppend: false });\n\t\t} else {\n\t\t\t/**\n\t\t\t * This event is fired when a card element must be added at the top or left of a layout because there is no card to be displayed on screen when a user scrolls near top or left.\n\t\t\t * @ko 카드가 레이아웃의 위나 왼쪽에 추가돼야 할 때 발생하는 이벤트. 사용자가 위나 왼쪽으로 스크롤해서 화면에 표시될 카드가 없을 때 발생한다.\n\t\t\t * @event eg.InfiniteGrid#prepend\n\t\t\t * @param {Object} param The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>\n\t\t\t * @param {String|Number} groupKey The group key of the first group visible on the screen <ko>화면에 보여지는 첫번째 그룹의 그룹키</ko>\n\t\t\t * @param {Boolean} param.isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>\n\t\t\t * @param {Function} param.startLoading Start loading for prepend loading data. <ko> 앞쪽에 추가되는 데이터 로딩을 시작한다. </ko>\n\t\t\t * @param {Object} param.startLoading.userStyle The custom style to apply to this loading bar for start. <ko> 로딩을 시작할 때 로딩 바에 적용될 사용자 스타일 </ko>\n\t\t\t * @param {Function} param.endLoading End loading after startLoading() for append/prepend loading data. <ko>데이터 로딩을 위해 append/prepend startLoading() 호출 이후 로딩을 끝낸다.</ko>\n\t\t\t * @param {Object} param.endLoading.userStyle The custom style to apply to this loading bar for start. <ko> 로딩이 끝날 때 로딩 바에 적용될 사용자 스타일 </ko>\n\t\t\t */\n\t\t\tthis.trigger(\"prepend\", {\n\t\t\t\tisTrusted: true,\n\t\t\t\tgroupKey: this.getGroupKeys().shift(),\n\t\t\t\tstartLoading: (userStyle: StyleType) => {\n\t\t\t\t\tthis.startLoading(false, userStyle);\n\t\t\t\t},\n\t\t\t\tendLoading: (userStyle: StyleType) => {\n\t\t\t\t\tthis.endLoading(userStyle);\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\tprivate _onResize() {\n\t\tthis.layout(true);\n\t}\n\tprivate _setCursor(start: number, end: number) {\n\t\tconst infinite = this._infinite;\n\t\tconst [startCursor, endCursor] = infinite.getCursors();\n\t\tinfinite.setCursor(\"start\", start);\n\t\tinfinite.setCursor(\"end\", end);\n\n\t\tconst isRecycle = this._recycle([\n\t\t\t{ start: startCursor, end: start - 1 },\n\t\t\t{ start: end + 1, end: endCursor },\n\t\t]);\n\t\tif (!isRecycle) {\n\t\t\tthis._requestGroups = [];\n\t\t\tthis.trigger(\"render\", {\n\t\t\t\tnext: () => { },\n\t\t\t});\n\t\t}\n\t}\n\tprivate _onCheck({\n\t\tisForward,\n\t\tscrollPos,\n\t\thorizontal,\n\t\torgScrollPos,\n\t}: {\n\t\tisForward: boolean,\n\t\tscrollPos: number,\n\t\thorizontal: boolean,\n\t\torgScrollPos: number,\n\t}) {\n\t\t/**\n\t\t * This event is fired when the user scrolls.\n\t\t * @ko 사용자가 스크롤 할 경우 발생하는 이벤트.\n\t\t * @event eg.InfiniteGrid#change\n\t\t * @param {Object} param The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>\n\t\t * @param {Boolean} param.isForward Indicates whether the scroll progression direction is forward or backword. <ko>스크롤 진행방향이 앞쪽으로 진행하는 지, 뒤쪽으로 진행하는지를 나타낸다.</ko>\n\t\t * @param {Number} param.scrollPos Current scroll position value relative to the infiniteGrid container element. <ko>infiniteGrid 컨테이너 엘리먼트 기준의 현재 스크롤 위치값</ko>\n\t\t * @param {Boolean} param.orgScrollPos Current position of the scroll <ko>현재 스크롤 위치값</ko>\n\t\t * @param {Boolean} param.isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>\n\t\t * @param {Boolean} options.horizontal Direction of the scroll movement (true: horizontal, false: vertical) <ko>스크롤 이동 방향 (true 가로방향, false 세로방향</ko>\n\t\t */\n\t\tthis.trigger(\"change\", {\n\t\t\tisForward,\n\t\t\thorizontal,\n\t\t\tscrollPos,\n\t\t\torgScrollPos,\n\t\t});\n\t\tthis._infinite.scroll(scrollPos);\n\t}\n\tprivate _onLayoutComplete({\n\t\titems,\n\t\tisAppend,\n\t\tisTrusted = false,\n\t\tuseRecycle = this.options.useRecycle,\n\t\tfromCache = false,\n\t\tisLayout = false,\n\t}: {\n\t\titems: IInfiniteGridItem[],\n\t\tisAppend?: boolean,\n\t\tisTrusted?: boolean,\n\t\tuseRecycle: boolean,\n\t\tfromCache: boolean,\n\t\tisLayout?: boolean,\n\t}) {\n\t\tconst viewSize = this._renderer.getViewSize();\n\n\t\tif (!isAppend) {\n\t\t\tthis._fit();\n\t\t} else {\n\t\t\tthis.isLoading() && this._renderLoading();\n\t\t}\n\n\t\tconst watcher = this._watcher;\n\t\tconst scrollPos = watcher.getScrollPos();\n\n\t\t// recycle after _fit beacause prepend and append are occured simultaneously by scroll.\n\t\tif (!isLayout && useRecycle && !this.isLoading()) {\n\t\t\tthis._infinite.recycle(scrollPos, isAppend);\n\t\t}\n\n\t\tconst size = this._getEdgeValue(\"end\");\n\n\t\tif (isAppend) {\n\t\t\tthis._setContainerSize(size + this._status.loadingSize || 0);\n\t\t\tif (typeof scrollPos === \"number\" && scrollPos > 0) {\n\t\t\t\t!IS_IOS && this._scrollTo(scrollPos);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * This event is fired when layout is successfully arranged through a call to the append(), prepend(), or layout() method.\n\t\t * @ko 레이아웃 배치가 완료됐을 때 발생하는 이벤트. append() 메서드나 prepend() 메서드, layout() 메서드 호출 후 카드의 배치가 완료됐을 때 발생한다\n\t\t * @event eg.InfiniteGrid#layoutComplete\n\t\t *\n\t\t * @param {Object} param The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>\n\t\t * @param {Array} param.target Rearranged card elements<ko>재배치된 카드 엘리먼트들</ko>\n\t\t * @param {Boolean} param.fromCache Check whether these items are cache or not <ko>해당 아이템들이 캐시인지 아닌지 확인한다.</ko>\n\t\t * @param {Boolean} param.isLayout Returns true if this is an event called by resize event or layout method. Returns false if this is an event called by adding an item. <ko>해당 이벤트가 리사이즈 이벤트 또는 layout() 메서드를 통해 호출됐으면 true, 아이템 추가로 호출됐으면 false를 반환한다.</ko>\n\t\t * @param {Boolean} param.isAppend Checks whether the append() method is used to add a card element. It returns true even though the layoutComplete event is fired after the layout() method is called. <ko>카드 엘리먼트가 append() 메서드로 추가됐는지 확인한다. layout() 메서드가 호출된 후 layoutComplete 이벤트가 발생해도 'true'를 반환한다.</ko>\n\t\t * @param {Boolean} param.isScroll Checks whether scrolling has occurred after the append(), prepend(), ..., etc method is called <ko>append, prend 등 호출 후 스크롤이 생겼는지 확인한다.</ko>\n\t\t * @param {Number} param.scrollPos Current scroll position value relative to the infiniteGrid container element. <ko>infiniteGrid 컨테이너 엘리먼트 기준의 현재 스크롤 위치값</ko>\n\t\t * @param {Number} param.orgScrollPos Current position of the scroll <ko>현재 스크롤 위치값</ko>\n\t\t * @param {Number} param.size The size of container element <ko>컨테이너 엘리먼트의 크기</ko>\n\t\t * @param {Boolean} param.isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>\n\t\t * @param {Function} param.endLoading End loading after startLoading() for append/prepend loading data. <ko>데이터 로딩을 위해 append/prepend startLoading() 호출 이후 로딩을 끝낸다.</ko>\n\t\t * @param {Object} param.endLoading.userStyle The custom style to apply to this loading bar for start. <ko> 로딩이 끝날 때 로딩 바에 적용될 사용자 스타일 </ko>\n\t\t */\n\t\tthis.trigger(\"layoutComplete\", {\n\t\t\ttarget: items.concat(),\n\t\t\tisAppend: !!isAppend,\n\t\t\tisTrusted,\n\t\t\tfromCache,\n\t\t\tisLayout,\n\t\t\tisScroll: viewSize < watcher.getContainerOffset() + size,\n\t\t\tscrollPos,\n\t\t\torgScrollPos: watcher.getOrgScrollPos(),\n\t\t\tsize,\n\t\t\tendLoading: (userStyle: StyleType) => {\n\t\t\t\tthis.endLoading(userStyle);\n\t\t\t},\n\t\t});\n\t\tthis._infinite.scroll(scrollPos);\n\t}\n\tprivate _reset() {\n\t\tthis._status = {\n\t\t\tprocessingStatus: IDLE,\n\t\t\tloadingSize: 0,\n\t\t\tloadingStyle: {},\n\t\t};\n\t}\n}\n\nexport default InfiniteGrid;\n","import { ALIGN } from \"../consts\";\nimport { getStyleNames, assignOptions, fill, cloneItems } from \"../utils\";\nimport { ILayout, IAlign, IRectlProperties, IInfiniteGridItem, IInfiniteGridGroup } from \"../types\";\n\n// ALIGN\nconst { START, CENTER, END, JUSTIFY } = ALIGN;\n\n/**\n * @classdesc The GridLayout is a layout that stacks cards with the same width as a stack of bricks. Adjust the width of all images to the same size, find the lowest height column, and insert a new card.\n * @ko GridLayout는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 카드를 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 카드 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다.\n * @class eg.InfiniteGrid.GridLayout\n * @param {Object} [options] The option object of eg.InfiniteGrid.GridLayout module <ko>eg.InfiniteGrid.GridLayout 모듈의 옵션 객체</ko>\n * @param {String} [options.margin=0] Margin used to create space around items <ko>아이템들 사이의 공간</ko>\n * @param {Boolean} [options.horizontal=false] Direction of the scroll movement (false: vertical, true: horizontal) <ko>스크롤 이동 방향 (false: 세로방향, true: 가로방향)</ko>\n * @param {Boolean} [options.align=START] Align of the position of the items (START, CENTER, END, JUSTIFY) <ko>아이템들의 위치의 정렬 (START, CENTER, END, JUSTIFY)</ko>\n * @param {Boolean} [options.itemSize=0] The size of the items. If it is 0, it is calculated as the size of the first item in items. <ko> 아이템의 사이즈. 만약 아이템 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. </ko>\n * @example\n```\n<script>\nvar ig = new eg.InfiniteGrid(\"#grid\". {\n  horizontal: true,\n});\n\nig.setLayout(eg.InfiniteGrid.GridLayout, {\n  margin: 10,\n  align: \"start\",\n  itemSize: 200\n});\n\n// or\n\nvar layout = new eg.InfiniteGrid.GridLayout({\n  margin: 10,\n  align: \"center\",\n  itemSize: 200,\n  horizontal: true,\n});\n\n</script>\n```\n **/\nclass GridLayout implements ILayout {\n\tpublic options: {\n\t\thorizontal: boolean,\n\t\tmargin: number,\n\t\talign: IAlign[keyof IAlign],\n\t\titemSize: number,\n\t};\n\tprivate _size: number;\n\tprivate _columnSize: number;\n\tprivate _columnLength: number;\n\tprivate _style: IRectlProperties;\n\tconstructor(options: Partial<GridLayout[\"options\"]> = {}) {\n\t\tthis.options = assignOptions({\n\t\t\tmargin: 0,\n\t\t\thorizontal: false,\n\t\t\talign: START,\n\t\t\titemSize: 0,\n\t\t}, options);\n\t\tthis._size = 0;\n\t\tthis._columnSize = 0;\n\t\tthis._columnLength = 0;\n\t\tthis._style = getStyleNames(this.options.horizontal);\n\t}\n\t/**\n\t * Adds items at the bottom of a outline.\n\t * @ko 아이템들을 아웃라인 아래에 추가한다.\n\t * @method eg.InfiniteGrid.GridLayout#append\n\t * @param {Array} items Array of items to be layouted <ko>레이아웃할 아이템들의 배열</ko>\n\t * @param {Array} [outline=[]] Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {Object} Layouted items and outline of start and end <ko> 레이아웃이 된 아이템과 시작과 끝의 아웃라인이 담긴 정보</ko>\n\t * @example\n\t * layout.prepend(items, [100, 200, 300, 400]);\n\t */\n\tpublic append(items: IInfiniteGridItem[], outline?: number[], cache?: boolean) {\n\t\treturn this._insert(items, outline, true, cache);\n\t}\n\t/**\n\t * Adds items at the top of a outline.\n\t * @ko 아이템을 아웃라인 위에 추가한다.\n\t * @method eg.InfiniteGrid.GridLayout#prepend\n\t * @param {Array} items Array of items to be layouted <ko>레이아웃할 아이템들의 배열</ko>\n\t * @param {Array} [outline=[]] Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {Object} Layouted items and outline of start and end <ko> 레이아웃이 된 아이템과 시작과 끝의 아웃라인이 담긴 정보</ko>\n\t * @example\n\t * layout.prepend(items, [100, 200, 300, 400]);\n\t */\n\tpublic prepend(items: IInfiniteGridItem[], outline?: number[], cache?: boolean) {\n\t\treturn this._insert(items, outline, false, cache);\n\t}\n\t/**\n\t * Adds items of groups at the bottom of a outline.\n\t * @ko 그룹들의 아이템들을 아웃라인 아래에 추가한다.\n\t * @method eg.InfiniteGrid.GridLayout#layout\n\t * @param {Array} groups Array of groups to be layouted <ko>레이아웃할 그룹들의 배열</ko>\n\t * @param {Array} outline Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {eg.InfiniteGrid.GridLayout} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * layout.layout(groups, [100, 200, 300, 400]);\n\t */\n\tpublic layout(groups: IInfiniteGridGroup[] = [], outline: number[] = []) {\n\t\tconst firstItem = (groups.length && groups[0].items.length && groups[0].items[0]) as IInfiniteGridItem;\n\n\t\tthis.checkColumn(firstItem);\n\n\t\t// if outlines' length and columns' length are now same, re-caculate outlines.\n\t\tlet startOutline: number[];\n\n\t\tif (outline.length !== this._columnLength) {\n\t\t\tconst pos = outline.length === 0 ? 0 : Math.min(...outline);\n\n\t\t\t// re-layout items.\n\t\t\tstartOutline = fill(new Array(this._columnLength), pos);\n\t\t} else {\n\t\t\tstartOutline = outline.slice();\n\t\t}\n\t\tgroups.forEach(group => {\n\t\t\tconst items = group.items;\n\t\t\tconst result = this._layout(items, startOutline, true);\n\n\t\t\tgroup.outlines = result;\n\t\t\tstartOutline = result.end;\n\t\t});\n\n\t\treturn this;\n\t}\n\t/**\n\t * Set the viewport size of the layout.\n\t * @ko 레이아웃의 가시 사이즈를 설정한다.\n\t * @method eg.InfiniteGrid.GridLayout#setSize\n\t * @param {Number} size The viewport size of container area where items are added to a layout <ko>레이아웃에 아이템을 추가하는 컨테이너 영역의 가시 사이즈</ko>\n\t * @return {eg.InfiniteGrid.GridLayout} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * layout.setSize(800);\n\t */\n\tpublic setSize(size: number) {\n\t\tthis._size = size;\n\t\treturn this;\n\t}\n\tprivate checkColumn(item: IInfiniteGridItem) {\n\t\tconst { itemSize, margin, horizontal } = this.options;\n\t\tconst sizeName = horizontal ? \"height\" : \"width\";\n\t\tconst columnSize = Math.floor(itemSize || (item && item.size![sizeName]) || 0) || 0;\n\n\t\tthis._columnSize = columnSize;\n\t\tif (!columnSize) {\n\t\t\tthis._columnLength = 1;\n\t\t\treturn;\n\t\t}\n\t\tthis._columnLength = Math.max(Math.floor((this._size + margin) / (columnSize + margin)), 1);\n\t}\n\tprivate _layout(items: IInfiniteGridItem[], outline: number[], isAppend?: boolean) {\n\t\tconst length = items.length;\n\t\tconst margin = this.options.margin;\n\t\tconst align = this.options.align;\n\t\tconst style = this._style;\n\n\t\tconst size1Name = style.size1;\n\t\tconst size2Name = style.size2;\n\t\tconst pos1Name = style.startPos1;\n\t\tconst pos2Name = style.startPos2;\n\t\tconst columnSize = this._columnSize;\n\t\tconst columnLength = this._columnLength;\n\n\t\tconst size = this._size;\n\t\tconst viewDist = (size - (columnSize + margin) * columnLength + margin);\n\n\t\tconst pointCaculateName = isAppend ? \"min\" : \"max\";\n\t\tconst indexCaculateName = isAppend ? \"indexOf\" : \"lastIndexOf\";\n\t\tconst startOutline = outline.slice();\n\t\tconst endOutline = outline.slice();\n\n\t\tfor (let i = 0; i < length; ++i) {\n\t\t\tconst point = Math[pointCaculateName](...endOutline) || 0;\n\t\t\tlet index = endOutline[indexCaculateName](point);\n\t\t\tconst item = items[isAppend ? i : length - 1 - i];\n\t\t\tconst itemSize = item.size;\n\n\t\t\tif (!itemSize) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst size1 = itemSize[size1Name];\n\t\t\tconst size2 = itemSize[size2Name];\n\t\t\tconst pos1 = isAppend ? point : point - margin - size1;\n\t\t\tconst endPos1 = pos1 + size1 + margin;\n\n\t\t\tif (index === -1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\tlet pos2 = (columnSize + margin) * index;\n\n\t\t\t// ALIGN\n\t\t\tif (align === CENTER) {\n\t\t\t\tpos2 += viewDist / 2;\n\t\t\t} else if (align === END) {\n\t\t\t\tpos2 += viewDist + columnSize - size2;\n\t\t\t} else if (align === JUSTIFY) {\n\t\t\t\tif (columnLength <= 1) {\n\t\t\t\t\tpos2 += viewDist / 2;\n\t\t\t\t} else {\n\t\t\t\t\tpos2 = (size - columnSize) / (columnLength - 1) * index;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// tetris\n\t\t\titem.rect = {\n\t\t\t\t[pos1Name as \"top\"]: pos1,\n\t\t\t\t[pos2Name as \"left\"]: pos2,\n\t\t\t};\n\t\t\titem.column = index;\n\t\t\tendOutline[index] = isAppend ? endPos1 : pos1;\n\t\t}\n\t\tif (!isAppend) {\n\t\t\titems.sort((a, b) => {\n\t\t\t\tconst item1pos1 = a.rect[pos1Name];\n\t\t\t\tconst item1pos2 = a.rect[pos2Name];\n\t\t\t\tconst item2pos1 = b.rect[pos1Name];\n\t\t\t\tconst item2pos2 = b.rect[pos2Name];\n\n\t\t\t\tif (item1pos1 - item2pos1) {\n\t\t\t\t\treturn item1pos1 - item2pos1;\n\t\t\t\t}\n\t\t\t\treturn item1pos2 - item2pos2;\n\t\t\t});\n\t\t}\n\t\t// if append items, startOutline is low, endOutline is high\n\t\t// if prepend items, startOutline is high, endOutline is low\n\t\treturn {\n\t\t\tstart: isAppend ? startOutline : endOutline,\n\t\t\tend: isAppend ? endOutline : startOutline,\n\t\t};\n\t}\n\tprivate _insert(\n\t\titems: IInfiniteGridItem[] = [],\n\t\toutline: number[] = [],\n\t\tisAppend?: boolean,\n\t\tcache?: boolean,\n\t) {\n\t\tconst clone = cache ? items : cloneItems(items);\n\n\t\tlet startOutline = outline;\n\n\t\tif (!this._columnLength) {\n\t\t\tthis.checkColumn(items[0]);\n\t\t}\n\t\tif (outline.length !== this._columnLength) {\n\t\t\tstartOutline = fill(new Array(this._columnLength), outline.length ? (Math[isAppend ? \"min\" : \"max\"](...outline) || 0) : 0);\n\t\t}\n\n\t\tconst result = this._layout(clone, startOutline, isAppend);\n\n\t\treturn {\n\t\t\titems: clone,\n\t\t\toutlines: result,\n\t\t};\n\t}\n}\n\nexport default GridLayout;\n","import { DUMMY_POSITION } from \"../consts\";\nimport { getStyleNames, assignOptions, fill, cloneItems } from \"../utils\";\nimport { ILayout, IRectlProperties, ISize, IInfiniteGridGroup, IInfiniteGridItem } from \"../types\";\n\nexport type FrameType = number[][];\nexport interface IFrameShape {\n\tleft?: number;\n\ttop?: number;\n\ttype: any;\n\twidth: number;\n\theight: number;\n\tindex?: number;\n}\nexport interface IFrameLayoutInterface {\n\thorizontal: boolean;\n\tmargin: number;\n\tframe: FrameType;\n\tframeFill: boolean;\n\titemSize: number | ISize;\n\t[key: string]: any;\n}\n/*\nFrame\n[\n[1, 1, 1, 1, 1],\n[0, 0, 2, 2, 2],\n[0, 0, 2, 2, 2],\n[3, 4, 5, 5, 5],\n]\n*/\nfunction disableFrame(\n\tframe: FrameType,\n\ttype: number,\n\ttop: number,\n\tleft: number,\n\twidth: number,\n\theight: number,\n) {\n\tfor (let i = top; i < top + height; ++i) {\n\t\tfor (let j = left; j < left + width; ++j) {\n\t\t\tif (type !== frame[i][j]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tframe[i][j] = 0;\n\t\t}\n\t}\n}\nfunction searchShapeInFrame(\n\tframe: FrameType,\n\ttype: number,\n\ttop: number,\n\tleft: number,\n\twidth: number,\n\theight: number,\n) {\n\tconst size: IFrameShape = {\n\t\tleft,\n\t\ttop,\n\t\ttype,\n\t\twidth: 1,\n\t\theight: 1,\n\t};\n\n\tfor (let i = left; i < width; ++i) {\n\t\tif (frame[top][i] === type) {\n\t\t\tsize.width = i - left + 1;\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\tfor (let i = top; i < height; ++i) {\n\t\tif (frame[i][left] === type) {\n\t\t\tsize.height = i - top + 1;\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\t// After finding the shape, it will not find again.\n\tdisableFrame(frame, type, top, left, size.width, size.height);\n\treturn size;\n}\nfunction getShapes(frame: FrameType) {\n\tconst height = frame.length;\n\tconst width = height ? frame[0].length : 0;\n\tconst shapes: IFrameShape[] = [];\n\n\tfor (let i = 0; i < height; ++i) {\n\t\tfor (let j = 0; j < width; ++j) {\n\t\t\tconst type = frame[i][j];\n\n\t\t\tif (!type) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Separate shapes with other numbers.\n\t\t\tshapes.push(searchShapeInFrame(frame, type, i, j, width, height));\n\t\t}\n\t}\n\tshapes.sort((a, b) => (a.type < b.type ? -1 : 1));\n\treturn {\n\t\tshapes,\n\t\twidth,\n\t\theight,\n\t};\n}\n/**\n * @classdesc FrameLayout is a layout that allows you to place cards in a given frame. It is a layout that corresponds to a level intermediate between the placement of the image directly by the designer and the layout using the algorithm.\n * @ko FrameLayout은 주어진 프레임에 맞춰 카드를 배치하는 레이아웃입니다. 디자이너가 직접 이미지를 배치하는 것과 알고리즘을 사용한 배치의 중간 정도 수준에 해당하는 레이아웃이다.\n * @class eg.InfiniteGrid.FrameLayout\n * @param {Object} [options] The option object of eg.InfiniteGrid.FrameLayout module <ko>eg.InfiniteGrid.FrameLayout 모듈의 옵션 객체</ko>\n * @param {String} [options.margin=0] Margin used to create space around items <ko>아이템들 사이의 공간</ko>\n * @param {Boolean} [options.horizontal=false] Direction of the scroll movement (false: vertical, true: horizontal) <ko>스크롤 이동 방향 (false: 세로방향, true: 가로방향)</ko>\n * @param {Boolean} [options.itemSize=0] The size of the items. If it is 0, it is calculated as the size of the first item in items. <ko> 아이템의 사이즈. 만약 아이템 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. </ko>\n * @param {Boolean} [options.frame=[]] The size of the items. If it is 0, it is calculated as the size of the first item in items. <ko> 아이템의 사이즈. 만약 아이템 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. </ko>\n * @param {Boolean} [options.frameFill=true] Make sure that the frame can be attached after the previous frame. <ko> 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. </ko>\n * @example\n```\n<script>\nvar ig = new eg.InfiniteGrid(\"#grid\". {\n  horizontal: true,\n});\n\nig.setLayout(eg.InfiniteGrid.FrameLayout, {\n  margin: 10,\n  itemSize: 200,\n  frame: [\n    [1, 1, 1, 1, 1],\n    [0, 0, 2, 2, 2],\n    [0, 0, 2, 2, 2],\n    [3, 4, 5, 5, 5],\n  ],\n});\n\n// or\n\nvar layout = new eg.InfiniteGrid.FrameLayout({\n  margin: 10,\n  itemSize: 200,\n  horizontal: true,\n  frame: [\n    [1, 1, 1, 1, 1],\n    [0, 0, 2, 2, 2],\n    [0, 0, 2, 2, 2],\n    [3, 4, 5, 5, 5],\n  ],\n});\n\n</script>\n```\n **/\nclass FrameLayout implements ILayout {\n\tpublic options: IFrameLayoutInterface;\n\tprotected _itemSize: number | ISize;\n\tprotected _shapes: {\n\t\tshapes: IFrameShape[],\n\t\twidth?: number,\n\t\theight?: number,\n\t};\n\tprotected _size: number;\n\tprotected _style: IRectlProperties;\n\n\tconstructor(options: Partial<IFrameLayoutInterface> = {}) {\n\t\tthis.options = assignOptions({\n\t\t\tmargin: 0,\n\t\t\thorizontal: false,\n\t\t\titemSize: 0,\n\t\t\tframe: [],\n\t\t\tframeFill: true,\n\t\t}, options);\n\t\tconst frame = this.options.frame.map(row => row.slice());\n\n\t\tthis._itemSize = this.options.itemSize || 0;\n\t\t// divide frame into shapes.\n\t\tthis._shapes = getShapes(frame);\n\t\tthis._size = 0;\n\t\tthis._style = getStyleNames(this.options.horizontal);\n\t}\n\t/**\n\t * Adds items of groups at the bottom of a outline.\n\t * @ko 그룹들의 아이템들을 아웃라인 아래에 추가한다.\n\t * @method eg.InfiniteGrid.FrameLayout#layout\n\t * @param {Array} groups Array of groups to be layouted <ko>레이아웃할 그룹들의 배열</ko>\n\t * @param {Array} outline Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {eg.InfiniteGrid.FrameLayout} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * layout.layout(groups, [100, 200, 300, 400]);\n\t */\n\tpublic layout(groups: IInfiniteGridGroup[] = [], outline: number[] = []) {\n\t\tconst length = groups.length;\n\t\tlet point = outline;\n\n\t\tfor (let i = 0; i < length; ++i) {\n\t\t\tconst group = groups[i];\n\t\t\tconst outlines = this._layout(group.items, point, true);\n\n\t\t\tgroup.outlines = outlines;\n\t\t\tpoint = outlines.end;\n\t\t}\n\t\treturn this;\n\t}\n\t/**\n\t * Set the viewport size of the layout.\n\t * @ko 레이아웃의 가시 사이즈를 설정한다.\n\t * @method eg.InfiniteGrid.FrameLayout#setSize\n\t * @param {Number} size The viewport size of container area where items are added to a layout <ko>레이아웃에 아이템을 추가하는 컨테이너 영역의 가시 사이즈</ko>\n\t * @return {eg.InfiniteGrid.FrameLayout} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * layout.setSize(800);\n\t */\n\tpublic setSize(size: number) {\n\t\tthis._size = size;\n\t\treturn this;\n\t}\n\t/**\n\t * Adds items at the bottom of a outline.\n\t * @ko 아이템들을 아웃라인 아래에 추가한다.\n\t * @method eg.InfiniteGrid.FrameLayout#append\n\t * @param {Array} items Array of items to be layouted <ko>레이아웃할 아이템들의 배열</ko>\n\t * @param {Array} [outline=[]] Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {Object} Layouted items and outline of start and end <ko> 레이아웃이 된 아이템과 시작과 끝의 아웃라인이 담긴 정보</ko>\n\t * @example\n\t * layout.prepend(items, [100]);\n\t */\n\tpublic append(items: IInfiniteGridItem[], outline?: number[], cache?: boolean) {\n\t\treturn this._insert(items, outline, true, cache);\n\t}\n\t/**\n\t * Adds items at the top of a outline.\n\t * @ko 아이템을 아웃라인 위에 추가한다.\n\t * @method eg.InfiniteGrid.FrameLayout#prepend\n\t * @param {Array} items Array of items to be layouted <ko>레이아웃할 아이템들의 배열</ko>\n\t * @param {Array} [outline=[]] Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {Object} Layouted items and outline of start and end <ko> 레이아웃이 된 아이템과 시작과 끝의 아웃라인이 담긴 정보</ko>\n\t * @example\n\t * layout.prepend(items, [100]);\n\t */\n\tpublic prepend(items: IInfiniteGridItem[], outline?: number[], cache?: boolean) {\n\t\treturn this._insert(items, outline, false, cache);\n\t}\n\tprotected _getItemSize() {\n\t\tthis._checkItemSize();\n\n\t\treturn this._itemSize;\n\t}\n\tprotected _checkItemSize() {\n\t\tif (this.options.itemSize) {\n\t\t\tthis._itemSize = this.options.itemSize;\n\t\t\treturn;\n\t\t}\n\t\tconst style = this._style;\n\t\tconst size = style.size2;\n\t\tconst margin = this.options.margin;\n\n\t\t// if itemSize is not in options, caculate itemSize from size.\n\t\tthis._itemSize = (this._size + margin) / this._shapes[size]! - margin;\n\t}\n\tprotected _layout(items: IInfiniteGridItem[], outline: number[] = [], isAppend?: boolean) {\n\t\tconst length = items.length;\n\t\tconst style = this._style;\n\t\tconst { margin, frameFill } = this.options;\n\t\tconst size1Name = style.size1;\n\t\tconst size2Name = style.size2;\n\t\tconst pos1Name = style.startPos1;\n\t\tconst pos2Name = style.startPos2;\n\t\tconst itemSize = this._getItemSize();\n\t\tconst isItemObject = typeof itemSize === \"object\";\n\t\tconst itemSize2 = isItemObject ? (itemSize as ISize)[size2Name] : itemSize as number;\n\t\tconst itemSize1 = isItemObject ? (itemSize as ISize)[size1Name] : itemSize as number;\n\t\tconst shapesSize = this._shapes[size2Name]!;\n\t\tconst shapes = this._shapes.shapes;\n\t\tconst shapesLength = shapes.length;\n\t\tconst startOutline = fill(new Array(shapesSize), DUMMY_POSITION);\n\t\tconst endOutline = fill(new Array(shapesSize), DUMMY_POSITION);\n\t\tlet dist = 0;\n\t\tlet end = 0;\n\n\t\tif (!shapesLength) {\n\t\t\treturn { start: outline, end: outline };\n\t\t}\n\t\tfor (let i = 0; i < length; i += shapesLength) {\n\t\t\tfor (let j = 0; j < shapesLength && i + j < length; ++j) {\n\t\t\t\tconst item = items[i + j];\n\t\t\t\tconst shape = shapes[j];\n\t\t\t\tconst shapePos1 = shape[pos1Name]!;\n\t\t\t\tconst shapePos2 = shape[pos2Name]!;\n\t\t\t\tconst shapeSize1 = shape[size1Name]!;\n\t\t\t\tconst shapeSize2 = shape[size2Name]!;\n\t\t\t\tconst pos1 = end - dist + shapePos1 * (itemSize1 + margin);\n\t\t\t\tconst pos2 = shapePos2 * (itemSize2 + margin);\n\t\t\t\tconst size1 = shapeSize1 * (itemSize1 + margin) - margin;\n\t\t\t\tconst size2 = shapeSize2 * (itemSize2 + margin) - margin;\n\n\t\t\t\tfor (let k = shapePos2; k < shapePos2 + shapeSize2 && k < shapesSize; ++k) {\n\t\t\t\t\tif (startOutline[k] === DUMMY_POSITION) {\n\t\t\t\t\t\tstartOutline[k] = pos1;\n\t\t\t\t\t}\n\t\t\t\t\tstartOutline[k] = Math.min(startOutline[k], pos1);\n\t\t\t\t\tendOutline[k] = Math.max(endOutline[k], pos1 + size1 + margin);\n\t\t\t\t}\n\t\t\t\titem.rect = {\n\t\t\t\t\t[pos1Name]: pos1,\n\t\t\t\t\t[pos2Name]: pos2,\n\t\t\t\t\t[size1Name]: size1,\n\t\t\t\t\t[size2Name]: size2,\n\t\t\t\t} as any;\n\t\t\t}\n\t\t\tend = Math.max(...endOutline);\n\t\t\t// check dist once\n\t\t\tif (i !== 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// find & fill empty block\n\t\t\tif (!frameFill) {\n\t\t\t\tdist = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdist = end;\n\n\t\t\tfor (let j = 0; j < shapesSize; ++j) {\n\t\t\t\tif (startOutline[j] === DUMMY_POSITION) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// the dist between frame's end outline and next frame's start outline\n\t\t\t\t// expect that next frame's start outline is startOutline[j] + end\n\t\t\t\tdist = Math.min(startOutline[j] + end - endOutline[j], dist);\n\t\t\t}\n\t\t}\n\t\tfor (let i = 0; i < shapesSize; ++i) {\n\t\t\tif (startOutline[i] !== DUMMY_POSITION) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tstartOutline[i] = Math.max(...startOutline);\n\t\t\tendOutline[i] = startOutline[i];\n\t\t}\n\t\t// The target outline is start outline when type is appending\n\t\tconst targetOutline = isAppend ? startOutline : endOutline;\n\t\tconst prevOutlineEnd = outline.length === 0 ? 0 : Math[isAppend ? \"max\" : \"min\"](...outline);\n\t\tlet prevOutlineDist = isAppend ? 0 : end;\n\n\t\tif (frameFill && outline.length === shapesSize) {\n\t\t\tprevOutlineDist = -DUMMY_POSITION;\n\t\t\tfor (let i = 0; i < shapesSize; ++i) {\n\t\t\t\tif (startOutline[i] === endOutline[i]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// if appending type is prepend(false), subtract dist from appending group's height.\n\n\t\t\t\tprevOutlineDist = Math.min(targetOutline[i] + prevOutlineEnd - outline[i], prevOutlineDist);\n\t\t\t}\n\t\t}\n\t\tfor (let i = 0; i < shapesSize; ++i) {\n\t\t\tstartOutline[i] += prevOutlineEnd - prevOutlineDist;\n\t\t\tendOutline[i] += prevOutlineEnd - prevOutlineDist;\n\t\t}\n\t\titems.forEach(item => {\n\t\t\titem.rect[pos1Name] += prevOutlineEnd - prevOutlineDist;\n\t\t});\n\t\treturn {\n\t\t\tstart: startOutline.map(point => parseInt(point, 10)),\n\t\t\tend: endOutline.map(point => parseInt(point, 10)),\n\t\t};\n\t}\n\tprivate _insert(items: IInfiniteGridItem[] = [], outline: number[] = [], isAppend?: boolean, cache?: boolean) {\n\t\t// this only needs the size of the item.\n\t\tconst clone = cache ? items : cloneItems(items);\n\n\t\treturn {\n\t\t\titems: clone,\n\t\t\toutlines: this._layout(clone, outline, isAppend),\n\t\t};\n\t}\n}\n\nexport default FrameLayout;\n","import FrameLayout, { IFrameLayoutInterface, IFrameShape } from \"./FrameLayout\";\nimport { fill } from \"../utils\";\nimport { IInfiniteGridItem } from \"../types\";\n\nfunction makeShapeOutline(\n\toutline: number[],\n\titemSize: number,\n\tcolumnLength: number,\n\tisAppend?: boolean,\n) {\n\tconst point = Math[isAppend ? \"min\" : \"max\"](...outline) || 0;\n\n\tif (outline.length !== columnLength) {\n\t\treturn fill(new Array(columnLength), 0);\n\t}\n\treturn outline.map(l => Math.floor((l - point) / itemSize));\n}\nfunction getColumn(item: IInfiniteGridItem) {\n\tif (item.column) {\n\t\treturn item.column;\n\t}\n\tlet column = 1;\n\n\tif (item.el) {\n\t\tcolumn = parseInt(item.el.getAttribute(\"data-column\")!, 10) || 1;\n\t}\n\titem.column = column;\n\treturn column;\n}\nexport interface ISquareLayoutOptions extends IFrameLayoutInterface {\n\tcolumn: number;\n}\n/**\n * @classdesc SquareLayout is a layout that places all cards like squares on a checkerboard, and important cards are n times larger. The main card can be enlarged, and then a small card can be placed to naturally show the relationship of the card.\n * @ko SquareLayout은 바둑판처럼 모든 카드를 정사각형으로 배치하고 중요한 카드는 크기를 N배로 키워서 보여주는 레이아웃이다. 주요 카드를 크게 표시하고, 그 다음에 작은 카드를 배치해 자연스럽게 카드의 관계를 나타낼 수 있습니다.\n * @class eg.InfiniteGrid.SquareLayout\n * @extends eg.InfiniteGrid.FrameLayout\n * @param {Object} [options] The option object of eg.InfiniteGrid.SquareLayout module <ko>eg.InfiniteGrid.SquareLayout 모듈의 옵션 객체</ko>\n * @param {String} [options.margin=0] Margin used to create space around items <ko>아이템들 사이의 공간</ko>\n * @param {Boolean} [options.horizontal=false] Direction of the scroll movement (false: vertical, true: horizontal) <ko>스크롤 이동 방향 (false: 세로방향, true: 가로방향)</ko>\n * @param {Boolean} [options.itemSize=0] The size of the items. If it is 0, it is calculated as the size of the first item in items. (priority: `column` > `itemSize` > element's size)<ko> 아이템의 사이즈. 만약 아이템 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (우선순위: `column` > `itemSize` > 엘리먼트의 사이즈) </ko>\n * @param {Boolean} [options.column=0] The number of columns in the layout. If it is 0, the column is returned by `itemSize`.  (priority: `column` > `itemSize` > element's size)<ko> 레이아웃의 열의 개수. 만약 column이 0이면, `itemSize`로 열을 구합니다. (우선순위: `column` > `itemSize` > 엘리먼트의 사이즈) </ko>\n * @example\n```\n<script>\nvar ig = new eg.InfiniteGrid(\"#grid\". {\n\thorizontal: true,\n});\n\nig.setLayout(eg.InfiniteGrid.SquareLayout, {\n\tmargin: 10,\n\titemSize: 200,\n});\n\n// or\n\nvar layout = new eg.InfiniteGrid.SquareLayout({\n\tmargin: 10,\n\titemSize: 200,\n\thorizontal: true,\n});\n\nvar item1 = '<div data-column=\"2\"></div>';\nvar item2 = \"<div></div>\"\nlayout.append([item1, item2]);\n</script>\n```\n **/\nexport default class SquareLayout extends FrameLayout {\n\tpublic options: ISquareLayoutOptions;\n\n\tconstructor(options: Partial<ISquareLayoutOptions> = {}) {\n\t\tsuper(options);\n\t}\n\tprotected _layout(\n\t\titems: IInfiniteGridItem[],\n\t\toutline: number[] = [],\n\t\tisAppend: boolean = false,\n\t) {\n\t\tconst itemSize = this._getSquareSize(items[0]) as number;\n\t\tconst margin = this.options.margin;\n\t\tconst columnLength = this.options.column ||\n\t\t\tMath.floor((this._size + margin) / (itemSize + margin)) || 1;\n\t\tconst length = items.length;\n\t\tconst endOutline = makeShapeOutline(outline, Math.floor(itemSize), columnLength, isAppend);\n\t\tconst pointCaculateName = isAppend ? \"min\" : \"max\";\n\t\tconst shapes: IFrameShape[] = [];\n\t\tconst sign = isAppend ? 1 : -1;\n\t\tconst style = this._style;\n\t\tconst pos1Name = style.startPos1;\n\t\tconst pos2Name = style.startPos2;\n\n\t\tfor (let i = 0; i < length; ++i) {\n\t\t\tconst point = Math[pointCaculateName](...endOutline);\n\t\t\tlet index = endOutline[isAppend ? \"indexOf\" : \"lastIndexOf\"](point);\n\t\t\tconst item = items[i];\n\t\t\tconst columnWidth = item.columnWidth;\n\t\t\tconst column = (columnWidth && columnWidth[0] === columnLength &&\n\t\t\t\tcolumnWidth[1]) || getColumn(item);\n\t\t\tlet columnCount = 1;\n\n\t\t\tif (column > 1) {\n\t\t\t\tfor (let j = 1; j < column &&\n\t\t\t\t\t((isAppend && index + j < columnLength) || (!isAppend && index - j >= 0)); ++j) {\n\t\t\t\t\tif ((isAppend && endOutline[index + sign * j] <= point) ||\n\t\t\t\t\t\t(!isAppend && endOutline[index + sign * j] >= point)) {\n\t\t\t\t\t\t++columnCount;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (!isAppend) {\n\t\t\t\t\tindex -= columnCount - 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\titem.columnWidth = [columnLength, columnCount];\n\t\t\tshapes.push({\n\t\t\t\twidth: columnCount,\n\t\t\t\theight: columnCount,\n\t\t\t\t[pos1Name]: point - (!isAppend ? columnCount : 0),\n\t\t\t\t[pos2Name]: index,\n\t\t\t\ttype: i + 1,\n\t\t\t\tindex: i,\n\t\t\t});\n\t\t\tfor (let j = 0; j < columnCount; ++j) {\n\t\t\t\tendOutline[index + j] = point + sign * columnCount;\n\t\t\t}\n\t\t}\n\t\tthis._shapes = {\n\t\t\tshapes,\n\t\t\t[style.size2]: columnLength,\n\t\t};\n\n\t\tconst result = super._layout(items, outline, isAppend);\n\n\t\tif (!isAppend) {\n\t\t\tshapes.sort((shape1, shape2) => {\n\t\t\t\tconst item1pos1 = shape1[pos1Name]!;\n\t\t\t\tconst item1pos2 = shape1[pos2Name]!;\n\t\t\t\tconst item2pos1 = shape2[pos1Name]!;\n\t\t\t\tconst item2pos2 = shape2[pos2Name]!;\n\n\t\t\t\tif (item1pos1 - item2pos1) {\n\t\t\t\t\treturn item1pos1 - item2pos1;\n\t\t\t\t}\n\t\t\t\treturn item1pos2 - item2pos2;\n\t\t\t});\n\t\t\titems.sort((a, b) => {\n\t\t\t\tconst item1pos1 = a.rect[pos1Name];\n\t\t\t\tconst item1pos2 = a.rect[pos2Name];\n\t\t\t\tconst item2pos1 = b.rect[pos1Name];\n\t\t\t\tconst item2pos2 = b.rect[pos2Name];\n\n\t\t\t\tif (item1pos1 - item2pos1) {\n\t\t\t\t\treturn item1pos1 - item2pos1;\n\t\t\t\t}\n\t\t\t\treturn item1pos2 - item2pos2;\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\tprivate _getSquareSize(item: IInfiniteGridItem) {\n\t\tconst { column, margin, itemSize } = this.options;\n\n\t\tif (column) {\n\t\t\t// if column is in options, caculate itemSize from column.\n\t\t\tthis._itemSize = (this._size + margin) / column - margin;\n\t\t} else if (itemSize) {\n\t\t\tthis._itemSize = this.options.itemSize;\n\t\t} else {\n\t\t\tconst sizeName = this._style.size2;\n\t\t\t// if frameSize is 0, caculate frameSize from item.size.\n\t\t\tconst frameSize\n\t\t\t\t= this._shapes[sizeName]\n\t\t\t\t|| Math.floor((this._size + margin) / (item.size![sizeName]! + margin) / getColumn(item));\n\t\t\tthis._itemSize = (this._size + margin) / frameSize - margin;\n\t\t}\n\t\treturn this._itemSize;\n\t}\n}\n","import { assign } from \"../../utils\";\n\nexport interface IBoxModel {\n\toriginWidth: number;\n\toriginHeight: number;\n\twidth: number;\n\theight: number;\n\tleft: number;\n\ttop: number;\n\titems: BoxModel[];\n}\n\nexport default class BoxModel implements IBoxModel {\n\tpublic originWidth: number;\n\tpublic originHeight: number;\n\tpublic width: number;\n\tpublic height: number;\n\tpublic left: number;\n\tpublic top: number;\n\tpublic items: BoxModel[];\n\tconstructor(options: Partial<IBoxModel>) {\n\t\tassign(this, {\n\t\t\toriginWidth: 0,\n\t\t\toriginHeight: 0,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\tleft: 0,\n\t\t\ttop: 0,\n\t\t\titems: [],\n\t\t}, options);\n\t}\n\tpublic scaleTo(width: number, height: number) {\n\t\tconst scaleX = this.width ? width / this.width : 0;\n\t\tconst scaleY = this.height ? height / this.height : 0;\n\n\t\tthis.items.forEach(v => {\n\t\t\tif (scaleX !== 0) {\n\t\t\t\tv.left *= scaleX;\n\t\t\t\tv.width *= scaleX;\n\t\t\t}\n\t\t\tif (scaleY !== 0) {\n\t\t\t\tv.top *= scaleY;\n\t\t\t\tv.height *= scaleY;\n\t\t\t}\n\t\t});\n\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t}\n\tpublic push(item: BoxModel) {\n\t\tthis.items.push(item);\n\t}\n\tpublic getOriginSize() {\n\t\treturn this.originWidth * this.originHeight;\n\t}\n\tpublic getSize() {\n\t\treturn this.width * this.height;\n\t}\n\tpublic getOriginRatio() {\n\t\treturn (this.originHeight === 0) ? 0 : this.originWidth / this.originHeight;\n\t}\n\tpublic getRatio() {\n\t\treturn (this.height === 0) ? 0 : this.width / this.height;\n\t}\n}\n","import BoxModel from \"./lib/BoxModel\";\nimport { getStyleNames, assignOptions, toZeroArray, cloneItems } from \"../utils\";\nimport { ILayout, IRectlProperties, ISize, IInfiniteGridItem, IInfiniteGridGroup } from \"../types\";\n\nfunction getCost(originLength: number, length: number) {\n\tlet cost = originLength / length;\n\n\tif (cost < 1) {\n\t\tcost = 1 / cost;\n\t}\n\n\treturn cost - 1;\n}\nfunction fitArea(\n\titem: BoxModel,\n\tbestFitArea: BoxModel,\n\titemFitSize: ISize,\n\tcontainerFitSize: ISize,\n\tlayoutVertical: boolean,\n) {\n\titem.height = itemFitSize.height;\n\titem.width = itemFitSize.width;\n\tbestFitArea.height = containerFitSize.height;\n\tbestFitArea.width = containerFitSize.width;\n\n\tif (layoutVertical) {\n\t\titem.top = bestFitArea.top + bestFitArea.height;\n\t\titem.left = bestFitArea.left;\n\t} else {\n\t\titem.left = bestFitArea.left + bestFitArea.width;\n\t\titem.top = bestFitArea.top;\n\t}\n}\n\n/**\n * @classdesc The PackingLayout is a layout that shows the important cards bigger without sacrificing the weight of the cards. Rows and columns are separated so that cards are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion.\n * @ko PackingLayout은 카드의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다. 행과 열이 구분돼 이미지를 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 카드를 배치한다.\n * @class eg.InfiniteGrid.PackingLayout\n * @param {Object} [options] The option object of eg.InfiniteGrid.PackingLayout module <ko>eg.InfiniteGrid.PackingLayout 모듈의 옵션 객체</ko>\n * @param {String} [options.margin=0] Margin used to create space around items <ko>아이템들 사이의 공간</ko>\n * @param {Boolean} [options.horizontal=false] Direction of the scroll movement (false: vertical, true: horizontal) <ko>스크롤 이동 방향 (false: 세로방향, true: 가로방향)</ko>\n * @param {Boolean} [options.aspectRatio=1] The aspect ratio of the group <ko> 그룹의 가로 세로 비 </ko>\n * @param {Boolean} [options.sizeWeight=1] The size weight when placing an image <ko> 이미지를 배치할 때 사이즈 가중치 </ko>\n * @param {Boolean} [options.ratioWeight=1] The ratio weight when placing an image <ko> 이미지를 배치할 때 비율 가중치 </ko>\n * @example\n```\n<script>\nvar ig = new eg.InfiniteGrid(\"#grid\". {\n  horizontal: true,\n});\n\nig.setLayout(eg.InfiniteGrid.PackingLayout, {\n  margin: 10,\n  aspectRatio: 1,\n  sizeWeight: 1,\n  ratioWeight: 2,\n});\n\n// or\n\nvar layout = new eg.InfiniteGrid.PackingLayout({\n  horizontal: true,\n  margin: 10,\n  aspectRatio: 1,\n  sizeWeight: 1,\n  ratioWeight: 2,\n});\n\n</script>\n```\n **/\nclass PackingLayout implements ILayout {\n\tpublic options: {\n\t\thorizontal: boolean,\n\t\tmargin: number,\n\t\taspectRatio: number,\n\t\tsizeWeight: number,\n\t\tratioWeight: number,\n\t};\n\tprivate _size: number;\n\tprivate _style: IRectlProperties;\n\tconstructor(options: Partial<PackingLayout[\"options\"]> = {}) {\n\t\tthis.options = assignOptions({\n\t\t\tmargin: 0,\n\t\t\thorizontal: false,\n\t\t\taspectRatio: 1,\n\t\t\tsizeWeight: 1,\n\t\t\tratioWeight: 1,\n\t\t}, options);\n\t\tthis._size = 0;\n\t\tthis._style = getStyleNames(this.options.horizontal);\n\t}\n\t/**\n\t * Adds items at the bottom of a outline.\n\t * @ko 아이템들을 아웃라인 아래에 추가한다.\n\t * @method eg.InfiniteGrid.PackingLayout#append\n\t * @param {Array} items Array of items to be layouted <ko>레이아웃할 아이템들의 배열</ko>\n\t * @param {Array} [outline=[]] Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {Object} Layouted items and outline of start and end <ko> 레이아웃이 된 아이템과 시작과 끝의 아웃라인이 담긴 정보</ko>\n\t * @example\n\t * layout.prepend(items, [100]);\n\t */\n\tpublic append(items: IInfiniteGridItem[], outline?: number[], cache?: boolean) {\n\t\treturn this._insert(items, outline, true, cache);\n\t}\n\t/**\n\t * Adds items at the top of a outline.\n\t * @ko 아이템을 아웃라인 위에 추가한다.\n\t * @method eg.InfiniteGrid.PackingLayout#prepend\n\t * @param {Array} items Array of items to be layouted <ko>레이아웃할 아이템들의 배열</ko>\n\t * @param {Array} [outline=[]] Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {Object} Layouted items and outline of start and end <ko> 레이아웃이 된 아이템과 시작과 끝의 아웃라인이 담긴 정보</ko>\n\t * @example\n\t * layout.prepend(items, [100]);\n\t */\n\tpublic prepend(items: IInfiniteGridItem[], outline?: number[], cache?: boolean) {\n\t\treturn this._insert(items, outline, false, cache);\n\t}\n\t/**\n\t * Adds items of groups at the bottom of a outline.\n\t * @ko 그룹들의 아이템들을 아웃라인 아래에 추가한다.\n\t * @method eg.InfiniteGrid.PackingLayout#layout\n\t * @param {Array} groups Array of groups to be layouted <ko>레이아웃할 그룹들의 배열</ko>\n\t * @param {Array} outline Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {eg.InfiniteGrid.PackingLayout} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * layout.layout(groups, [100, 200, 300, 400]);\n\t */\n\tpublic layout(groups: IInfiniteGridGroup[] = [], outline: number[] = []) {\n\t\tconst length = groups.length;\n\t\tlet point = outline;\n\n\t\tfor (let i = 0; i < length; ++i) {\n\t\t\tconst group = groups[i];\n\t\t\tconst outlines = this._layout(group.items, point, true);\n\n\t\t\tgroup.outlines = outlines;\n\t\t\tpoint = outlines.end;\n\t\t}\n\t\treturn this;\n\t}\n\t/**\n\t * Set the viewport size of the layout.\n\t * @ko 레이아웃의 가시 사이즈를 설정한다.\n\t * @method eg.InfiniteGrid.PackingLayout#setSize\n\t * @param {Number} size The viewport size of container area where items are added to a layout <ko>레이아웃에 아이템을 추가하는 컨테이너 영역의 가시 사이즈</ko>\n\t * @return {eg.InfiniteGrid.PackingLayout} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * layout.setSize(800);\n\t */\n\tpublic setSize(size: number) {\n\t\tthis._size = size;\n\t\treturn this;\n\t}\n\tprivate _findBestFitArea(container: BoxModel, item: BoxModel) {\n\t\tif (container.getRatio() === 0) { // 아이템 최초 삽입시 전체영역 지정\n\t\t\tcontainer.originWidth = item.width;\n\t\t\tcontainer.originHeight = item.height;\n\t\t\tcontainer.width = item.width;\n\t\t\tcontainer.height = item.height;\n\t\t\treturn;\n\t\t}\n\n\t\tlet bestFitArea!: BoxModel;\n\t\tlet minCost = 10000000;\n\t\tlet layoutVertical = false;\n\t\tconst itemFitSize: ISize = {\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t};\n\t\tconst containerFitSize: ISize = {\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t};\n\t\tconst { sizeWeight, ratioWeight } = this.options;\n\n\t\tcontainer.items.forEach(v => {\n\t\t\tconst containerSizeCost = getCost(v.getOriginSize(), v.getSize()) * sizeWeight;\n\t\t\tconst containerRatioCost = getCost(v.getOriginRatio(), v.getRatio()) * ratioWeight;\n\t\t\tconst width = v.width;\n\t\t\tconst height = v.height;\n\t\t\tlet cost;\n\n\t\t\tfor (let i = 0; i < 2; ++i) {\n\t\t\t\tlet itemWidth;\n\t\t\t\tlet itemHeight;\n\t\t\t\tlet containerWidth;\n\t\t\t\tlet containerHeight;\n\n\t\t\t\tif (i === 0) {\n\t\t\t\t\t// 상하에 아이템 추가\n\t\t\t\t\titemWidth = width;\n\t\t\t\t\titemHeight = height * (item.height / (v.originHeight + item.height));\n\t\t\t\t\tcontainerWidth = width;\n\t\t\t\t\tcontainerHeight = height - itemHeight;\n\t\t\t\t} else {\n\t\t\t\t\t// 좌우에 아이템 추가\n\t\t\t\t\titemHeight = height;\n\t\t\t\t\titemWidth = width * (item.width / (v.originWidth + item.width));\n\t\t\t\t\tcontainerHeight = height;\n\t\t\t\t\tcontainerWidth = width - itemWidth;\n\t\t\t\t}\n\n\t\t\t\tconst itemSize = itemWidth * itemHeight;\n\t\t\t\tconst itemRatio = itemWidth / itemHeight;\n\t\t\t\tconst containerSize = containerWidth * containerHeight;\n\t\t\t\tconst containerRatio = containerHeight / containerHeight;\n\n\t\t\t\tcost = getCost(item.getSize(), itemSize) * sizeWeight;\n\t\t\t\tcost += getCost(item.getRatio(), itemRatio) * ratioWeight;\n\t\t\t\tcost += getCost(v.getOriginSize(), containerSize) * sizeWeight - containerSizeCost;\n\t\t\t\tcost += getCost(v.getOriginRatio(), containerRatio) * ratioWeight - containerRatioCost;\n\n\t\t\t\tif (cost === Math.min(cost, minCost)) {\n\t\t\t\t\tminCost = cost;\n\t\t\t\t\tbestFitArea = v;\n\t\t\t\t\tlayoutVertical = (i === 0);\n\t\t\t\t\titemFitSize.width = itemWidth;\n\t\t\t\t\titemFitSize.height = itemHeight;\n\t\t\t\t\tcontainerFitSize.width = containerWidth;\n\t\t\t\t\tcontainerFitSize.height = containerHeight;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tfitArea(item, bestFitArea, itemFitSize, containerFitSize, layoutVertical);\n\t}\n\tprivate _layout(items: IInfiniteGridItem[], outline: number[] = [], isAppend?: boolean) {\n\t\tconst style = this._style;\n\t\tconst { horizontal, aspectRatio, margin } = this.options;\n\t\tconst pos1Name = style.startPos1;\n\t\tconst containerWidth = this._size * (horizontal ? aspectRatio : 1);\n\t\tconst containerHeight = this._size / (horizontal ? 1 : aspectRatio);\n\t\tconst containerSize1 = horizontal ? containerWidth : containerHeight;\n\t\tconst prevOutline = toZeroArray(outline);\n\t\tconst start = isAppend ? Math.max(...prevOutline) :\n\t\t\tMath.min(...prevOutline) - containerSize1 - margin;\n\t\tconst end = start + containerSize1 + margin;\n\t\tconst container = new BoxModel({});\n\n\t\titems.forEach(item => {\n\t\t\tconst { width, height } = item.orgSize!;\n\t\t\tconst model = new BoxModel({\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\toriginWidth: width,\n\t\t\t\toriginHeight: height,\n\t\t\t});\n\n\t\t\tthis._findBestFitArea(container, model);\n\t\t\tcontainer.push(model);\n\t\t\tcontainer.scaleTo(containerWidth + margin, containerHeight + margin);\n\t\t});\n\t\titems.forEach((item, i) => {\n\t\t\tconst boxItem = container.items[i];\n\t\t\tconst width = boxItem.width;\n\t\t\tconst height = boxItem.height;\n\t\t\tconst top = boxItem.top;\n\t\t\tconst left = boxItem.left;\n\n\t\t\titem.rect = { top, left, width: width - margin, height: height - margin };\n\t\t\titem.rect[pos1Name] += start;\n\t\t});\n\n\t\treturn {\n\t\t\tstart: [start],\n\t\t\tend: [end],\n\t\t};\n\t}\n\tprivate _insert(items: IInfiniteGridItem[] = [], outline: number[] = [], isAppend?: boolean, cache?: boolean) {\n\t\t// this only needs the size of the item.\n\t\tconst clone = cache ? items : cloneItems(items);\n\n\t\treturn {\n\t\t\titems: clone,\n\t\t\toutlines: this._layout(clone, outline, isAppend),\n\t\t};\n\t}\n}\n\nexport default PackingLayout;\n","/* eslint-disable */\n/******************************************************************************\n * Created 2008-08-19.\n *\n * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.\n *\n * Copyright (C) 2008\n *   Wyatt Baldwin <self@wyattbaldwin.com>\n *   All rights reserved\n *\n * Licensed under the MIT license.\n *\n *   http://www.opensource.org/licenses/mit-license.php\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *****************************************************************************/\nfunction single_source_shortest_paths(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\t// Predecessor map for each node that has been encountered.\n\t// node ID => predecessor node ID\n\tconst predecessors: { [key: string]: string } = {};\n\t// Costs of shortest paths from s to all nodes encountered.\n\t// node ID => cost\n\tconst costs: { [key: string]: number } = {};\n\tcosts[s] = 0;\n\n\t// Costs of shortest paths from s to all nodes encountered; differs from\n\t// `costs` in that it provides easy access to the node that currently has\n\t// the known shortest path from s.\n\t// XXX: Do we actually need both `costs` and `open`?\n\tconst open = new BinaryHeap<{ value: string, cost: number }>(x => x.cost);\n\topen.push({ value: s, cost: 0 });\n\n\tlet closest;\n\tlet u;\n\tlet cost_of_s_to_u;\n\tlet adjacent_nodes;\n\tlet cost_of_e;\n\tlet cost_of_s_to_u_plus_cost_of_e;\n\tlet cost_of_s_to_v;\n\tlet first_visit: boolean;\n\n\twhile (open.size()) {\n\t\t// In the nodes remaining in graph that have a known cost from s,\n\t\t// find the node, u, that currently has the shortest path from s.\n\t\tclosest = open.pop();\n\t\tu = closest.value;\n\t\tcost_of_s_to_u = closest.cost;\n\n\t\t// Get nodes adjacent to u...\n\t\tadjacent_nodes = graph(u) || {};\n\n\t\t// ...and explore the edges that connect u to those nodes, updating\n\t\t// the cost of the shortest paths to any or all of those nodes as\n\t\t// necessary. v is the node across the current edge from u.\n\t\tfor (const v in adjacent_nodes) {\n\t\t\t// Get the cost of the edge running from u to v.\n\t\t\tcost_of_e = adjacent_nodes[v];\n\n\t\t\t// Cost of s to u plus the cost of u to v across e--this is *a*\n\t\t\t// cost from s to v that may or may not be less than the current\n\t\t\t// known cost to v.\n\t\t\tcost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;\n\n\t\t\t// If we haven't visited v yet OR if the current known cost from s to\n\t\t\t// v is greater than the new cost we just found (cost of s to u plus\n\t\t\t// cost of u to v across e), update v's cost in the cost list and\n\t\t\t// update v's predecessor in the predecessor list (it's now u).\n\t\t\tcost_of_s_to_v = costs[v];\n\t\t\tfirst_visit = (typeof costs[v] === \"undefined\");\n\t\t\tif (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {\n\t\t\t\tcosts[v] = cost_of_s_to_u_plus_cost_of_e;\n\t\t\t\topen.push({ value: v, cost: cost_of_s_to_u_plus_cost_of_e });\n\t\t\t\tpredecessors[v] = u;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (typeof costs[d] === \"undefined\") {\n\t\tconst msg = [\"Could not find a path from \", s, \" to \", d, \".\"].join(\"\");\n\t\tthrow new Error(msg);\n\t}\n\n\treturn predecessors;\n}\nfunction extract_shortest_path_from_predecessor_list(\n\tpredecessors: { [key: string]: string },\n\td: string,\n) {\n\tconst nodes: string[] = [];\n\tlet u = d;\n\n\twhile (u) {\n\t\tnodes.push(u);\n\t\tu = predecessors[u];\n\t}\n\tnodes.reverse();\n\treturn nodes;\n}\nfunction find_path(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\tconst predecessors = single_source_shortest_paths(graph, s, d);\n\n\treturn extract_shortest_path_from_predecessor_list(predecessors, d);\n}\n\nclass BinaryHeap<T> {\n\tprivate content: T[];\n\tprivate scoreFunction: (x: T) => number;\n\n\tconstructor(scoreFunction: (x: T) => number) {\n\t\tthis.content = [];\n\t\tthis.scoreFunction = scoreFunction;\n\t}\n\tpublic push(element: T) {\n\t\t// Add the new element to the end of the array.\n\t\tthis.content.push(element);\n\t\t// Allow it to bubble up.\n\t\tthis.bubbleUp(this.content.length - 1);\n\t}\n\tpublic pop() {\n\t\t// Store the first element so we can return it later.\n\t\tconst result = this.content[0];\n\t\t// Get the element at the end of the array.\n\t\tconst end = this.content.pop()!;\n\t\t// If there are any elements left, put the end element at the\n\t\t// start, and let it sink down.\n\t\tif (this.content.length > 0) {\n\t\t\tthis.content[0] = end;\n\t\t\tthis.sinkDown(0);\n\t\t}\n\t\treturn result;\n\t}\n\tpublic size() {\n\t\treturn this.content.length;\n\t}\n\tpublic bubbleUp(_n: number) {\n\t\tlet n = _n;\n\t\t// Fetch the element that has to be moved.\n\t\tconst element = this.content[n];\n\t\t// When at 0, an element can not go up any further.\n\t\twhile (n > 0) {\n\t\t\t// Compute the parent element's index, and fetch it.\n\t\t\tconst parentN = Math.floor((n + 1) / 2) - 1;\n\t\t\tconst parent = this.content[parentN];\n\n\t\t\t// Swap the elements if the parent is greater.\n\t\t\tif (this.scoreFunction(element) < this.scoreFunction(parent)) {\n\t\t\t\tthis.content[parentN] = element;\n\t\t\t\tthis.content[n] = parent;\n\t\t\t\t// Update 'n' to continue at the new position.\n\t\t\t\tn = parentN;\n\t\t\t} else {\n\t\t\t\t// Found a parent that is less, no need to move it further.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tpublic sinkDown(n: number) {\n\t\t// Look up the target element and its score.\n\t\tconst length = this.content.length;\n\t\tconst element = this.content[n];\n\t\tconst elemScore = this.scoreFunction(element);\n\t\tlet child1Score;\n\n\t\twhile (true) {\n\t\t\t// Compute the indices of the child elements.\n\t\t\tconst child2N = (n + 1) * 2;\n\t\t\tconst child1N = child2N - 1;\n\t\t\t// This is used to store the new position of the element,\n\t\t\t// if any.\n\t\t\tlet swap: number | null = null;\n\t\t\t// If the first child exists (is inside the array)...\n\t\t\tif (child1N < length) {\n\t\t\t\t// Look it up and compute its score.\n\t\t\t\tconst child1 = this.content[child1N];\n\t\t\t\tchild1Score = this.scoreFunction(child1);\n\t\t\t\t// If the score is less than our element's, we need to swap.\n\t\t\t\tif (child1Score < elemScore) {\n\t\t\t\t\tswap = child1N;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Do the same checks for the other child.\n\t\t\tif (child2N < length) {\n\t\t\t\tconst child2 = this.content[child2N];\n\t\t\t\tconst child2Score = this.scoreFunction(child2);\n\n\t\t\t\tif (child2Score < (swap == null ? elemScore : child1Score)) {\n\t\t\t\t\tswap = child2N;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If the element needs to be moved, swap it, and continue.\n\t\t\tif (swap !== null) {\n\t\t\t\tthis.content[n] = this.content[swap];\n\t\t\t\tthis.content[swap] = element;\n\t\t\t\tn = swap;\n\t\t\t} else {\n\t\t\t\t// Otherwise, we are done.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport { find_path };\n","import { find_path } from \"./lib/dijkstra\";\nimport { getStyleNames, assignOptions, cloneItems } from \"../utils\";\nimport { ILayout, IRectlProperties, SizeType, IInfiniteGridItem, IInfiniteGridGroup } from \"../types\";\n\n/**\n * @classdesc 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedLayout is a layout that the card is filled up on the basis of a line given a size.\n * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. 용어의 의미대로 너비가 주어진 사이즈를 기준으로 카드가 가득 차도록 배치하는 레이아웃이다.\n * @class eg.InfiniteGrid.JustifiedLayout\n * @param {Object} [options] The option object of eg.InfiniteGrid.JustifiedLayout module <ko>eg.InfiniteGrid.JustifiedLayout 모듈의 옵션 객체</ko>\n * @param {String} [options.margin=0] Margin used to create space around items <ko>아이템들 사이의 공간</ko>\n * @param {Boolean} [options.horizontal=false] Direction of the scroll movement (false: vertical, true: horizontal) <ko>스크롤 이동 방향 (false: 세로방향, true: 가로방향)</ko>\n * @param {Number} [options.minSize=0] Minimum size of item to be resized <ko> 아이템이 조정되는 최소 크기 </ko>\n * @param {Number} [options.maxSize=0] Maximum size of item to be resized <ko> 아이템이 조정되는 최대 크기 </ko>\n * @param {Array|Number} [options.column=[1, 8]] The number of items in a line <ko> 한 줄에 들어가는 아이템의 개수 </ko>\n * @example\n```\n<script>\nvar ig = new eg.InfiniteGrid(\"#grid\". {\n  horizontal: true,\n});\n\nig.setLayout(eg.InfiniteGrid.JustifiedLayout, {\n  margin: 10,\n  minSize: 100,\n  maxSize: 300,\n});\n\n// or\n\nvar layout = new eg.InfiniteGrid.JustifiedLayout({\n  margin: 10,\n  minSize: 100,\n  maxSize: 300,\n  column: 5,\n  horizontal: true,\n});\n\n</script>\n```\n **/\nclass JustifiedLayout implements ILayout {\n\tpublic options: {\n\t\tmargin: number;\n\t\tminSize: number;\n\t\tmaxSize: number;\n\t\tcolumn: number | number[];\n\t\thorizontal: boolean;\n\t};\n\tprivate _style: IRectlProperties;\n\tprivate _size: number;\n\n\tconstructor(options: Partial<JustifiedLayout[\"options\"]> = {}) {\n\t\tthis.options = assignOptions({\n\t\t\tmargin: 0,\n\t\t\thorizontal: false,\n\t\t\tminSize: 0,\n\t\t\tmaxSize: 0,\n\t\t\tcolumn: [1, 8],\n\t\t}, options);\n\n\t\tthis._style = getStyleNames(this.options.horizontal);\n\t\tthis._size = 0;\n\t}\n\t/**\n\t * Set the viewport size of the layout.\n\t * @ko 레이아웃의 가시 사이즈를 설정한다.\n\t * @method eg.InfiniteGrid.JustifiedLayout#setSize\n\t * @param {Number} size The viewport size of container area where items are added to a layout <ko>레이아웃에 아이템을 추가하는 컨테이너 영역의 가시 사이즈</ko>\n\t * @return {eg.InfiniteGrid.JustifiedLayout} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * layout.setSize(800);\n\t */\n\tpublic setSize(size: number) {\n\t\tthis._size = size;\n\t\treturn this;\n\t}\n\t/**\n\t * Adds items at the bottom of a outline.\n\t * @ko 아이템들을 아웃라인 아래에 추가한다.\n\t * @method eg.InfiniteGrid.JustifiedLayout#append\n\t * @param {Array} items Array of items to be layouted <ko>레이아웃할 아이템들의 배열</ko>\n\t * @param {Array} [outline=[]] Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {Object} Layouted items and outline of start and end <ko> 레이아웃이 된 아이템과 시작과 끝의 아웃라인이 담긴 정보</ko>\n\t * @example\n\t * layout.prepend(items, [100]);\n\t */\n\tpublic append(items: IInfiniteGridItem[], outline?: number[], cache?: boolean) {\n\t\treturn this._insert(items, outline, true, cache);\n\t}\n\t/**\n\t * Adds items at the top of a outline.\n\t * @ko 아이템을 아웃라인 위에 추가한다.\n\t * @method eg.InfiniteGrid.JustifiedLayout#prepend\n\t * @param {Array} items Array of items to be layouted <ko>레이아웃할 아이템들의 배열</ko>\n\t * @param {Array} [outline=[]] Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {Object} Layouted items and outline of start and end <ko> 레이아웃이 된 아이템과 시작과 끝의 아웃라인이 담긴 정보</ko>\n\t * @example\n\t * layout.prepend(items, [100]);\n\t */\n\tpublic prepend(items: IInfiniteGridItem[], outline?: number[], cache?: boolean) {\n\t\treturn this._insert(items, outline, false, cache);\n\t}\n\t/**\n\t * Adds items of groups at the bottom of a outline.\n\t * @ko 그룹들의 아이템들을 아웃라인 아래에 추가한다.\n\t * @method eg.InfiniteGrid.JustifiedLayout#layout\n\t * @param {Array} groups Array of groups to be layouted <ko>레이아웃할 그룹들의 배열</ko>\n\t * @param {Array} outline Array of outline points to be reference points <ko>기준점이 되는 아웃라인 점들의 배열</ko>\n\t * @return {eg.InfiniteGrid.JustifiedLayout} An instance of a module itself<ko>모듈 자신의 인스턴스</ko>\n\t * @example\n\t * layout.layout(groups, [100]);\n\t */\n\tpublic layout(groups: IInfiniteGridGroup[] = [], outline: number[] = []) {\n\t\tconst length = groups.length;\n\t\tlet point = outline;\n\n\t\tfor (let i = 0; i < length; ++i) {\n\t\t\tconst group = groups[i];\n\t\t\tconst outlines = this._layout(group.items, point, true);\n\n\t\t\tgroup.outlines = outlines;\n\t\t\tpoint = outlines.end;\n\t\t}\n\t\treturn this;\n\t}\n\tprivate _layout(items: IInfiniteGridItem[], outline: number[], isAppend?: boolean) {\n\t\tconst style = this._style;\n\t\tconst size1Name = style.size1;\n\t\tconst size2Name = style.size2;\n\t\tconst startIndex = 0;\n\t\tconst endIndex = items.length;\n\t\tconst column = this.options.column;\n\t\tconst columns: number[] = (typeof column === \"object\") ? column : [column, column];\n\n\t\tconst graph = (_start: string) => {\n\t\t\tconst results: { [key: string]: number } = {};\n\t\t\tconst start = +_start.replace(/[^0-9]/g, \"\");\n\t\t\tconst length = endIndex + 1;\n\n\t\t\tfor (let i = Math.min(start + columns[0], length - 1); i < length; ++i) {\n\t\t\t\tif (i - start > columns[1]) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tlet cost = this._getCost(items, start, i, size1Name, size2Name);\n\n\t\t\t\tif (cost === null) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (cost < 0 && i === length - 1) {\n\t\t\t\t\tcost = 0;\n\t\t\t\t}\n\t\t\t\tresults[`${i}`] = Math.pow(cost, 2);\n\t\t\t}\n\t\t\treturn results;\n\t\t};\n\t\t// shortest path for items' total height.\n\t\tconst path = find_path(graph, `${startIndex}`, `${endIndex}`);\n\n\t\treturn this._setStyle(items, path, outline, isAppend);\n\t}\n\tprivate _getSize(items: IInfiniteGridItem[], size1Name: SizeType, size2Name: SizeType) {\n\t\tconst margin = this.options.margin;\n\t\tconst size = items.reduce((sum, item) => sum +\n\t\t\t(item.orgSize![size2Name]) / item.orgSize![size1Name], 0);\n\n\t\treturn (this._size - margin * (items.length - 1)) / size;\n\t}\n\tprivate _getCost(\n\t\titems: IInfiniteGridItem[],\n\t\ti: number,\n\t\tj: number,\n\t\tsize1Name: SizeType,\n\t\tsize2Name: SizeType,\n\t) {\n\t\tconst size = this._getSize(items.slice(i, j), size1Name, size2Name);\n\t\tconst min = this.options.minSize || 0;\n\t\tconst max = this.options.maxSize || Infinity;\n\n\t\tif (isFinite(max)) {\n\t\t\t// if this size is not in range, the cost increases sharply.\n\t\t\tif (size < min) {\n\t\t\t\treturn Math.pow(size - min, 2) + Math.pow(max, 2);\n\t\t\t} else if (size > max) {\n\t\t\t\treturn Math.pow(size - max, 2) + Math.pow(max, 2);\n\t\t\t} else {\n\t\t\t\t// if this size in range, the cost is negative or low.\n\t\t\t\treturn Math.min(size - max, min - size);\n\t\t\t}\n\t\t}\n\t\t// if max is infinite type, caculate cost only with \"min\".\n\t\tif (size < min) {\n\t\t\treturn Math.max(Math.pow(min, 2), Math.pow(size, 2));\n\t\t}\n\t\treturn size - min;\n\t}\n\tprivate _setStyle(\n\t\titems: IInfiniteGridItem[],\n\t\tpath: string[],\n\t\toutline: number[] = [],\n\t\tisAppend?: boolean,\n\t) {\n\t\tconst style = this._style;\n\t\t// if direction is vertical\n\t\t// startPos1 : top, endPos1 : bottom\n\t\t// size1 : height\n\t\t// startPos2 : left, endPos2 : right\n\t\t// size2 : width\n\n\t\t// if direction is horizontal\n\t\t// startPos1 : left, endPos1 : right\n\t\t// size1 : width\n\t\t// startPos2 : top, endPos2 : bottom\n\t\t// size2 : height\n\t\tconst pos1Name = style.startPos1;\n\t\tconst size1Name = style.size1;\n\t\tconst pos2Name = style.startPos2;\n\t\tconst size2Name = style.size2;\n\t\tconst length = path.length;\n\t\tconst margin = this.options.margin;\n\t\tconst startPoint = outline[0] || 0;\n\t\tlet endPoint = startPoint;\n\t\tlet height = 0;\n\n\t\tfor (let i = 0; i < length - 1; ++i) {\n\t\t\tconst path1 = parseInt(path[i], 10);\n\t\t\tconst path2 = parseInt(path[i + 1], 10);\n\t\t\t// pathItems(path1 to path2) are in 1 line.\n\t\t\tconst pathItems = items.slice(path1, path2);\n\t\t\tconst pathItemsLength = pathItems.length;\n\t\t\tconst size1 = this._getSize(pathItems, size1Name, size2Name);\n\t\t\tconst pos1 = endPoint;\n\n\t\t\tfor (let j = 0; j < pathItemsLength; ++j) {\n\t\t\t\tconst item = pathItems[j];\n\t\t\t\tconst size2 = item.orgSize![size2Name] / item.orgSize![size1Name] * size1;\n\t\t\t\t// item has margin bottom and right.\n\t\t\t\t// first item has not margin.\n\t\t\t\tconst prevItemRect = j === 0 ? 0 : pathItems[j - 1].rect;\n\t\t\t\tconst pos2 = (prevItemRect ? prevItemRect[pos2Name] + prevItemRect[size2Name]! + margin : 0);\n\n\t\t\t\titem.rect = {\n\t\t\t\t\t[pos1Name]: pos1,\n\t\t\t\t\t[pos2Name]: pos2,\n\t\t\t\t\t[size1Name]: size1,\n\t\t\t\t\t[size2Name]: size2,\n\t\t\t\t} as any;\n\t\t\t}\n\t\t\theight += margin + size1;\n\t\t\tendPoint = startPoint + height;\n\t\t}\n\t\tconst itemsLength = items.length;\n\n\t\tif (isAppend) {\n\t\t\t// previous group's end outline is current group's start outline\n\t\t\treturn {\n\t\t\t\tstart: [startPoint],\n\t\t\t\tend: [endPoint],\n\t\t\t};\n\t\t}\n\t\t// for prepend, only substract height from position.\n\t\t// always start is lower than end.\n\n\t\tfor (let i = 0; i < itemsLength; ++i) {\n\t\t\tconst item = items[i];\n\n\t\t\t// move items as long as height for prepend\n\t\t\titem.rect[pos1Name] -= height;\n\t\t}\n\t\treturn {\n\t\t\tstart: [startPoint - height],\n\t\t\tend: [startPoint], // endPoint - height = startPoint\n\t\t};\n\t}\n\tprivate _insert(items: IInfiniteGridItem[] = [], outline: number[] = [], isAppend?: boolean, cache?: boolean) {\n\t\t// this only needs the size of the item.\n\t\tconst clone = cache ? items : cloneItems(items);\n\n\t\treturn {\n\t\t\titems: clone,\n\t\t\toutlines: this._layout(clone, outline, isAppend),\n\t\t};\n\t}\n}\n\nexport default JustifiedLayout;\n","/**\n * Copyright (c) NAVER Corp.\n * egjs-infinitegrid projects are licensed under the MIT license\n */\nimport InfiniteGrid from \"./InfiniteGrid\";\nimport GridLayout from \"./layouts/GridLayout\";\nimport FrameLayout from \"./layouts/FrameLayout\";\nimport SquareLayout from \"./layouts/SquareLayout\";\nimport PackingLayout from \"./layouts/PackingLayout\";\nimport JustifiedLayout from \"./layouts/JustifiedLayout\";\nimport DOMRenderer from \"./DOMRenderer\";\nimport ItemManager from \"./ItemManager\";\nimport Infinite from \"./Infinite\";\nimport {\n\tCONTAINER_CLASSNAME, IGNORE_CLASSNAME,\n\tDEFAULT_OPTIONS, INFINITEGRID_METHODS,\n\tINFINITEGRID_EVENTS,\n} from \"./consts\";\nimport { categorize, withInfiniteGridMethods } from \"./utils\";\n\n// fix for IE8\n(InfiniteGrid as any).categorize = categorize;\n(InfiniteGrid as any).INFINITEGRID_METHODS = INFINITEGRID_METHODS;\n(InfiniteGrid as any).INFINITEGRID_EVENTS = INFINITEGRID_EVENTS;\n(InfiniteGrid as any).withInfiniteGridMethods = withInfiniteGridMethods;\n(InfiniteGrid as any).CONTAINER_CLASSNAME = CONTAINER_CLASSNAME;\n(InfiniteGrid as any).IGNORE_CLASSNAME = IGNORE_CLASSNAME;\n(InfiniteGrid as any).DEFAULT_OPTIONS = DEFAULT_OPTIONS;\n(InfiniteGrid as any).GridLayout = GridLayout;\n(InfiniteGrid as any).FrameLayout = FrameLayout;\n(InfiniteGrid as any).SquareLayout = SquareLayout;\n(InfiniteGrid as any).PackingLayout = PackingLayout;\n(InfiniteGrid as any).JustifiedLayout = JustifiedLayout;\n(InfiniteGrid as any).ItemManager = ItemManager;\n(InfiniteGrid as any).Infinite = Infinite;\n(InfiniteGrid as any).DOMRenderer = DOMRenderer;\n(InfiniteGrid as any).default = InfiniteGrid;\n\nexport default InfiniteGrid;\n"],"names":["win","window","document","navigator","userAgent","ua","SUPPORT_COMPUTEDSTYLE","SUPPORT_ADDEVENTLISTENER","SUPPORT_PASSIVE","supportsPassiveOption","Object","defineProperty","addEventListener","get","e","IS_IE","test","IS_IOS","IS_ANDROID2","CONTAINER_CLASSNAME","IGNORE_CLASSNAME","TRANSITION_NAME","VERTICAL","HORIZONTAL","DUMMY_POSITION","GROUPKEY_ATT","DEFAULT_OPTIONS","itemSelector","isOverflowScroll","threshold","isEqualSize","isConstantSize","useRecycle","horizontal","transitionDuration","useFit","attributePrefix","renderExternal","DEFAULT_LAYOUT_OPTIONS","margin","agent","toLowerCase","isMobile","ALIGN","START","CENTER","END","JUSTIFY","IDLE","LOADING_APPEND","LOADING_PREPEND","PROCESSING","webkit","exec","WEBKIT_VERSION","parseInt","DEFENSE_BROWSER","ITEM_KEYS","TRANSFORM","TRANSITION","TRANSITION_END","INFINITEGRID_EVENTS","INFINITEGRID_METHODS","getLoadingBar","getItem","getItems","layout","getGroupKeys","getStatus","setStatus","isProcessing","startLoading","endLoading","isLoading","updateItem","updateItems","moveTo","nodes","array","length","i","push","html","match","param","multi","el","matchHTML","dummy","createElement","innerHTML","childNodes","querySelectorAll","toArray","isWindow","isJQuery","$","Array","isArray","map","v","undefined","nodeName","nodeType","slice","call","element","type","handler","eventListenerOptions","options","attachEvent","removeEventListener","detachEvent","callback","removeEvent","addEvent","prop","body","documentElement","x","y","scroll","scrollLeft","scrollTop","scrollBy","getComputedStyle","currentStyle","name","isOffset","isDocument","doc","Math","max","size","clientRect","getBoundingClientRect","right","left","bottom","top","cssSize","getStyles","indexOf","parseFloat","_getSize","width","outerWidth","height","outerHeight","STYLE","vertical","startPos1","endPos1","size1","startPos2","endPos2","size2","isHorizontal","target","_i","sources","forEach","source","key","defaultOptions","assign","outline","items","item","jQuery","constructor","prototype","jquery","arr","value","newItems","newGroups","groupKeys","groupKey","group","orgSize","mounted","content","outerHTML","rect","infinitegridName","keys","args","result","_a","className","classList","contains","RegExp","add","ItemManager","elements","makeItem","data","property","reduce","acc","concat","_groups","_groupKeys","startKey","endKey","datas","startIndex","endIndex","_data","item2","data2","status","clear","_this","insertGroup","base","groups","outlines","start","end","isUndefined","sliceGroups","pluck","index","cursor","targetValue","Infinity","getOutline","getGroup","getEdgeIndex","startCursor","endCursor","getGroups","pos","groupIndex","prevItems","newGroup","splice","insert","categorize","diff","removed","added","maintained","removedIndex","nextGroups","fromIndex","addedIndex","reverse","toIndex","syncItems","newItem","itemIndex","groupItem","groupItems","removeGroup","getAttribute","nextItems","nextIndex","styles","pos1","pos2","removeTransition","selectContainer","querySelector","style","position","container","children","appendChild","properties","p","view","viewport","_init","resize","DOMRenderer","prevRect","setAttribute","render","setTransition","addOnceEvent","itemRect","renderItem","removeElement","parentNode","removeChild","noElementItems","filter","replace","join","cssText","_size","getSize","isAppend","createElements","renderItems","_insert","_calcSize","isResize","innerWidth","innerHeight","_orgStyle","overflowX","overflowY","createContainer","df","createDocumentFragment","insertBefore","firstChild","scrollPos","endScrollPos","min","itemManger","append","prepend","recycle","_itemManager","_status","itemManager","prevVisisbleGroups","prevVisibleItems","sync","startGroup","find","getGroupByKey","endGroup","findLast","nextStartCursor","nextEndCursor","minCursor","maxCursor","nextVisibleItems","visibleDiffResult","itemKey","isForward","_b","visibles","isVisible","lastIndexOf","setCursor","startEdgePos","endEdgePos","startPos","endPos","cache","cachedAppendData","cachedPrependData","isPrepend","getEdgeOutline","remove","_infinite","_renderer","_layout","callbackComponent","checkGroups","replaceTarget","removeTarget","prefix","check","on","_complete","_error","_end","infinite","prevGroup","updateSize","groupOutline","isRelayout","every","groupInfo","getCursor","requestStartCursor","requestEndCursor","isInCursor","tempCursor","trigger","errorIndex","removeItem","hasTarget","src","removeAutoSizer","removeAttribute","replaceItem","totalIndex","removeTargetLength","replaceTargetLength","layoutedItems","prevPos","getScrollPos","orgScrollPos","getOrgScrollPos","setScrollPos","_isScrollIssue","_timer","clearTimeout","setTimeout","_view","_prevPos","applyScrollPos","scrollTo","arrPos","getContainerOffset","_onCheck","_onResize","_containerOffset","_getOffset","reset","tslib_1","_super","_reset","_watcher","Watcher","Infinite","_requestAppend","_requestPrepend","_recycle","_renderManager","RenderManager","LayoutKlass","setLayout","_setSize","getViewportSize","includeCached","getVisibleItems","itemKeys","nextVisisbleItems","_requestGroups","getRenderingItems","isChange","_isProcessing","_postLayout","fromCache","getVisibleData","isTrusted","firstGroup","hasChildren","renderer","isLayoutAll","children_1","getContainerSize","setContainerSize","_relayout","_fit","clearOutlines","_onLayoutComplete","isLayout","removeByIndex","syncElements","watcher","processingStatus","visibleItems","createAndInsert","isReLayout","isNeededResize","_appendLoadingBar","userLoadingBar","loadingBarObj","loadingSize","loadingStyle","loadingBar","_loadingBar","isChangeLoadingBar","loadingElement","hasClass","addClass","_renderLoading","_getLoadingStatus","userStyle","display","_process","next","_setContainerSize","_getEdgeValue","_fitItems","_updateItem","fit","_scrollTo","_setScrollPos","_postCache","destroy","layoutGroups","getMaxEdgeValue","setSize","getViewSize","getEdgeValue","isAdd","toItems","_insertItems","_c","ranges","isRecycle","some","removeItems","posName","resetSize","Component","_setCursor","layoutItems","scroller","pop","shift","_d","_e","viewSize","isScroll","InfiniteGrid","assignOptions","align","itemSize","_columnSize","_columnLength","_style","getStyleNames","firstItem","checkColumn","startOutline","fill","sizeName","columnSize","floor","size1Name","size2Name","pos1Name","pos2Name","columnLength","viewDist","pointCaculateName","indexCaculateName","endOutline","point","column","sort","a","b","item1pos1","item1pos2","item2pos1","item2pos2","clone","cloneItems","frame","j","disableFrame","shapes","searchShapeInFrame","frameFill","row","_itemSize","_shapes","getShapes","_checkItemSize","_getItemSize","isItemObject","itemSize2","itemSize1","shapesSize","shapesLength","dist","shape","shapePos1","shapePos2","shapeSize1","shapeSize2","k","targetOutline","prevOutlineEnd","prevOutlineDist","l","_getSquareSize","makeShapeOutline","sign","columnWidth","getColumn","columnCount","shape1","shape2","frameSize","FrameLayout","originWidth","originHeight","scaleX","scaleY","originLength","cost","bestFitArea","itemFitSize","containerFitSize","layoutVertical","aspectRatio","sizeWeight","ratioWeight","getRatio","minCost","containerSizeCost","getCost","getOriginSize","containerRatioCost","getOriginRatio","itemWidth","itemHeight","containerWidth","containerHeight","itemRatio","containerSize","containerRatio","fitArea","containerSize1","prevOutline","toZeroArray","BoxModel","model","_findBestFitArea","scaleTo","boxItem","graph","s","d","predecessors","costs","open","BinaryHeap","closest","u","cost_of_s_to_u","adjacent_nodes","cost_of_e","cost_of_s_to_u_plus_cost_of_e","cost_of_s_to_v","first_visit","msg","Error","single_source_shortest_paths","extract_shortest_path_from_predecessor_list","scoreFunction","bubbleUp","sinkDown","_n","n","parentN","parent","elemScore","child1Score","child2N","child1N","swap","child1","child2","child2Score","minSize","maxSize","columns","_start","results","_getCost","pow","path","find_path","_setStyle","sum","isFinite","startPoint","endPoint","path1","path2","pathItems","pathItemsLength","prevIt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