UNPKG

108 kBJavaScriptView Raw
1/*
2Copyright (c) NAVER Corp.
3name: @egjs/infinitegrid
4license: MIT
5author: NAVER Corp.
6repository: https://github.com/naver/egjs-infinitegrid
7version: 4.6.0
8*/
9import Component, { ComponentEvent } from '@egjs/component';
10import Grid, { GRID_PROPERTY_TYPES, GridItem, MOUNT_STATE, withMethods, UPDATE_STATE, PROPERTY_TYPE, GetterSetter, DEFAULT_GRID_OPTIONS, getUpdatedItems, ContainerManager, ItemRenderer, MasonryGrid, JustifiedGrid, FrameGrid, PackingGrid } from '@egjs/grid';
11import { diff } from '@egjs/list-differ';
12
13/*! *****************************************************************************
14Copyright (c) Microsoft Corporation.
15
16Permission to use, copy, modify, and/or distribute this software for any
17purpose with or without fee is hereby granted.
18
19THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
20REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
21AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
22INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25PERFORMANCE OF THIS SOFTWARE.
26***************************************************************************** */
27
28/* global Reflect, Promise */
29var extendStatics = function (d, b) {
30 extendStatics = Object.setPrototypeOf || {
31 __proto__: []
32 } instanceof Array && function (d, b) {
33 d.__proto__ = b;
34 } || function (d, b) {
35 for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
36 };
37
38 return extendStatics(d, b);
39};
40
41function __extends(d, b) {
42 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
43 extendStatics(d, b);
44
45 function __() {
46 this.constructor = d;
47 }
48
49 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
50}
51var __assign = function () {
52 __assign = Object.assign || function __assign(t) {
53 for (var s, i = 1, n = arguments.length; i < n; i++) {
54 s = arguments[i];
55
56 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
57 }
58
59 return t;
60 };
61
62 return __assign.apply(this, arguments);
63};
64function __rest(s, e) {
65 var t = {};
66
67 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
68
69 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
71 }
72 return t;
73}
74function __decorate(decorators, target, key, desc) {
75 var c = arguments.length,
76 r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
77 d;
78 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
79 return c > 3 && r && Object.defineProperty(target, key, r), r;
80}
81/** @deprecated */
82
83function __spreadArrays() {
84 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
85
86 for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
87
88 return r;
89}
90
91var ua = typeof window !== "undefined" ? window.navigator.userAgent : "";
92var IS_IOS = /iPhone|iPad/.test(ua);
93var CONTAINER_CLASS_NAME = "infinitegrid-container";
94var IGNORE_PROPERITES_MAP = {
95 renderOnPropertyChange: true,
96 useFit: true,
97 autoResize: true
98};
99var INFINITEGRID_PROPERTY_TYPES = __assign({}, GRID_PROPERTY_TYPES);
100var DIRECTION = {
101 START: "start",
102 END: "end",
103 NONE: ""
104};
105var INFINITEGRID_EVENTS = {
106 CHANGE_SCROLL: "changeScroll",
107 REQUEST_APPEND: "requestAppend",
108 REQUEST_PREPEND: "requestPrepend",
109 RENDER_COMPLETE: "renderComplete",
110 CONTENT_ERROR: "contentError"
111}; // type?: ITEM_TYPE;
112// groupKey?: string | number;
113// key?: string | number;
114// element?: HTMLElement | null;
115// html?: string;
116// data?: Record<string, any>;
117
118var ITEM_INFO_PROPERTIES = {
119 type: true,
120 groupKey: true,
121 key: true,
122 element: true,
123 html: true,
124 data: true
125};
126var INFINITEGRID_METHODS = ["insertByGroupIndex", "updateItems", "getItems", "getVisibleItems", "getGroups", "getVisibleGroups", "renderItems", "getContainerElement", "getScrollContainerElement", "getWrapperElement", "setStatus", "getStatus", "removePlaceholders", "prependPlaceholders", "appendPlaceholders", "getStartCursor", "getEndCursor", "setCursors"];
127var GROUP_TYPE;
128
129(function (GROUP_TYPE) {
130 GROUP_TYPE[GROUP_TYPE["NORMAL"] = 0] = "NORMAL";
131 GROUP_TYPE[GROUP_TYPE["VIRTUAL"] = 1] = "VIRTUAL";
132 GROUP_TYPE[GROUP_TYPE["LOADING"] = 2] = "LOADING";
133})(GROUP_TYPE || (GROUP_TYPE = {}));
134
135var ITEM_TYPE;
136
137(function (ITEM_TYPE) {
138 ITEM_TYPE[ITEM_TYPE["NORMAL"] = 0] = "NORMAL";
139 ITEM_TYPE[ITEM_TYPE["VIRTUAL"] = 1] = "VIRTUAL";
140 ITEM_TYPE[ITEM_TYPE["LOADING"] = 2] = "LOADING";
141})(ITEM_TYPE || (ITEM_TYPE = {}));
142
143var STATUS_TYPE;
144
145(function (STATUS_TYPE) {
146 // does not remove anything.
147 STATUS_TYPE[STATUS_TYPE["NOT_REMOVE"] = 0] = "NOT_REMOVE"; // Minimize information on invisible items
148
149 STATUS_TYPE[STATUS_TYPE["MINIMIZE_INVISIBLE_ITEMS"] = 1] = "MINIMIZE_INVISIBLE_ITEMS"; // Minimize information on invisible groups
150
151 STATUS_TYPE[STATUS_TYPE["MINIMIZE_INVISIBLE_GROUPS"] = 2] = "MINIMIZE_INVISIBLE_GROUPS"; // remove invisible groups
152
153 STATUS_TYPE[STATUS_TYPE["REMOVE_INVISIBLE_GROUPS"] = 3] = "REMOVE_INVISIBLE_GROUPS";
154})(STATUS_TYPE || (STATUS_TYPE = {}));
155
156var INVISIBLE_POS = -9999;
157
158/**
159 * @extends Grid.GridItem
160 */
161
162var InfiniteGridItem =
163/*#__PURE__*/
164function (_super) {
165 __extends(InfiniteGridItem, _super);
166
167 function InfiniteGridItem(horizontal, itemStatus) {
168 var _this = _super.call(this, horizontal, __assign({
169 html: "",
170 type: ITEM_TYPE.NORMAL,
171 cssRect: {
172 top: INVISIBLE_POS,
173 left: INVISIBLE_POS
174 }
175 }, itemStatus)) || this;
176
177 if (_this.type === ITEM_TYPE.VIRTUAL) {
178 if (_this.rect.width || _this.rect.height) {
179 _this.mountState = MOUNT_STATE.UNMOUNTED;
180 }
181
182 var orgRect = _this.orgRect;
183 var rect = _this.rect;
184 var cssRect = _this.cssRect;
185
186 if (cssRect.width) {
187 rect.width = cssRect.width;
188 } else if (orgRect.width) {
189 rect.width = orgRect.width;
190 }
191
192 if (cssRect.height) {
193 rect.height = cssRect.height;
194 } else if (orgRect.height) {
195 rect.height = orgRect.height;
196 }
197 }
198
199 return _this;
200 }
201
202 var __proto = InfiniteGridItem.prototype;
203
204 __proto.getVirtualStatus = function () {
205 return {
206 type: ITEM_TYPE.VIRTUAL,
207 groupKey: this.groupKey,
208 key: this.key,
209 orgRect: this.orgRect,
210 rect: this.rect,
211 cssRect: this.cssRect,
212 attributes: this.attributes
213 };
214 };
215
216 __proto.getMinimizedStatus = function () {
217 var status = __assign(__assign({}, _super.prototype.getMinimizedStatus.call(this)), {
218 type: ITEM_TYPE.NORMAL,
219 groupKey: this.groupKey
220 });
221
222 if (this.html) {
223 status.html = this.html;
224 }
225
226 return status;
227 };
228
229 return InfiniteGridItem;
230}(GridItem);
231
232var LOADING_GROUP_KEY = "__INFINITEGRID__LOADING_GRID";
233var LOADING_ITEM_KEY = "__INFINITEGRID__LOADING_ITEM";
234
235var LoadingGrid =
236/*#__PURE__*/
237function (_super) {
238 __extends(LoadingGrid, _super);
239
240 function LoadingGrid() {
241 var _this = _super !== null && _super.apply(this, arguments) || this;
242
243 _this.type = "";
244 return _this;
245 }
246
247 var __proto = LoadingGrid.prototype;
248
249 __proto.getLoadingItem = function () {
250 return this.items[0] || null;
251 };
252
253 __proto.setLoadingItem = function (item) {
254 if (item) {
255 var loadingItem = this.getLoadingItem();
256
257 if (!loadingItem) {
258 this.items = [new InfiniteGridItem(this.options.horizontal, __assign(__assign({}, item), {
259 type: ITEM_TYPE.LOADING,
260 key: LOADING_ITEM_KEY
261 }))];
262 } else {
263 for (var name in item) {
264 loadingItem[name] = item[name];
265 }
266 }
267 } else {
268 this.items = [];
269 }
270 };
271
272 __proto.applyGrid = function (items, direction, outline) {
273 if (!items.length) {
274 return {
275 start: outline,
276 end: outline
277 };
278 }
279
280 var nextOutline = outline.length ? __spreadArrays(outline) : [0];
281 var item = items[0];
282 var offset = item.contentSize + this.gap;
283 item.cssInlinePos = this.getContainerInlineSize() / 2 - item.inlineSize / 2;
284
285 if (direction === "end") {
286 var maxPos = Math.max.apply(Math, nextOutline);
287 item.cssContentPos = maxPos;
288 return {
289 start: nextOutline,
290 end: nextOutline.map(function (pos) {
291 return pos + offset;
292 })
293 };
294 } else {
295 var minPos = Math.min.apply(Math, nextOutline);
296 item.cssContentPos = minPos - offset;
297 return {
298 start: nextOutline.map(function (pos) {
299 return pos - offset;
300 }),
301 end: nextOutline
302 };
303 }
304 };
305
306 return LoadingGrid;
307}(Grid);
308
309function isWindow(el) {
310 return el === window;
311}
312function isNumber(val) {
313 return typeof val === "number";
314}
315function isString(val) {
316 return typeof val === "string";
317}
318function isObject(val) {
319 return typeof val === "object";
320}
321function flat(arr) {
322 return arr.reduce(function (prev, cur) {
323 return __spreadArrays(prev, cur);
324 }, []);
325}
326function splitOptions(options) {
327 var gridOptions = options.gridOptions,
328 otherOptions = __rest(options, ["gridOptions"]);
329
330 return __assign(__assign({}, splitGridOptions(gridOptions)), otherOptions);
331}
332function splitGridOptions(options) {
333 var nextOptions = {};
334 var gridOptions = {};
335 var defaultOptions = Grid.defaultOptions;
336
337 for (var name in options) {
338 var value = options[name];
339
340 if (!(name in IGNORE_PROPERITES_MAP)) {
341 gridOptions[name] = value;
342 }
343
344 if (name in defaultOptions) {
345 nextOptions[name] = value;
346 }
347 }
348
349 return __assign(__assign({}, nextOptions), {
350 gridOptions: gridOptions
351 });
352}
353function categorize(items) {
354 var groups = [];
355 var groupKeys = {};
356 var registeredGroupKeys = {};
357 items.filter(function (item) {
358 return item.groupKey != null;
359 }).forEach(function (_a) {
360 var groupKey = _a.groupKey;
361 registeredGroupKeys[groupKey] = true;
362 });
363 var generatedGroupKey;
364 var isContinuousGroupKey = false;
365 items.forEach(function (item) {
366 if (item.groupKey != null) {
367 isContinuousGroupKey = false;
368 } else {
369 if (!isContinuousGroupKey) {
370 generatedGroupKey = makeKey(registeredGroupKeys);
371 isContinuousGroupKey = true;
372 registeredGroupKeys[generatedGroupKey] = true;
373 }
374
375 item.groupKey = generatedGroupKey;
376 }
377
378 var groupKey = item.groupKey;
379 var group = groupKeys[groupKey];
380
381 if (!group) {
382 group = {
383 groupKey: groupKey,
384 items: []
385 };
386 groupKeys[groupKey] = group;
387 groups.push(group);
388 }
389
390 group.items.push(item);
391 });
392 return groups;
393}
394function getNextCursors(prevKeys, nextKeys, prevStartCursor, prevEndCursor) {
395 var result = diff(prevKeys, nextKeys, function (key) {
396 return key;
397 });
398 var nextStartCursor = -1;
399 var nextEndCursor = -1; // sync cursors
400
401 result.maintained.forEach(function (_a) {
402 var prevIndex = _a[0],
403 nextIndex = _a[1];
404
405 if (prevStartCursor <= prevIndex && prevIndex <= prevEndCursor) {
406 if (nextStartCursor === -1) {
407 nextStartCursor = nextIndex;
408 nextEndCursor = nextIndex;
409 } else {
410 nextStartCursor = Math.min(nextStartCursor, nextIndex);
411 nextEndCursor = Math.max(nextEndCursor, nextIndex);
412 }
413 }
414 });
415 return {
416 startCursor: nextStartCursor,
417 endCursor: nextEndCursor
418 };
419}
420function splitVirtualGroups(groups, direction, nextGroups) {
421 var virtualGroups = [];
422
423 if (direction === "start") {
424 var index = findIndex(groups, function (group) {
425 return group.type === GROUP_TYPE.NORMAL;
426 });
427
428 if (index === -1) {
429 return [];
430 } // Get the virtual group maintained in the group from the next group.
431
432
433 var endMaintainedIndex = findIndex(groups, function (group) {
434 return findIndex(nextGroups, function (nextGroup) {
435 return nextGroup.groupKey === group.groupKey;
436 }) >= 0;
437 });
438 var endIndex = endMaintainedIndex >= 0 ? Math.min(index, endMaintainedIndex) : index;
439 virtualGroups = groups.slice(0, endIndex);
440 } else {
441 var index = findLastIndex(groups, function (group) {
442 return group.type === GROUP_TYPE.NORMAL;
443 });
444
445 if (index === -1) {
446 return [];
447 }
448
449 var startMaintainedIndex = findLastIndex(groups, function (group) {
450 return findIndex(nextGroups, function (nextGroup) {
451 return nextGroup.groupKey === group.groupKey;
452 }) >= 0;
453 });
454 var startIndex = startMaintainedIndex >= 0 ? Math.max(index, startMaintainedIndex) : index;
455 virtualGroups = groups.slice(startIndex + 1);
456 }
457
458 return virtualGroups;
459}
460function getFirstRenderingItems(nextItems, horizontal) {
461 var groups = categorize(nextItems);
462
463 if (!groups[0]) {
464 return [];
465 }
466
467 return groups[0].items.map(function (item) {
468 return new InfiniteGridItem(horizontal, __assign({}, item));
469 });
470}
471function getRenderingItemsByStatus(groupManagerStatus, nextItems, usePlaceholder, horizontal) {
472 var prevGroups = groupManagerStatus.groups;
473 var groups = categorize(nextItems);
474 var startVirtualGroups = splitVirtualGroups(prevGroups, "start", groups);
475 var endVirtualGroups = splitVirtualGroups(prevGroups, "end", groups);
476
477 var nextGroups = __spreadArrays(startVirtualGroups, groups, endVirtualGroups);
478
479 var _a = getNextCursors(prevGroups.map(function (group) {
480 return group.groupKey;
481 }), nextGroups.map(function (group) {
482 return group.groupKey;
483 }), groupManagerStatus.cursors[0], groupManagerStatus.cursors[1]),
484 startCursor = _a.startCursor,
485 endCursor = _a.endCursor;
486
487 var nextVisibleItems = flat(nextGroups.slice(startCursor, endCursor + 1).map(function (group) {
488 return group.items.map(function (item) {
489 return new InfiniteGridItem(horizontal, __assign({}, item));
490 });
491 }));
492
493 if (!usePlaceholder) {
494 nextVisibleItems = nextVisibleItems.filter(function (item) {
495 return item.type !== ITEM_TYPE.VIRTUAL;
496 });
497 }
498
499 return nextVisibleItems;
500}
501function mountRenderingItems(items, options) {
502 var grid = options.grid,
503 usePlaceholder = options.usePlaceholder,
504 useLoading = options.useLoading,
505 useFirstRender = options.useFirstRender,
506 status = options.status;
507
508 if (!grid) {
509 return;
510 }
511
512 if (usePlaceholder) {
513 grid.setPlaceholder({});
514 }
515
516 if (useLoading) {
517 grid.setLoading({});
518 }
519
520 if (status) {
521 grid.setStatus(status, true);
522 }
523
524 grid.syncItems(items);
525
526 if (useFirstRender && !status && grid.getGroups().length) {
527 grid.setCursors(0, 0, true);
528 }
529}
530function getRenderingItems(items, options) {
531 var status = options.status,
532 usePlaceholder = options.usePlaceholder,
533 useLoading = options.useLoading,
534 horizontal = options.horizontal,
535 useFirstRender = options.useFirstRender,
536 grid = options.grid;
537 var visibleItems = [];
538
539 if (grid) {
540 grid.setPlaceholder(usePlaceholder ? {} : null);
541 grid.setLoading(useLoading ? {} : null);
542 grid.syncItems(items);
543 visibleItems = grid.getRenderingItems();
544 } else if (status) {
545 visibleItems = getRenderingItemsByStatus(status.groupManager, items, !!usePlaceholder, !!horizontal);
546 } else if (useFirstRender) {
547 visibleItems = getFirstRenderingItems(items, !!horizontal);
548 }
549
550 return visibleItems;
551}
552/* Class Decorator */
553
554function InfiniteGridGetterSetter(component) {
555 var prototype = component.prototype,
556 propertyTypes = component.propertyTypes;
557
558 var _loop_1 = function (name) {
559 var attributes = {
560 enumerable: true,
561 configurable: true,
562 get: function () {
563 var options = this.groupManager.options;
564
565 if (name in options) {
566 return options[name];
567 } else {
568 return options.gridOptions[name];
569 }
570 },
571 set: function (value) {
572 var _a;
573
574 var prevValue = this.groupManager[name];
575
576 if (prevValue === value) {
577 return;
578 }
579
580 this.groupManager.gridOptions = (_a = {}, _a[name] = value, _a);
581 }
582 };
583 Object.defineProperty(prototype, name, attributes);
584 };
585
586 for (var name in propertyTypes) {
587 _loop_1(name);
588 }
589}
590function makeKey(registeredKeys) {
591 var index = 0; // eslint-disable-next-line no-constant-condition
592
593 while (true) {
594 var key = "infinitegrid_" + index++;
595
596 if (!(key in registeredKeys)) {
597 return key;
598 }
599 }
600}
601function convertHTMLtoElement(html) {
602 var dummy = document.createElement("div");
603 dummy.innerHTML = html;
604 return toArray(dummy.children);
605}
606function convertInsertedItems(items, groupKey) {
607 var insertedItems;
608
609 if (isString(items)) {
610 insertedItems = convertHTMLtoElement(items);
611 } else {
612 insertedItems = items;
613 }
614
615 return insertedItems.map(function (item) {
616 var element;
617 var html = "";
618 var key;
619
620 if (isString(item)) {
621 html = item;
622 } else if ("parentNode" in item) {
623 element = item;
624 html = item.outerHTML;
625 } else {
626 return __assign({
627 groupKey: groupKey
628 }, item);
629 }
630
631 return {
632 key: key,
633 groupKey: groupKey,
634 html: html,
635 element: element
636 };
637 });
638}
639function toArray(nodes) {
640 var array = [];
641
642 if (nodes) {
643 var length = nodes.length;
644
645 for (var i = 0; i < length; i++) {
646 array.push(nodes[i]);
647 }
648 }
649
650 return array;
651}
652function findIndex(arr, callback) {
653 var length = arr.length;
654
655 for (var i = 0; i < length; ++i) {
656 if (callback(arr[i], i)) {
657 return i;
658 }
659 }
660
661 return -1;
662}
663function findLastIndex(arr, callback) {
664 var length = arr.length;
665
666 for (var i = length - 1; i >= 0; --i) {
667 if (callback(arr[i], i)) {
668 return i;
669 }
670 }
671
672 return -1;
673}
674function getItemInfo(info) {
675 var nextInfo = {};
676
677 for (var name in info) {
678 if (name in ITEM_INFO_PROPERTIES) {
679 nextInfo[name] = info[name];
680 }
681 }
682
683 return nextInfo;
684}
685function setPlaceholder(item, info) {
686 for (var name in info) {
687 var value = info[name];
688
689 if (isObject(value)) {
690 item[name] = __assign(__assign({}, item[name]), value);
691 } else {
692 item[name] = info[name];
693 }
694 }
695}
696function isFlatOutline(start, end) {
697 return start.length === end.length && start.every(function (pos, i) {
698 return end[i] === pos;
699 });
700}
701function range(length) {
702 var arr = [];
703
704 for (var i = 0; i < length; ++i) {
705 arr.push(i);
706 }
707
708 return arr;
709}
710function flatGroups(groups) {
711 return flat(groups.map(function (_a) {
712 var grid = _a.grid;
713 return grid.getItems();
714 }));
715}
716function filterVirtuals(items, includePlaceholders) {
717 if (includePlaceholders) {
718 return items;
719 } else {
720 return items.filter(function (item) {
721 return item.type !== ITEM_TYPE.VIRTUAL;
722 });
723 }
724}
725/**
726 * Decorator that makes the method of InfiniteGrid available in the framework.
727 * @ko 프레임워크에서 InfiniteGrid의 메소드를 사용할 수 있게 하는 데코레이터.
728 * @private
729 * @example
730 * ```js
731 * import { withInfiniteGridMethods } from "@egjs/infinitegrid";
732 *
733 * class Grid extends React.Component<Partial<InfiniteGridProps & InfiniteGridOptions>> {
734 * &#64;withInfiniteGridMethods
735 * private grid: NativeGrid;
736 * }
737 * ```
738 */
739
740var withInfiniteGridMethods = withMethods(INFINITEGRID_METHODS);
741
742var GroupManager =
743/*#__PURE__*/
744function (_super) {
745 __extends(GroupManager, _super);
746
747 function GroupManager(container, options) {
748 var _this = _super.call(this, container, splitOptions(options)) || this;
749
750 _this.groupItems = [];
751 _this.groups = [];
752 _this.itemKeys = {};
753 _this.groupKeys = {};
754 _this.startCursor = 0;
755 _this.endCursor = 0;
756 _this._placeholder = null;
757 _this._loadingGrid = new LoadingGrid(container, {
758 externalContainerManager: _this.containerManager,
759 useFit: false,
760 autoResize: false,
761 renderOnPropertyChange: false,
762 gap: _this.gap
763 });
764 _this._mainGrid = _this._makeGrid();
765 return _this;
766 }
767
768 var __proto = GroupManager.prototype;
769 Object.defineProperty(__proto, "gridOptions", {
770 set: function (options) {
771 var _a = splitGridOptions(options),
772 gridOptions = _a.gridOptions,
773 otherOptions = __rest(_a, ["gridOptions"]);
774
775 var shouldRender = this._checkShouldRender(options);
776
777 this.options.gridOptions = __assign(__assign({}, this.options.gridOptions), gridOptions);
778
779 __spreadArrays([this._mainGrid], this.groups.map(function (_a) {
780 var grid = _a.grid;
781 return grid;
782 })).forEach(function (grid) {
783 for (var name in options) {
784 grid[name] = options[name];
785 }
786 });
787
788 for (var name in otherOptions) {
789 this[name] = otherOptions[name];
790 }
791
792 this._loadingGrid.gap = this.gap;
793
794 if (shouldRender) {
795 this.scheduleRender();
796 }
797 },
798 enumerable: false,
799 configurable: true
800 });
801
802 __proto.getItemByKey = function (key) {
803 return this.itemKeys[key] || null;
804 };
805
806 __proto.getGroupItems = function (includePlaceholders) {
807 return filterVirtuals(this.groupItems, includePlaceholders);
808 };
809
810 __proto.getVisibleItems = function (includePlaceholders) {
811 return filterVirtuals(this.items, includePlaceholders);
812 };
813
814 __proto.getRenderingItems = function () {
815 if (this.hasPlaceholder()) {
816 return this.items;
817 } else {
818 return this.items.filter(function (item) {
819 return item.type !== ITEM_TYPE.VIRTUAL;
820 });
821 }
822 };
823
824 __proto.getGroups = function (includePlaceholders) {
825 return filterVirtuals(this.groups, includePlaceholders);
826 };
827
828 __proto.hasVisibleVirtualGroups = function () {
829 return this.getVisibleGroups(true).some(function (group) {
830 return group.type === GROUP_TYPE.VIRTUAL;
831 });
832 };
833
834 __proto.hasPlaceholder = function () {
835 return !!this._placeholder;
836 };
837
838 __proto.hasLoadingItem = function () {
839 return !!this._getLoadingItem();
840 };
841
842 __proto.updateItems = function (items, options) {
843 if (items === void 0) {
844 items = this.groupItems;
845 }
846
847 return _super.prototype.updateItems.call(this, items, options);
848 };
849
850 __proto.setPlaceholder = function (placeholder) {
851 this._placeholder = placeholder;
852
853 this._updatePlaceholder();
854 };
855
856 __proto.getLoadingType = function () {
857 return this._loadingGrid.type;
858 };
859
860 __proto.startLoading = function (type) {
861 this._loadingGrid.type = type;
862 this.items = this._getRenderingItems();
863 return true;
864 };
865
866 __proto.endLoading = function () {
867 var prevType = this._loadingGrid.type;
868 this._loadingGrid.type = "";
869 this.items = this._getRenderingItems();
870 return !!prevType;
871 };
872
873 __proto.setLoading = function (loading) {
874 this._loadingGrid.setLoadingItem(loading);
875
876 this.items = this._getRenderingItems();
877 };
878
879 __proto.getVisibleGroups = function (includePlaceholders) {
880 var groups = this.groups.slice(this.startCursor, this.endCursor + 1);
881 return filterVirtuals(groups, includePlaceholders);
882 };
883
884 __proto.getComputedOutlineLength = function (items) {
885 if (items === void 0) {
886 items = this.items;
887 }
888
889 return this._mainGrid.getComputedOutlineLength(items);
890 };
891
892 __proto.getComputedOutlineSize = function (items) {
893 if (items === void 0) {
894 items = this.items;
895 }
896
897 return this._mainGrid.getComputedOutlineSize(items);
898 };
899
900 __proto.applyGrid = function (items, direction, outline) {
901 var _this = this;
902
903 var renderingGroups = this.groups.slice();
904
905 if (!renderingGroups.length) {
906 return {
907 start: [],
908 end: []
909 };
910 }
911
912 var loadingGrid = this._loadingGrid;
913
914 if (loadingGrid.getLoadingItem()) {
915 if (loadingGrid.type === "start") {
916 renderingGroups.unshift(this._getLoadingGroup());
917 } else if (loadingGrid.type === "end") {
918 renderingGroups.push(this._getLoadingGroup());
919 }
920 }
921
922 var groups = renderingGroups.slice();
923 var nextOutline = outline;
924
925 if (direction === "start") {
926 groups.reverse();
927 }
928
929 var groupItems = this.groupItems;
930 var outlineLength = this.getComputedOutlineLength(groupItems);
931 var outlineSize = this.getComputedOutlineSize(groupItems);
932 groups.forEach(function (group) {
933 var grid = group.grid;
934 var gridItems = grid.getItems();
935 var isVirtual = group.type === GROUP_TYPE.VIRTUAL && !gridItems[0];
936 var appliedItems = gridItems.filter(function (item) {
937 return item.mountState !== MOUNT_STATE.UNCHECKED && item.rect.width;
938 });
939 var gridOutlines;
940 grid.outlineLength = outlineLength;
941 grid.outlineSize = outlineSize;
942
943 if (isVirtual) {
944 gridOutlines = _this._applyVirtualGrid(grid, direction, nextOutline);
945 } else if (appliedItems.length) {
946 gridOutlines = grid.applyGrid(appliedItems, direction, nextOutline);
947 } else {
948 gridOutlines = {
949 start: __spreadArrays(nextOutline),
950 end: __spreadArrays(nextOutline)
951 };
952 }
953
954 grid.setOutlines(gridOutlines);
955 nextOutline = gridOutlines[direction];
956 });
957 return {
958 start: renderingGroups[0].grid.getOutlines().start,
959 end: renderingGroups[renderingGroups.length - 1].grid.getOutlines().end
960 };
961 };
962
963 __proto.syncItems = function (nextItemInfos) {
964 var _this = this;
965
966 var prevItemKeys = this.itemKeys;
967 this.itemKeys = {};
968
969 var nextItems = this._syncItemInfos(nextItemInfos.map(function (info) {
970 return getItemInfo(info);
971 }), prevItemKeys);
972
973 var prevGroupKeys = this.groupKeys;
974 var nextManagerGroups = categorize(nextItems);
975
976 var startVirtualGroups = this._splitVirtualGroups("start", nextManagerGroups);
977
978 var endVirtualGroups = this._splitVirtualGroups("end", nextManagerGroups);
979
980 nextManagerGroups = __spreadArrays(startVirtualGroups, this._mergeVirtualGroups(nextManagerGroups), endVirtualGroups);
981 var nextGroups = nextManagerGroups.map(function (_a) {
982 var _b, _c;
983
984 var groupKey = _a.groupKey,
985 items = _a.items;
986 var isVirtual = !items[0] || items[0].type === ITEM_TYPE.VIRTUAL;
987 var grid = (_c = (_b = prevGroupKeys[groupKey]) === null || _b === void 0 ? void 0 : _b.grid) !== null && _c !== void 0 ? _c : _this._makeGrid();
988 var gridItems = isVirtual ? items : items.filter(function (_a) {
989 var type = _a.type;
990 return type === ITEM_TYPE.NORMAL;
991 });
992 grid.setItems(gridItems);
993 return {
994 type: isVirtual ? GROUP_TYPE.VIRTUAL : GROUP_TYPE.NORMAL,
995 groupKey: groupKey,
996 grid: grid,
997 items: gridItems,
998 renderItems: items
999 };
1000 });
1001
1002 this._registerGroups(nextGroups);
1003 };
1004
1005 __proto.renderItems = function (options) {
1006 if (options === void 0) {
1007 options = {};
1008 }
1009
1010 if (options.useResize) {
1011 this.groupItems.forEach(function (item) {
1012 item.updateState = UPDATE_STATE.NEED_UPDATE;
1013 });
1014
1015 var loadingItem = this._getLoadingItem();
1016
1017 if (loadingItem) {
1018 loadingItem.updateState = UPDATE_STATE.NEED_UPDATE;
1019 }
1020 }
1021
1022 return _super.prototype.renderItems.call(this, options);
1023 };
1024
1025 __proto.setCursors = function (startCursor, endCursor) {
1026 this.startCursor = startCursor;
1027 this.endCursor = endCursor;
1028 this.items = this._getRenderingItems();
1029 };
1030
1031 __proto.getStartCursor = function () {
1032 return this.startCursor;
1033 };
1034
1035 __proto.getEndCursor = function () {
1036 return this.endCursor;
1037 };
1038
1039 __proto.getGroupStatus = function (type, includePlaceholders) {
1040 var orgStartCursor = this.startCursor;
1041 var orgEndCursor = this.endCursor;
1042 var orgGroups = this.groups;
1043 var startGroup = orgGroups[orgStartCursor];
1044 var endGroup = orgGroups[orgEndCursor];
1045 var startCursor = orgStartCursor;
1046 var endCursor = orgEndCursor;
1047 var isMinimizeItems = type === STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS;
1048 var isMinimizeGroups = type === STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS;
1049 var groups;
1050
1051 if (type === STATUS_TYPE.REMOVE_INVISIBLE_GROUPS) {
1052 groups = this.getVisibleGroups(includePlaceholders);
1053 endCursor = groups.length - 1;
1054 startCursor = 0;
1055 } else {
1056 groups = this.getGroups(includePlaceholders);
1057
1058 if (!includePlaceholders) {
1059 startCursor = -1;
1060 endCursor = -1;
1061
1062 for (var orgIndex = orgStartCursor; orgIndex <= orgEndCursor; ++orgIndex) {
1063 var orgGroup = orgGroups[orgIndex];
1064
1065 if (orgGroup && orgGroup.type !== GROUP_TYPE.VIRTUAL) {
1066 startCursor = groups.indexOf(orgGroup);
1067 break;
1068 }
1069 }
1070
1071 for (var orgIndex = orgEndCursor; orgIndex >= orgStartCursor; --orgIndex) {
1072 var orgGroup = orgGroups[orgIndex];
1073
1074 if (orgGroup && orgGroup.type !== GROUP_TYPE.VIRTUAL) {
1075 endCursor = groups.lastIndexOf(orgGroup);
1076 break;
1077 }
1078 }
1079 }
1080 }
1081
1082 var groupStatus = groups.map(function (_a, i) {
1083 var grid = _a.grid,
1084 groupKey = _a.groupKey;
1085 var isOutsideCursor = i < startCursor || endCursor < i;
1086 var isVirtualItems = isMinimizeItems && isOutsideCursor;
1087 var isVirtualGroup = isMinimizeGroups && isOutsideCursor;
1088 var gridItems = grid.getItems();
1089 var items = isVirtualGroup ? [] : gridItems.map(function (item) {
1090 return isVirtualItems ? item.getVirtualStatus() : item.getMinimizedStatus();
1091 });
1092 return {
1093 type: isVirtualGroup || isVirtualItems ? GROUP_TYPE.VIRTUAL : GROUP_TYPE.NORMAL,
1094 groupKey: groupKey,
1095 outlines: grid.getOutlines(),
1096 items: items
1097 };
1098 });
1099 var totalItems = this.getGroupItems();
1100 var itemStartCursor = totalItems.indexOf(startGroup === null || startGroup === void 0 ? void 0 : startGroup.items[0]);
1101 var itemEndCursor = totalItems.indexOf(endGroup === null || endGroup === void 0 ? void 0 : endGroup.items.slice().reverse()[0]);
1102 return {
1103 cursors: [startCursor, endCursor],
1104 orgCursors: [orgStartCursor, orgEndCursor],
1105 itemCursors: [itemStartCursor, itemEndCursor],
1106 startGroupKey: startGroup === null || startGroup === void 0 ? void 0 : startGroup.groupKey,
1107 endGroupKey: endGroup === null || endGroup === void 0 ? void 0 : endGroup.groupKey,
1108 groups: groupStatus,
1109 outlines: this.outlines
1110 };
1111 };
1112
1113 __proto.fitOutlines = function (useFit) {
1114 if (useFit === void 0) {
1115 useFit = this.useFit;
1116 }
1117
1118 var groups = this.groups;
1119 var firstGroup = groups[0];
1120
1121 if (!firstGroup) {
1122 return;
1123 }
1124
1125 var outlines = firstGroup.grid.getOutlines();
1126 var startOutline = outlines.start;
1127 var outlineOffset = startOutline.length ? Math.min.apply(Math, startOutline) : 0; // If the outline is less than 0, a fit occurs forcibly.
1128
1129 if (!useFit && outlineOffset > 0) {
1130 return;
1131 }
1132
1133 groups.forEach(function (_a) {
1134 var grid = _a.grid;
1135
1136 var _b = grid.getOutlines(),
1137 start = _b.start,
1138 end = _b.end;
1139
1140 grid.setOutlines({
1141 start: start.map(function (point) {
1142 return point - outlineOffset;
1143 }),
1144 end: end.map(function (point) {
1145 return point - outlineOffset;
1146 })
1147 });
1148 });
1149 this.groupItems.forEach(function (item) {
1150 var contentPos = item.cssContentPos;
1151
1152 if (!isNumber(contentPos)) {
1153 return;
1154 }
1155
1156 item.cssContentPos = contentPos - outlineOffset;
1157 });
1158 };
1159
1160 __proto.setGroupStatus = function (status) {
1161 var _this = this;
1162
1163 this.itemKeys = {};
1164 this.groupItems = [];
1165 this.items = [];
1166 var prevGroupKeys = this.groupKeys;
1167 var nextGroups = status.groups.map(function (_a) {
1168 var _b, _c;
1169
1170 var type = _a.type,
1171 groupKey = _a.groupKey,
1172 items = _a.items,
1173 outlines = _a.outlines;
1174
1175 var nextItems = _this._syncItemInfos(items);
1176
1177 var grid = (_c = (_b = prevGroupKeys[groupKey]) === null || _b === void 0 ? void 0 : _b.grid) !== null && _c !== void 0 ? _c : _this._makeGrid();
1178 grid.setOutlines(outlines);
1179 grid.setItems(nextItems);
1180 return {
1181 type: type,
1182 groupKey: groupKey,
1183 grid: grid,
1184 items: nextItems,
1185 renderItems: nextItems
1186 };
1187 });
1188 this.setOutlines(status.outlines);
1189
1190 this._registerGroups(nextGroups);
1191
1192 this._updatePlaceholder();
1193
1194 this.setCursors(status.cursors[0], status.cursors[1]);
1195 };
1196
1197 __proto.appendPlaceholders = function (items, groupKey) {
1198 return this.insertPlaceholders("end", items, groupKey);
1199 };
1200
1201 __proto.prependPlaceholders = function (items, groupKey) {
1202 return this.insertPlaceholders("start", items, groupKey);
1203 };
1204
1205 __proto.removePlaceholders = function (type) {
1206 var groups = this.groups;
1207 var length = groups.length;
1208
1209 if (type === "start") {
1210 var index = findIndex(groups, function (group) {
1211 return group.type === GROUP_TYPE.NORMAL;
1212 });
1213 groups.splice(0, index);
1214 } else if (type === "end") {
1215 var index = findLastIndex(groups, function (group) {
1216 return group.type === GROUP_TYPE.NORMAL;
1217 });
1218 groups.splice(index + 1, length - index - 1);
1219 } else {
1220 var groupKey_1 = type.groupKey;
1221 var index = findIndex(groups, function (group) {
1222 return group.groupKey === groupKey_1;
1223 });
1224
1225 if (index > -1) {
1226 groups.splice(index, 1);
1227 }
1228 }
1229
1230 this.syncItems(flatGroups(this.getGroups()));
1231 };
1232
1233 __proto.insertPlaceholders = function (direction, items, groupKey) {
1234 var _a, _b;
1235
1236 if (groupKey === void 0) {
1237 groupKey = makeKey(this.groupKeys);
1238 }
1239
1240 var infos = [];
1241
1242 if (isNumber(items)) {
1243 infos = range(items).map(function () {
1244 return {
1245 type: ITEM_TYPE.VIRTUAL,
1246 groupKey: groupKey
1247 };
1248 });
1249 } else if (Array.isArray(items)) {
1250 infos = items.map(function (status) {
1251 return __assign(__assign({
1252 groupKey: groupKey
1253 }, status), {
1254 type: ITEM_TYPE.VIRTUAL
1255 });
1256 });
1257 }
1258
1259 var grid = this._makeGrid();
1260
1261 var nextItems = this._syncItemInfos(infos, this.itemKeys);
1262
1263 this._updatePlaceholder(nextItems);
1264
1265 grid.setItems(nextItems);
1266 var group = {
1267 type: GROUP_TYPE.VIRTUAL,
1268 groupKey: groupKey,
1269 grid: grid,
1270 items: nextItems,
1271 renderItems: nextItems
1272 };
1273 this.groupKeys[groupKey] = group;
1274
1275 if (direction === "end") {
1276 this.groups.push(group);
1277
1278 (_a = this.groupItems).push.apply(_a, nextItems);
1279 } else {
1280 this.groups.splice(0, 0, group);
1281
1282 (_b = this.groupItems).splice.apply(_b, __spreadArrays([0, 0], nextItems));
1283
1284 if (this.startCursor > -1) {
1285 ++this.startCursor;
1286 ++this.endCursor;
1287 }
1288 }
1289
1290 return {
1291 group: group,
1292 items: nextItems
1293 };
1294 };
1295
1296 __proto.shouldRerenderItems = function () {
1297 var isRerender = false;
1298 this.getVisibleGroups().forEach(function (group) {
1299 var items = group.items;
1300
1301 if (items.length === group.renderItems.length || items.every(function (item) {
1302 return item.mountState === MOUNT_STATE.UNCHECKED;
1303 })) {
1304 return;
1305 }
1306
1307 isRerender = true;
1308 group.renderItems = __spreadArrays(items);
1309 });
1310
1311 if (isRerender) {
1312 this.items = this._getRenderingItems();
1313 }
1314
1315 return isRerender;
1316 };
1317
1318 __proto._getGroupItems = function () {
1319 return flatGroups(this.getGroups(true));
1320 };
1321
1322 __proto._getRenderingItems = function () {
1323 var items = flat(this.getVisibleGroups(true).map(function (item) {
1324 return item.renderItems;
1325 }));
1326 var loadingGrid = this._loadingGrid;
1327 var loadingItem = loadingGrid.getLoadingItem();
1328
1329 if (loadingItem) {
1330 if (loadingGrid.type === "end") {
1331 items.push(loadingItem);
1332 } else if (loadingGrid.type === "start") {
1333 items.unshift(loadingItem);
1334 }
1335 }
1336
1337 return items;
1338 };
1339
1340 __proto._checkShouldRender = function (options) {
1341 var GridConstructor = this.options.gridConstructor;
1342 var prevOptions = this.gridOptions;
1343 var propertyTypes = GridConstructor.propertyTypes;
1344
1345 for (var name in prevOptions) {
1346 if (!(name in options) && propertyTypes[name] === PROPERTY_TYPE.RENDER_PROPERTY) {
1347 return true;
1348 }
1349 }
1350
1351 for (var name in options) {
1352 if (prevOptions[name] !== options[name] && propertyTypes[name] === PROPERTY_TYPE.RENDER_PROPERTY) {
1353 return true;
1354 }
1355 }
1356
1357 return false;
1358 };
1359
1360 __proto._applyVirtualGrid = function (grid, direction, outline) {
1361 var startOutline = outline.length ? __spreadArrays(outline) : [0];
1362 var prevOutlines = grid.getOutlines();
1363 var prevOutline = prevOutlines[direction === "end" ? "start" : "end"];
1364
1365 if (prevOutline.length !== startOutline.length || prevOutline.some(function (value, i) {
1366 return value !== startOutline[i];
1367 })) {
1368 return {
1369 start: __spreadArrays(startOutline),
1370 end: __spreadArrays(startOutline)
1371 };
1372 }
1373
1374 return prevOutlines;
1375 };
1376
1377 __proto._syncItemInfos = function (nextItemInfos, prevItemKeys) {
1378 if (prevItemKeys === void 0) {
1379 prevItemKeys = {};
1380 }
1381
1382 var horizontal = this.options.horizontal;
1383 var nextItemKeys = this.itemKeys;
1384 nextItemInfos.filter(function (info) {
1385 return info.key != null;
1386 }).forEach(function (info) {
1387 var key = info.key;
1388 var prevItem = prevItemKeys[key];
1389
1390 if (!prevItem) {
1391 nextItemKeys[key] = new InfiniteGridItem(horizontal, __assign({}, info));
1392 } else if (prevItem.type === ITEM_TYPE.VIRTUAL && info.type !== ITEM_TYPE.VIRTUAL) {
1393 nextItemKeys[key] = new InfiniteGridItem(horizontal, __assign({
1394 orgRect: prevItem.orgRect,
1395 rect: prevItem.rect
1396 }, info));
1397 } else {
1398 if (info.data) {
1399 prevItem.data = info.data;
1400 }
1401
1402 nextItemKeys[key] = prevItem;
1403 }
1404 });
1405 var nextItems = nextItemInfos.map(function (info) {
1406 var key = info.key;
1407
1408 if (info.key == null) {
1409 key = makeKey(nextItemKeys);
1410 }
1411
1412 var item = nextItemKeys[key];
1413
1414 if (!item) {
1415 var prevItem = prevItemKeys[key];
1416
1417 if (prevItem) {
1418 item = prevItem;
1419
1420 if (info.data) {
1421 item.data = info.data;
1422 }
1423 } else {
1424 item = new InfiniteGridItem(horizontal, __assign(__assign({}, info), {
1425 key: key
1426 }));
1427 }
1428
1429 nextItemKeys[key] = item;
1430 }
1431
1432 return item;
1433 });
1434 return nextItems;
1435 };
1436
1437 __proto._registerGroups = function (groups) {
1438 var nextGroupKeys = {};
1439 groups.forEach(function (group) {
1440 nextGroupKeys[group.groupKey] = group;
1441 });
1442 this.groups = groups;
1443 this.groupKeys = nextGroupKeys;
1444 this.groupItems = this._getGroupItems();
1445 };
1446
1447 __proto._splitVirtualGroups = function (direction, nextGroups) {
1448 var groups = splitVirtualGroups(this.groups, direction, nextGroups);
1449 var itemKeys = this.itemKeys;
1450 groups.forEach(function (_a) {
1451 var renderItems = _a.renderItems;
1452 renderItems.forEach(function (item) {
1453 itemKeys[item.key] = item;
1454 });
1455 });
1456 return groups;
1457 };
1458
1459 __proto._mergeVirtualGroups = function (groups) {
1460 var itemKeys = this.itemKeys;
1461 var groupKeys = this.groupKeys;
1462 groups.forEach(function (group) {
1463 var prevGroup = groupKeys[group.groupKey];
1464
1465 if (!prevGroup) {
1466 return;
1467 }
1468
1469 var items = group.items;
1470
1471 if (items.every(function (item) {
1472 return item.mountState === MOUNT_STATE.UNCHECKED;
1473 })) {
1474 prevGroup.renderItems.forEach(function (item) {
1475 if (item.type === ITEM_TYPE.VIRTUAL && !itemKeys[item.key]) {
1476 items.push(item);
1477 itemKeys[item.key] = item;
1478 }
1479 });
1480 }
1481 });
1482 return groups;
1483 };
1484
1485 __proto._updatePlaceholder = function (items) {
1486 if (items === void 0) {
1487 items = this.groupItems;
1488 }
1489
1490 var placeholder = this._placeholder;
1491
1492 if (!placeholder) {
1493 return;
1494 }
1495
1496 items.filter(function (item) {
1497 return item.type === ITEM_TYPE.VIRTUAL;
1498 }).forEach(function (item) {
1499 setPlaceholder(item, placeholder);
1500 });
1501 };
1502
1503 __proto._makeGrid = function () {
1504 var GridConstructor = this.options.gridConstructor;
1505 var gridOptions = this.gridOptions;
1506 var container = this.containerElement;
1507 return new GridConstructor(container, __assign(__assign({}, gridOptions), {
1508 useFit: false,
1509 autoResize: false,
1510 useResizeObserver: false,
1511 observeChildren: false,
1512 renderOnPropertyChange: false,
1513 externalContainerManager: this.containerManager,
1514 externalItemRenderer: this.itemRenderer
1515 }));
1516 };
1517
1518 __proto._getLoadingGroup = function () {
1519 var loadingGrid = this._loadingGrid;
1520 var items = loadingGrid.getItems();
1521 return {
1522 groupKey: LOADING_GROUP_KEY,
1523 type: GROUP_TYPE.NORMAL,
1524 grid: loadingGrid,
1525 items: items,
1526 renderItems: items
1527 };
1528 };
1529
1530 __proto._getLoadingItem = function () {
1531 return this._loadingGrid.getLoadingItem();
1532 };
1533
1534 GroupManager.defaultOptions = __assign(__assign({}, Grid.defaultOptions), {
1535 gridConstructor: null,
1536 gridOptions: {}
1537 });
1538 GroupManager.propertyTypes = __assign(__assign({}, Grid.propertyTypes), {
1539 gridConstructor: PROPERTY_TYPE.PROPERTY,
1540 gridOptions: PROPERTY_TYPE.PROPERTY
1541 });
1542 GroupManager = __decorate([GetterSetter], GroupManager);
1543 return GroupManager;
1544}(Grid);
1545
1546var Infinite =
1547/*#__PURE__*/
1548function (_super) {
1549 __extends(Infinite, _super);
1550
1551 function Infinite(options) {
1552 var _this = _super.call(this) || this;
1553
1554 _this.startCursor = -1;
1555 _this.endCursor = -1;
1556 _this.size = 0;
1557 _this.items = [];
1558 _this.itemKeys = {};
1559 _this.options = __assign({
1560 threshold: 0,
1561 useRecycle: true,
1562 defaultDirection: "end"
1563 }, options);
1564 return _this;
1565 }
1566
1567 var __proto = Infinite.prototype;
1568
1569 __proto.scroll = function (scrollPos) {
1570 var _a, _b;
1571
1572 var prevStartCursor = this.startCursor;
1573 var prevEndCursor = this.endCursor;
1574 var items = this.items;
1575 var length = items.length;
1576 var size = this.size;
1577 var _c = this.options,
1578 defaultDirection = _c.defaultDirection,
1579 threshold = _c.threshold,
1580 useRecycle = _c.useRecycle;
1581 var isDirectionEnd = defaultDirection === "end";
1582
1583 if (!length) {
1584 this.trigger(isDirectionEnd ? "requestAppend" : "requestPrepend", {
1585 key: undefined,
1586 isVirtual: false
1587 });
1588 return;
1589 } else if (prevStartCursor === -1 || prevEndCursor === -1) {
1590 var nextCursor = isDirectionEnd ? 0 : length - 1;
1591 this.trigger("change", {
1592 prevStartCursor: prevStartCursor,
1593 prevEndCursor: prevEndCursor,
1594 nextStartCursor: nextCursor,
1595 nextEndCursor: nextCursor
1596 });
1597 return;
1598 }
1599
1600 var endScrollPos = scrollPos + size;
1601 var startEdgePos = Math.max.apply(Math, items[prevStartCursor].startOutline);
1602 var endEdgePos = Math.min.apply(Math, items[prevEndCursor].endOutline);
1603 var visibles = items.map(function (item) {
1604 var startOutline = item.startOutline,
1605 endOutline = item.endOutline;
1606
1607 if (!startOutline.length || !endOutline.length) {
1608 return false;
1609 }
1610
1611 var startPos = Math.min.apply(Math, startOutline);
1612 var endPos = Math.max.apply(Math, endOutline);
1613
1614 if (startPos - threshold <= endScrollPos && scrollPos <= endPos + threshold) {
1615 return true;
1616 }
1617
1618 return false;
1619 });
1620 var hasStartItems = 0 < prevStartCursor;
1621 var hasEndItems = prevEndCursor < length - 1;
1622 var isStart = scrollPos <= startEdgePos + threshold;
1623 var isEnd = endScrollPos >= endEdgePos - threshold;
1624 var nextStartCursor = visibles.indexOf(true);
1625 var nextEndCursor = visibles.lastIndexOf(true);
1626
1627 if (nextStartCursor === -1) {
1628 nextStartCursor = prevStartCursor;
1629 nextEndCursor = prevEndCursor;
1630 }
1631
1632 if (!useRecycle) {
1633 nextStartCursor = Math.min(nextStartCursor, prevStartCursor);
1634 nextEndCursor = Math.max(nextEndCursor, prevEndCursor);
1635 }
1636
1637 if (nextStartCursor === prevStartCursor && hasStartItems && isStart) {
1638 nextStartCursor -= 1;
1639 }
1640
1641 if (nextEndCursor === prevEndCursor && hasEndItems && isEnd) {
1642 nextEndCursor += 1;
1643 }
1644
1645 var nextVisibleItems = items.slice(nextStartCursor, nextEndCursor + 1); // It must contain no virtual items.
1646
1647 if (nextVisibleItems.every(function (item) {
1648 return item.isVirtual === true;
1649 })) {
1650 // The real item can be in either the start or end direction.
1651 var hasRealItem = false;
1652
1653 for (var i = nextStartCursor - 1; i >= 0; --i) {
1654 if (!items[i].isVirtual) {
1655 nextStartCursor = i;
1656 hasRealItem = true;
1657 break;
1658 }
1659 }
1660
1661 if (!hasRealItem) {
1662 for (var i = nextEndCursor + 1; i < length; ++i) {
1663 if (!items[i].isVirtual) {
1664 nextEndCursor = i;
1665 hasRealItem = true;
1666 break;
1667 }
1668 }
1669 }
1670
1671 if (hasRealItem) {
1672 nextVisibleItems = items.slice(nextStartCursor, nextEndCursor + 1);
1673 }
1674 }
1675
1676 var hasVirtualItems = nextVisibleItems.some(function (item) {
1677 return item.isVirtual === true;
1678 });
1679
1680 if (prevStartCursor !== nextStartCursor || prevEndCursor !== nextEndCursor) {
1681 this.trigger("change", {
1682 prevStartCursor: prevStartCursor,
1683 prevEndCursor: prevEndCursor,
1684 nextStartCursor: nextStartCursor,
1685 nextEndCursor: nextEndCursor
1686 });
1687
1688 if (!hasVirtualItems) {
1689 return;
1690 }
1691 } // If a virtual item is included, a requestPrepend (or requestAppend) event is triggered.
1692
1693
1694 if (hasVirtualItems) {
1695 var isStartVirtual = (_a = nextVisibleItems[0]) === null || _a === void 0 ? void 0 : _a.isVirtual;
1696 var isEndVirtual = (_b = nextVisibleItems[nextVisibleItems.length - 1]) === null || _b === void 0 ? void 0 : _b.isVirtual;
1697
1698 if ((!isDirectionEnd || !isEnd) && isStartVirtual) {
1699 var realItemIndex = findIndex(nextVisibleItems, function (item) {
1700 return !item.isVirtual;
1701 });
1702 var endVirtualItemIndex = (realItemIndex === -1 ? nextVisibleItems.length : realItemIndex) - 1;
1703
1704 if (nextVisibleItems[endVirtualItemIndex]) {
1705 this.trigger("requestPrepend", {
1706 key: nextVisibleItems[realItemIndex].key,
1707 nextKey: nextVisibleItems[endVirtualItemIndex].key,
1708 nextKeys: nextVisibleItems.slice(0, endVirtualItemIndex + 1).map(function (item) {
1709 return item.key;
1710 }),
1711 isVirtual: true
1712 });
1713 }
1714 } else if ((isDirectionEnd || !isStart) && isEndVirtual) {
1715 var realItemIndex = findLastIndex(nextVisibleItems, function (item) {
1716 return !item.isVirtual;
1717 });
1718 var startVirtualItemIndex = realItemIndex + 1;
1719
1720 if (nextVisibleItems[startVirtualItemIndex]) {
1721 this.trigger("requestAppend", {
1722 key: nextVisibleItems[realItemIndex].key,
1723 nextKey: nextVisibleItems[startVirtualItemIndex].key,
1724 nextKeys: nextVisibleItems.slice(startVirtualItemIndex).map(function (item) {
1725 return item.key;
1726 }),
1727 isVirtual: true
1728 });
1729 }
1730 }
1731 } else if (!this._requestVirtualItems()) {
1732 if ((!isDirectionEnd || !isEnd) && isStart) {
1733 this.trigger("requestPrepend", {
1734 key: items[prevStartCursor].key,
1735 isVirtual: false
1736 });
1737 } else if ((isDirectionEnd || !isStart) && isEnd) {
1738 this.trigger("requestAppend", {
1739 key: items[prevEndCursor].key,
1740 isVirtual: false
1741 });
1742 }
1743 }
1744 };
1745 /**
1746 * Call the requestAppend or requestPrepend event to fill the virtual items.
1747 * @ko virtual item을 채우기 위해 requestAppend 또는 requestPrepend 이벤트를 호출합니다.
1748 * @return - Whether the event is called. <ko>이벤트를 호출했는지 여부.</ko>
1749 */
1750
1751
1752 __proto._requestVirtualItems = function () {
1753 var isDirectionEnd = this.options.defaultDirection === "end";
1754 var items = this.items;
1755 var totalVisibleItems = this.getVisibleItems();
1756 var visibleItems = totalVisibleItems.filter(function (item) {
1757 return !item.isVirtual;
1758 });
1759 var totalVisibleLength = totalVisibleItems.length;
1760 var visibleLength = visibleItems.length;
1761 var startCursor = this.getStartCursor();
1762 var endCursor = this.getEndCursor();
1763
1764 if (visibleLength === totalVisibleLength) {
1765 return false;
1766 } else if (visibleLength) {
1767 var startKey_1 = visibleItems[0].key;
1768 var endKey_1 = visibleItems[visibleLength - 1].key;
1769 var startIndex = findIndex(items, function (item) {
1770 return item.key === startKey_1;
1771 }) - 1;
1772 var endIndex = findIndex(items, function (item) {
1773 return item.key === endKey_1;
1774 }) + 1;
1775 var isEnd = endIndex <= endCursor;
1776 var isStart = startIndex >= startCursor; // Fill the placeholder with the original item.
1777
1778 if ((isDirectionEnd || !isStart) && isEnd) {
1779 this.trigger("requestAppend", {
1780 key: endKey_1,
1781 nextKey: items[endIndex].key,
1782 isVirtual: true
1783 });
1784 return true;
1785 } else if ((!isDirectionEnd || !isEnd) && isStart) {
1786 this.trigger("requestPrepend", {
1787 key: startKey_1,
1788 nextKey: items[startIndex].key,
1789 isVirtual: true
1790 });
1791 return true;
1792 }
1793 } else if (totalVisibleLength) {
1794 var lastItem = totalVisibleItems[totalVisibleLength - 1];
1795
1796 if (isDirectionEnd) {
1797 this.trigger("requestAppend", {
1798 nextKey: totalVisibleItems[0].key,
1799 isVirtual: true
1800 });
1801 } else {
1802 this.trigger("requestPrepend", {
1803 nextKey: lastItem.key,
1804 isVirtual: true
1805 });
1806 }
1807
1808 return true;
1809 }
1810
1811 return false;
1812 };
1813
1814 __proto.setCursors = function (startCursor, endCursor) {
1815 this.startCursor = startCursor;
1816 this.endCursor = endCursor;
1817 };
1818
1819 __proto.setSize = function (size) {
1820 this.size = size;
1821 };
1822
1823 __proto.getStartCursor = function () {
1824 return this.startCursor;
1825 };
1826
1827 __proto.getEndCursor = function () {
1828 return this.endCursor;
1829 };
1830
1831 __proto.isLoading = function (direction) {
1832 var startCursor = this.startCursor;
1833 var endCursor = this.endCursor;
1834 var items = this.items;
1835 var firstItem = items[startCursor];
1836 var lastItem = items[endCursor];
1837 var length = items.length;
1838
1839 if (direction === DIRECTION.END && endCursor > -1 && endCursor < length - 1 && !lastItem.isVirtual && !isFlatOutline(lastItem.startOutline, lastItem.endOutline)) {
1840 return false;
1841 }
1842
1843 if (direction === DIRECTION.START && startCursor > 0 && !firstItem.isVirtual && !isFlatOutline(firstItem.startOutline, firstItem.endOutline)) {
1844 return false;
1845 }
1846
1847 return true;
1848 };
1849
1850 __proto.setItems = function (nextItems) {
1851 this.items = nextItems;
1852 var itemKeys = {};
1853 nextItems.forEach(function (item) {
1854 itemKeys[item.key] = item;
1855 });
1856 this.itemKeys = itemKeys;
1857 };
1858
1859 __proto.syncItems = function (nextItems) {
1860 var prevItems = this.items;
1861 var prevStartCursor = this.startCursor;
1862 var prevEndCursor = this.endCursor;
1863
1864 var _a = getNextCursors(this.items.map(function (item) {
1865 return item.key;
1866 }), nextItems.map(function (item) {
1867 return item.key;
1868 }), prevStartCursor, prevEndCursor),
1869 nextStartCursor = _a.startCursor,
1870 nextEndCursor = _a.endCursor; // sync items between cursors
1871
1872
1873 var isChange = nextEndCursor - nextStartCursor !== prevEndCursor - prevStartCursor || prevStartCursor === -1 || nextStartCursor === -1;
1874
1875 if (!isChange) {
1876 var prevVisibleItems = prevItems.slice(prevStartCursor, prevEndCursor + 1);
1877 var nextVisibleItems = nextItems.slice(nextStartCursor, nextEndCursor + 1);
1878 var visibleResult = diff(prevVisibleItems, nextVisibleItems, function (item) {
1879 return item.key;
1880 });
1881 isChange = visibleResult.added.length > 0 || visibleResult.removed.length > 0 || visibleResult.changed.length > 0;
1882 }
1883
1884 this.setItems(nextItems);
1885 this.setCursors(nextStartCursor, nextEndCursor);
1886 return isChange;
1887 };
1888
1889 __proto.getItems = function () {
1890 return this.items;
1891 };
1892
1893 __proto.getVisibleItems = function () {
1894 var startCursor = this.startCursor;
1895 var endCursor = this.endCursor;
1896
1897 if (startCursor === -1) {
1898 return [];
1899 }
1900
1901 return this.items.slice(startCursor, endCursor + 1);
1902 };
1903
1904 __proto.getItemByKey = function (key) {
1905 return this.itemKeys[key];
1906 };
1907
1908 __proto.getRenderedVisibleItems = function () {
1909 var items = this.getVisibleItems();
1910 var rendered = items.map(function (_a) {
1911 var startOutline = _a.startOutline,
1912 endOutline = _a.endOutline;
1913 var length = startOutline.length;
1914
1915 if (length === 0 || length !== endOutline.length) {
1916 return false;
1917 }
1918
1919 return startOutline.some(function (pos, i) {
1920 return endOutline[i] !== pos;
1921 });
1922 });
1923 var startIndex = rendered.indexOf(true);
1924 var endIndex = rendered.lastIndexOf(true);
1925 return endIndex === -1 ? [] : items.slice(startIndex, endIndex + 1);
1926 };
1927
1928 __proto.destroy = function () {
1929 this.off();
1930 this.startCursor = -1;
1931 this.endCursor = -1;
1932 this.items = [];
1933 this.size = 0;
1934 };
1935
1936 return Infinite;
1937}(Component);
1938
1939var Renderer =
1940/*#__PURE__*/
1941function (_super) {
1942 __extends(Renderer, _super);
1943
1944 function Renderer() {
1945 var _this = _super !== null && _super.apply(this, arguments) || this;
1946
1947 _this.items = [];
1948 _this.container = null;
1949 _this.rendererKey = 0;
1950 _this._updateTimer = 0;
1951 _this._state = {};
1952 _this._isItemChanged = false;
1953 return _this;
1954 }
1955
1956 var __proto = Renderer.prototype;
1957
1958 __proto.updateKey = function () {
1959 this.rendererKey = Date.now();
1960 };
1961
1962 __proto.getItems = function () {
1963 return this.items;
1964 };
1965
1966 __proto.setContainer = function (container) {
1967 this.container = container;
1968 };
1969
1970 __proto.render = function (nextItems, state) {
1971 return this.syncItems(nextItems, state);
1972 };
1973
1974 __proto.update = function (state) {
1975 var _this = this;
1976
1977 if (state === void 0) {
1978 state = {};
1979 }
1980
1981 this._state = __assign(__assign({}, this._state), state);
1982 this.trigger("update", {
1983 state: state
1984 });
1985 clearTimeout(this._updateTimer);
1986 this._updateTimer = window.setTimeout(function () {
1987 _this.trigger("requestUpdate", {
1988 state: state
1989 });
1990 });
1991 };
1992
1993 __proto.updated = function (nextElements) {
1994 var _a, _b;
1995
1996 if (nextElements === void 0) {
1997 nextElements = (_b = (_a = this.container) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : [];
1998 }
1999
2000 var diffResult = this._diffResult;
2001 var isChanged = !!(diffResult.added.length || diffResult.removed.length || diffResult.changed.length);
2002 var state = this._state;
2003 var isItemChanged = this._isItemChanged;
2004 var nextItems = diffResult.list;
2005 this._isItemChanged = false;
2006 this._state = {};
2007 this.items = nextItems;
2008 nextItems.forEach(function (item, i) {
2009 item.element = nextElements[i];
2010 });
2011 this.trigger("updated", {
2012 items: nextItems,
2013 elements: toArray(nextElements),
2014 diffResult: this._diffResult,
2015 state: state,
2016 isItemChanged: isItemChanged,
2017 isChanged: isChanged
2018 });
2019 return isChanged;
2020 };
2021
2022 __proto.syncItems = function (items, state) {
2023 if (state === void 0) {
2024 state = {};
2025 }
2026
2027 var rendererKey = this.rendererKey;
2028 var prevItems = this.items;
2029 var nextItems = items.map(function (item) {
2030 return __assign(__assign({}, item), {
2031 renderKey: rendererKey + "_" + item.key
2032 });
2033 });
2034 var result = diff(prevItems, nextItems, function (item) {
2035 return item.renderKey;
2036 });
2037 this._isItemChanged = !!result.added.length || !!result.removed.length || !!result.changed.length;
2038 this._state = __assign(__assign({}, this._state), state);
2039 this._diffResult = result;
2040 return result;
2041 };
2042
2043 __proto.destroy = function () {
2044 this.off();
2045 };
2046
2047 return Renderer;
2048}(Component);
2049
2050var VanillaRenderer =
2051/*#__PURE__*/
2052function (_super) {
2053 __extends(VanillaRenderer, _super);
2054
2055 function VanillaRenderer() {
2056 return _super !== null && _super.apply(this, arguments) || this;
2057 }
2058
2059 var __proto = VanillaRenderer.prototype;
2060
2061 __proto.render = function (nextItems, state) {
2062 var container = this.container;
2063
2064 var result = _super.prototype.render.call(this, nextItems, state);
2065
2066 var prevList = result.prevList,
2067 removed = result.removed,
2068 ordered = result.ordered,
2069 added = result.added,
2070 list = result.list;
2071
2072 var diffList = __spreadArrays(prevList);
2073
2074 removed.forEach(function (index) {
2075 diffList.splice(index, 1);
2076 container.removeChild(prevList[index].element);
2077 });
2078 ordered.forEach(function (_a) {
2079 var _b, _c;
2080
2081 var prevIndex = _a[0],
2082 nextIndex = _a[1];
2083 var item = diffList.splice(prevIndex, 1)[0];
2084 diffList.splice(nextIndex, 0, item);
2085 container.insertBefore(item.element, (_c = (_b = diffList[nextIndex + 1]) === null || _b === void 0 ? void 0 : _b.element) !== null && _c !== void 0 ? _c : null);
2086 });
2087 added.forEach(function (index) {
2088 var _a, _b;
2089
2090 var item = list[index];
2091 diffList.splice(index, 0, item);
2092 container.insertBefore(item.element, (_b = (_a = diffList[index + 1]) === null || _a === void 0 ? void 0 : _a.element) !== null && _b !== void 0 ? _b : null);
2093 });
2094 this.updated(container.children);
2095 return result;
2096 };
2097
2098 return VanillaRenderer;
2099}(Renderer);
2100
2101var VanillaGridRenderer =
2102/*#__PURE__*/
2103function (_super) {
2104 __extends(VanillaGridRenderer, _super);
2105
2106 function VanillaGridRenderer() {
2107 return _super !== null && _super.apply(this, arguments) || this;
2108 }
2109
2110 var __proto = VanillaGridRenderer.prototype;
2111
2112 __proto.syncItems = function (nextItems) {
2113 var result = _super.prototype.syncItems.call(this, nextItems);
2114
2115 var added = result.added,
2116 list = result.list;
2117 added.forEach(function (index) {
2118 var orgItem = nextItems[index].orgItem;
2119
2120 if (orgItem.html && !orgItem.element) {
2121 orgItem.element = convertHTMLtoElement(orgItem.html)[0];
2122 }
2123
2124 list[index].element = orgItem.element;
2125 });
2126 return result;
2127 };
2128
2129 return VanillaGridRenderer;
2130}(VanillaRenderer);
2131
2132var ScrollManager =
2133/*#__PURE__*/
2134function (_super) {
2135 __extends(ScrollManager, _super);
2136
2137 function ScrollManager(wrapper, options) {
2138 var _this = _super.call(this) || this;
2139
2140 _this.wrapper = wrapper;
2141 _this.prevScrollPos = null;
2142 _this.scrollOffset = 0;
2143 _this.contentSize = 0;
2144 _this._isScrollIssue = IS_IOS;
2145
2146 _this._onCheck = function () {
2147 var prevScrollPos = _this.getScrollPos();
2148
2149 var nextScrollPos = _this.getOrgScrollPos();
2150
2151 _this.setScrollPos(nextScrollPos);
2152
2153 if (prevScrollPos === null || _this._isScrollIssue && nextScrollPos === 0 || prevScrollPos === nextScrollPos) {
2154 nextScrollPos && (_this._isScrollIssue = false);
2155 return;
2156 }
2157
2158 _this._isScrollIssue = false;
2159
2160 _this.trigger(new ComponentEvent("scroll", {
2161 direction: prevScrollPos < nextScrollPos ? "end" : "start",
2162 scrollPos: nextScrollPos,
2163 relativeScrollPos: _this.getRelativeScrollPos()
2164 }));
2165 };
2166
2167 _this.options = __assign({
2168 container: false,
2169 containerTag: "div",
2170 horizontal: false
2171 }, options);
2172
2173 _this._init();
2174
2175 return _this;
2176 }
2177
2178 var __proto = ScrollManager.prototype;
2179
2180 __proto.getWrapper = function () {
2181 return this.wrapper;
2182 };
2183
2184 __proto.getContainer = function () {
2185 return this.container;
2186 };
2187
2188 __proto.getScrollContainer = function () {
2189 return this.scrollContainer;
2190 };
2191
2192 __proto.getScrollOffset = function () {
2193 return this.scrollOffset;
2194 };
2195
2196 __proto.getContentSize = function () {
2197 return this.contentSize;
2198 };
2199
2200 __proto.getRelativeScrollPos = function () {
2201 return (this.prevScrollPos || 0) - this.scrollOffset;
2202 };
2203
2204 __proto.getScrollPos = function () {
2205 return this.prevScrollPos;
2206 };
2207
2208 __proto.setScrollPos = function (pos) {
2209 this.prevScrollPos = pos;
2210 };
2211
2212 __proto.getOrgScrollPos = function () {
2213 var eventTarget = this.eventTarget;
2214 var horizontal = this.options.horizontal;
2215 var prop = "scroll" + (horizontal ? "Left" : "Top");
2216
2217 if (isWindow(eventTarget)) {
2218 return window[horizontal ? "pageXOffset" : "pageYOffset"] || document.documentElement[prop] || document.body[prop];
2219 } else {
2220 return eventTarget[prop];
2221 }
2222 };
2223
2224 __proto.setStatus = function (status) {
2225 this.contentSize = status.contentSize;
2226 this.scrollOffset = status.scrollOffset;
2227 this.prevScrollPos = status.prevScrollPos;
2228 this.scrollTo(this.prevScrollPos);
2229 };
2230
2231 __proto.getStatus = function () {
2232 return {
2233 contentSize: this.contentSize,
2234 scrollOffset: this.scrollOffset,
2235 prevScrollPos: this.prevScrollPos
2236 };
2237 };
2238
2239 __proto.scrollTo = function (pos) {
2240 var eventTarget = this.eventTarget;
2241 var horizontal = this.options.horizontal;
2242
2243 var _a = horizontal ? [pos, 0] : [0, pos],
2244 x = _a[0],
2245 y = _a[1];
2246
2247 if (isWindow(eventTarget)) {
2248 eventTarget.scroll(x, y);
2249 } else {
2250 eventTarget.scrollLeft = x;
2251 eventTarget.scrollTop = y;
2252 }
2253 };
2254
2255 __proto.scrollBy = function (pos) {
2256 if (!pos) {
2257 return;
2258 }
2259
2260 var eventTarget = this.eventTarget;
2261 var horizontal = this.options.horizontal;
2262
2263 var _a = horizontal ? [pos, 0] : [0, pos],
2264 x = _a[0],
2265 y = _a[1];
2266
2267 this.prevScrollPos += pos;
2268
2269 if (isWindow(eventTarget)) {
2270 eventTarget.scrollBy(x, y);
2271 } else {
2272 eventTarget.scrollLeft += x;
2273 eventTarget.scrollTop += y;
2274 }
2275 };
2276
2277 __proto.resize = function () {
2278 var scrollContainer = this.scrollContainer;
2279 var horizontal = this.options.horizontal;
2280 var isBody = scrollContainer === document.body;
2281 var scrollContainerRect = isBody ? {
2282 top: 0,
2283 left: 0
2284 } : scrollContainer.getBoundingClientRect();
2285 var containerRect = this.container.getBoundingClientRect();
2286 this.scrollOffset = (this.prevScrollPos || 0) + (horizontal ? containerRect.left - scrollContainerRect.left : containerRect.top - scrollContainerRect.top);
2287
2288 if (isBody) {
2289 this.contentSize = horizontal ? window.innerWidth : window.innerHeight;
2290 } else {
2291 this.contentSize = horizontal ? scrollContainer.offsetWidth : scrollContainer.offsetHeight;
2292 }
2293 };
2294
2295 __proto.destroy = function () {
2296 var container = this.container;
2297 this.eventTarget.removeEventListener("scroll", this._onCheck);
2298
2299 if (this._isCreateElement) {
2300 var scrollContainer = this.scrollContainer;
2301 var fragment_1 = document.createDocumentFragment();
2302 var childNodes = toArray(container.childNodes);
2303 scrollContainer.removeChild(container);
2304 childNodes.forEach(function (childNode) {
2305 fragment_1.appendChild(childNode);
2306 });
2307 scrollContainer.appendChild(fragment_1);
2308 } else if (this.options.container) {
2309 container.style.cssText = this._orgCSSText;
2310 }
2311 };
2312
2313 __proto._init = function () {
2314 var _a;
2315
2316 var _b = this.options,
2317 containerOption = _b.container,
2318 containerTag = _b.containerTag,
2319 horizontal = _b.horizontal;
2320 var wrapper = this.wrapper;
2321 var scrollContainer = wrapper;
2322 var container = wrapper;
2323 var containerCSSText = "";
2324
2325 if (!containerOption) {
2326 scrollContainer = document.body;
2327 containerCSSText = container.style.cssText;
2328 } else {
2329 if (containerOption instanceof HTMLElement) {
2330 // Container that already exists
2331 container = containerOption;
2332 } else if (containerOption === true) {
2333 // Create Container
2334 container = document.createElement(containerTag);
2335 container.style.position = "relative";
2336 container.className = CONTAINER_CLASS_NAME;
2337 var childNodes = toArray(scrollContainer.childNodes);
2338 childNodes.forEach(function (childNode) {
2339 container.appendChild(childNode);
2340 });
2341 scrollContainer.appendChild(container);
2342 this._isCreateElement = true;
2343 } else {
2344 // Find Container by Selector
2345 container = scrollContainer.querySelector(containerOption);
2346 }
2347
2348 containerCSSText = container.style.cssText;
2349 var style = scrollContainer.style;
2350 _a = horizontal ? ["scroll", "hidden"] : ["hidden", "scroll"], style.overflowX = _a[0], style.overflowY = _a[1];
2351
2352 if (horizontal) {
2353 container.style.height = "100%";
2354 }
2355 }
2356
2357 var eventTarget = scrollContainer === document.body ? window : scrollContainer;
2358 eventTarget.addEventListener("scroll", this._onCheck);
2359 this._orgCSSText = containerCSSText;
2360 this.container = container;
2361 this.scrollContainer = scrollContainer;
2362 this.eventTarget = eventTarget;
2363 this.resize();
2364 this.setScrollPos(this.getOrgScrollPos());
2365 };
2366
2367 return ScrollManager;
2368}(Component);
2369
2370/**
2371 * A module used to arrange items including content infinitely according to layout type. With this module, you can implement various layouts composed of different items whose sizes vary. It guarantees performance by maintaining the number of DOMs the module is handling under any circumstance
2372 * @ko 콘텐츠가 있는 아이템을 레이아웃 타입에 따라 무한으로 배치하는 모듈. 다양한 크기의 아이템을 다양한 레이아웃으로 배치할 수 있다. 아이템의 개수가 계속 늘어나도 모듈이 처리하는 DOM의 개수를 일정하게 유지해 최적의 성능을 보장한다
2373 * @extends Component
2374 * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
2375 * @example
2376```html
2377<ul id="grid">
2378 <li class="card">
2379 <div>test1</div>
2380 </li>
2381 <li class="card">
2382 <div>test2</div>
2383 </li>
2384 <li class="card">
2385 <div>test3</div>
2386 </li>
2387 <li class="card">
2388 <div>test4</div>
2389 </li>
2390 <li class="card">
2391 <div>test5</div>
2392 </li>
2393 <li class="card">
2394 <div>test6</div>
2395 </li>
2396</ul>
2397<script>
2398import { MasonryInfiniteGrid } from "@egjs/infinitegrid";
2399var some = new MasonryInfiniteGrid("#grid").on("renderComplete", function(e) {
2400 // ...
2401});
2402// If you already have items in the container, call "layout" method.
2403some.renderItems();
2404</script>
2405```
2406 */
2407
2408var InfiniteGrid =
2409/*#__PURE__*/
2410function (_super) {
2411 __extends(InfiniteGrid, _super);
2412 /**
2413 * @param - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
2414 * @param - The option object of the InfiniteGrid module <ko>eg.InfiniteGrid 모듈의 옵션 객체</ko>
2415 */
2416
2417
2418 function InfiniteGrid(wrapper, options) {
2419 var _this = _super.call(this) || this;
2420
2421 _this._waitType = "";
2422
2423 _this._onScroll = function (_a) {
2424 var direction = _a.direction,
2425 scrollPos = _a.scrollPos,
2426 relativeScrollPos = _a.relativeScrollPos;
2427
2428 _this._scroll();
2429 /**
2430 * This event is fired when scrolling.
2431 * @ko 스크롤하면 발생하는 이벤트이다.
2432 * @event InfiniteGrid#changeScroll
2433 * @param {InfiniteGrid.OnChangeScroll} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2434 */
2435
2436
2437 _this.trigger(new ComponentEvent(INFINITEGRID_EVENTS.CHANGE_SCROLL, {
2438 direction: direction,
2439 scrollPos: scrollPos,
2440 relativeScrollPos: relativeScrollPos
2441 }));
2442 };
2443
2444 _this._onChange = function (e) {
2445 _this.setCursors(e.nextStartCursor, e.nextEndCursor);
2446 };
2447
2448 _this._onRendererUpdated = function (e) {
2449 if (!e.isChanged) {
2450 _this._checkEndLoading();
2451
2452 _this._scroll();
2453
2454 return;
2455 }
2456
2457 var renderedItems = e.items;
2458 var _a = e.diffResult,
2459 added = _a.added,
2460 removed = _a.removed,
2461 prevList = _a.prevList,
2462 list = _a.list;
2463 removed.forEach(function (index) {
2464 var orgItem = prevList[index].orgItem;
2465
2466 if (orgItem.mountState !== MOUNT_STATE.UNCHECKED) {
2467 orgItem.mountState = MOUNT_STATE.UNMOUNTED;
2468 }
2469 });
2470 renderedItems.forEach(function (item) {
2471 // set grid element
2472 var gridItem = item.orgItem;
2473 gridItem.element = item.element;
2474 });
2475 var horizontal = _this.options.horizontal;
2476 var addedItems = added.map(function (index) {
2477 var gridItem = list[index].orgItem;
2478 var element = gridItem.element;
2479
2480 if (gridItem.type === ITEM_TYPE.VIRTUAL) {
2481 var cssRect = __assign({}, gridItem.cssRect);
2482
2483 var rect = gridItem.rect;
2484
2485 if (!cssRect.width && rect.width) {
2486 cssRect.width = rect.width;
2487 }
2488
2489 if (!cssRect.height && rect.height) {
2490 cssRect.height = rect.height;
2491 } // virtual item
2492
2493
2494 return new GridItem(horizontal, {
2495 element: element,
2496 cssRect: cssRect
2497 });
2498 }
2499
2500 return gridItem;
2501 });
2502 var containerManager = _this.containerManager;
2503
2504 if (_this.options.observeChildren) {
2505 containerManager.observeChildren(added.map(function (index) {
2506 return list[index].element;
2507 }));
2508 containerManager.unobserveChildren(removed.map(function (index) {
2509 return prevList[index].element;
2510 }));
2511 }
2512
2513 var _b = e.state,
2514 isRestore = _b.isRestore,
2515 isResize = _b.isResize;
2516
2517 _this.itemRenderer.renderItems(addedItems);
2518
2519 if (isRestore) {
2520 _this._onRenderComplete({
2521 mounted: added.map(function (index) {
2522 return list[index].orgItem;
2523 }),
2524 updated: [],
2525 isResize: false,
2526 direction: _this.defaultDirection
2527 });
2528 }
2529
2530 if (!isRestore || isResize || e.isItemChanged) {
2531 _this.groupManager.renderItems();
2532 }
2533 };
2534
2535 _this._onResize = function (e) {
2536 if (e.isResizeContainer) {
2537 _this._renderItems({
2538 useResize: true
2539 }, true);
2540 } else {
2541 var updatedItems = getUpdatedItems(_this.getVisibleItems(), e.childEntries);
2542
2543 if (updatedItems.length > 0) {
2544 _this.updateItems(updatedItems);
2545 }
2546 }
2547 };
2548
2549 _this._onRequestAppend = function (e) {
2550 /**
2551 * The event is fired when scrolling reaches the end or when data for a virtual group is required.
2552 * @ko 스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다.
2553 * @event InfiniteGrid#requestAppend
2554 * @param {InfiniteGrid.OnRequestAppend} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2555 */
2556 _this._onRequestInsert(DIRECTION.END, INFINITEGRID_EVENTS.REQUEST_APPEND, e);
2557 };
2558
2559 _this._onRequestPrepend = function (e) {
2560 /**
2561 * The event is fired when scrolling reaches the start or when data for a virtual group is required.
2562 * @ko 스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다.
2563 * @event InfiniteGrid#requestPrepend
2564 * @param {InfiniteGrid.OnRequestPrepend} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2565 */
2566 _this._onRequestInsert(DIRECTION.START, INFINITEGRID_EVENTS.REQUEST_PREPEND, e);
2567 };
2568
2569 _this._onContentError = function (_a) {
2570 var element = _a.element,
2571 target = _a.target,
2572 item = _a.item,
2573 update = _a.update;
2574 /**
2575 * The event is fired when scrolling reaches the start or when data for a virtual group is required.
2576 * @ko 스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다.
2577 * @event InfiniteGrid#contentError
2578 * @param {InfiniteGrid.OnContentError} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2579 */
2580
2581 _this.trigger(new ComponentEvent(INFINITEGRID_EVENTS.CONTENT_ERROR, {
2582 element: element,
2583 target: target,
2584 item: item,
2585 update: update,
2586 remove: function () {
2587 _this.removeByKey(item.key);
2588 }
2589 }));
2590 };
2591
2592 _this._onRenderComplete = function (_a) {
2593 var isResize = _a.isResize,
2594 mounted = _a.mounted,
2595 updated = _a.updated,
2596 direction = _a.direction;
2597 var infinite = _this.infinite;
2598 var prevRenderedGroups = infinite.getRenderedVisibleItems();
2599 var length = prevRenderedGroups.length;
2600 var isDirectionEnd = direction === DIRECTION.END;
2601
2602 _this._syncInfinite();
2603
2604 if (length) {
2605 var prevStandardGroup = prevRenderedGroups[isDirectionEnd ? 0 : length - 1];
2606 var nextStandardGroup = infinite.getItemByKey(prevStandardGroup.key);
2607 var offset = isDirectionEnd ? Math.min.apply(Math, nextStandardGroup.startOutline) - Math.min.apply(Math, prevStandardGroup.startOutline) : Math.max.apply(Math, nextStandardGroup.endOutline) - Math.max.apply(Math, prevStandardGroup.endOutline);
2608
2609 _this.scrollManager.scrollBy(offset);
2610 }
2611 /**
2612 * This event is fired when the InfiniteGrid has completed rendering.
2613 * @ko InfiniteGrid가 렌더링이 완료됐을 때 이벤트가 발생한다.
2614 * @event InfiniteGrid#renderComplete
2615 * @param {InfiniteGrid.OnRenderComplete} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2616 */
2617
2618
2619 _this.trigger(new ComponentEvent(INFINITEGRID_EVENTS.RENDER_COMPLETE, {
2620 isResize: isResize,
2621 direction: direction,
2622 mounted: mounted.filter(function (item) {
2623 return item.type !== ITEM_TYPE.LOADING;
2624 }),
2625 updated: updated.filter(function (item) {
2626 return item.type !== ITEM_TYPE.LOADING;
2627 }),
2628 startCursor: _this.getStartCursor(),
2629 endCursor: _this.getEndCursor(),
2630 items: _this.getVisibleItems(true),
2631 groups: _this.getVisibleGroups(true)
2632 }));
2633
2634 if (_this.groupManager.shouldRerenderItems()) {
2635 _this._update();
2636 } else {
2637 _this._checkEndLoading();
2638
2639 _this._scroll();
2640 }
2641 };
2642
2643 _this.options = __assign(__assign(__assign({}, _this.constructor.defaultOptions), {
2644 renderer: new VanillaGridRenderer().on("requestUpdate", function () {
2645 return _this._render();
2646 })
2647 }), options);
2648
2649 var _a = _this.options,
2650 gridConstructor = _a.gridConstructor,
2651 containerTag = _a.containerTag,
2652 container = _a.container,
2653 renderer = _a.renderer,
2654 threshold = _a.threshold,
2655 useRecycle = _a.useRecycle,
2656 gridOptions = __rest(_a, ["gridConstructor", "containerTag", "container", "renderer", "threshold", "useRecycle"]); // options.container === false, wrapper = container, scrollContainer = document.body
2657 // options.container === true, wrapper = scrollContainer, container = wrapper's child
2658 // options.container === string,
2659
2660
2661 var horizontal = gridOptions.horizontal,
2662 attributePrefix = gridOptions.attributePrefix,
2663 useTransform = gridOptions.useTransform,
2664 percentage = gridOptions.percentage,
2665 isConstantSize = gridOptions.isConstantSize,
2666 isEqualSize = gridOptions.isEqualSize,
2667 autoResize = gridOptions.autoResize,
2668 useResizeObserver = gridOptions.useResizeObserver,
2669 resizeDebounce = gridOptions.resizeDebounce,
2670 maxResizeDebounce = gridOptions.maxResizeDebounce,
2671 defaultDirection = gridOptions.defaultDirection;
2672 var wrapperElement = isString(wrapper) ? document.querySelector(wrapper) : wrapper;
2673 var scrollManager = new ScrollManager(wrapperElement, {
2674 container: container,
2675 containerTag: containerTag,
2676 horizontal: horizontal
2677 }).on({
2678 scroll: _this._onScroll
2679 });
2680 var containerElement = scrollManager.getContainer();
2681 var containerManager = new ContainerManager(containerElement, {
2682 horizontal: horizontal,
2683 autoResize: autoResize,
2684 resizeDebounce: resizeDebounce,
2685 maxResizeDebounce: maxResizeDebounce,
2686 useResizeObserver: useResizeObserver
2687 }).on("resize", _this._onResize);
2688 var itemRenderer = new ItemRenderer({
2689 attributePrefix: attributePrefix,
2690 horizontal: horizontal,
2691 useTransform: useTransform,
2692 percentage: percentage,
2693 isEqualSize: isEqualSize,
2694 isConstantSize: isConstantSize
2695 });
2696 var infinite = new Infinite({
2697 defaultDirection: defaultDirection,
2698 useRecycle: useRecycle,
2699 threshold: threshold
2700 }).on({
2701 "change": _this._onChange,
2702 "requestAppend": _this._onRequestAppend,
2703 "requestPrepend": _this._onRequestPrepend
2704 });
2705 infinite.setSize(scrollManager.getContentSize());
2706 var groupManager = new GroupManager(containerElement, {
2707 gridConstructor: gridConstructor,
2708 externalItemRenderer: itemRenderer,
2709 externalContainerManager: containerManager,
2710 gridOptions: gridOptions
2711 });
2712 groupManager.on({
2713 "renderComplete": _this._onRenderComplete,
2714 "contentError": _this._onContentError
2715 });
2716 renderer.setContainer(containerElement);
2717 renderer.on("updated", _this._onRendererUpdated);
2718 _this.itemRenderer = itemRenderer;
2719 _this.groupManager = groupManager;
2720 _this.wrapperElement = wrapperElement;
2721 _this.scrollManager = scrollManager;
2722 _this.containerManager = containerManager;
2723 _this.infinite = infinite;
2724
2725 _this.containerManager.resize();
2726
2727 return _this;
2728 }
2729
2730 var __proto = InfiniteGrid.prototype;
2731 InfiniteGrid_1 = InfiniteGrid;
2732 /**
2733 * Rearrange items to fit the grid and render them. When rearrange is complete, the `renderComplete` event is fired.
2734 * @ko grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다.
2735 * @param - Options for rendering. <ko>렌더링을 하기 위한 옵션.</ko>
2736 * @example
2737 * ```ts
2738 * import { MasonryInfiniteGrid } from "@egjs/infinitegrid";
2739 * const grid = new MasonryInfiniteGrid();
2740 *
2741 * grid.on("renderComplete", e => {
2742 * console.log(e);
2743 * });
2744 * grid.renderItems();
2745 * ```
2746 */
2747
2748 __proto.renderItems = function (options) {
2749 if (options === void 0) {
2750 options = {};
2751 }
2752
2753 this._renderItems(options);
2754
2755 return this;
2756 };
2757 /**
2758 * Returns the wrapper element specified by the user.
2759 * @ko 컨테이너 엘리먼트를 반환한다.
2760 */
2761
2762
2763 __proto.getWrapperElement = function () {
2764 return this.scrollManager.getWrapper();
2765 };
2766 /**
2767 * Returns the container element corresponding to the scroll area.
2768 * @ko 스크롤 영역에 해당하는 컨테이너 엘리먼트를 반환한다.
2769 */
2770
2771
2772 __proto.getScrollContainerElement = function () {
2773 return this.scrollManager.getScrollContainer();
2774 };
2775 /**
2776 * Returns the container element containing item elements.
2777 * @ko 아이템 엘리먼트들을 담긴 컨테이너 엘리먼트를 반환한다.
2778 */
2779
2780
2781 __proto.getContainerElement = function () {
2782 return this.scrollManager.getContainer();
2783 };
2784 /**
2785 * When items change, it synchronizes and renders items.
2786 * @ko items가 바뀐 경우 동기화를 하고 렌더링을 한다.
2787 * @param - Options for rendering. <ko>렌더링을 하기 위한 옵션.</ko>
2788 */
2789
2790
2791 __proto.syncItems = function (items) {
2792 this.groupManager.syncItems(items);
2793
2794 this._syncGroups();
2795
2796 return this;
2797 };
2798 /**
2799 * Change the currently visible groups.
2800 * @ko 현재 보이는 그룹들을 바꾼다.
2801 * @param - first index of visible groups. <ko>보이는 그룹의 첫번째 index.</ko>
2802 * @param - last index of visible groups. <ko>보이는 그룹의 마지막 index.</ko>
2803 * @param - Whether the first rendering has already been done. <ko>첫 렌더링이 이미 되어있는지 여부.</ko>
2804 */
2805
2806
2807 __proto.setCursors = function (startCursor, endCursor, useFirstRender) {
2808 this.groupManager.setCursors(startCursor, endCursor);
2809 this.infinite.setCursors(startCursor, endCursor);
2810
2811 if (useFirstRender) {
2812 this._syncItems();
2813 } else {
2814 this._update();
2815
2816 this._checkEndLoading();
2817 }
2818
2819 return this;
2820 };
2821 /**
2822 * Returns the first index of visible groups.
2823 * @ko 보이는 그룹들의 첫번째 index를 반환한다.
2824 */
2825
2826
2827 __proto.getStartCursor = function () {
2828 return this.infinite.getStartCursor();
2829 };
2830 /**
2831 * Returns the last index of visible groups.
2832 * @ko 보이는 그룹들의 마지막 index를 반환한다.
2833 */
2834
2835
2836 __proto.getEndCursor = function () {
2837 return this.infinite.getEndCursor();
2838 };
2839 /**
2840 * Add items at the bottom(right) of the grid.
2841 * @ko 아이템들을 grid 아래(오른쪽)에 추가한다.
2842 * @param - items to be added <ko>추가할 아이템들</ko>
2843 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2844 * @return - An instance of a module itself<ko>모듈 자신의 인스턴스</ko>
2845 * @example
2846 * ```js
2847 * ig.append(`<div class="item">test1</div><div class="item">test2</div>`);
2848 * ig.append([`<div class="item">test1</div>`, `<div class="item">test2</div>`]);
2849 * ig.append([HTMLElement1, HTMLElement2]);
2850 * ```
2851 */
2852
2853
2854 __proto.append = function (items, groupKey) {
2855 return this.insert(-1, items, groupKey);
2856 };
2857 /**
2858 * Add items at the top(left) of the grid.
2859 * @ko 아이템들을 grid 위(왼쪽)에 추가한다.
2860 * @param - items to be added <ko>추가할 아이템들</ko>
2861 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2862 * @return - An instance of a module itself<ko>모듈 자신의 인스턴스</ko>
2863 * @example
2864 * ```ts
2865 * ig.prepend(`<div class="item">test1</div><div class="item">test2</div>`);
2866 * ig.prepend([`<div class="item">test1</div>`, `<div class="item">test2</div>`]);
2867 * ig.prepend([HTMLElement1, HTMLElement2]);
2868 * ```
2869 */
2870
2871
2872 __proto.prepend = function (items, groupKey) {
2873 return this.insert(0, items, groupKey);
2874 };
2875 /**
2876 * Add items to a specific index.
2877 * @ko 아이템들을 특정 index에 추가한다.
2878 * @param - index to add <ko>추가하기 위한 index</ko>
2879 * @param - items to be added <ko>추가할 아이템들</ko>
2880 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2881 * @return - An instance of a module itself<ko>모듈 자신의 인스턴스</ko>
2882 * @example
2883 * ```ts
2884 * ig.insert(2, `<div class="item">test1</div><div class="item">test2</div>`);
2885 * ig.insert(3, [`<div class="item">test1</div>`, `<div class="item">test2</div>`]);
2886 * ig.insert(4, [HTMLElement1, HTMLElement2]);
2887 * ```
2888 */
2889
2890
2891 __proto.insert = function (index, items, groupKey) {
2892 var nextItemInfos = this.groupManager.getGroupItems();
2893 var itemInfos = convertInsertedItems(items, groupKey);
2894
2895 if (index === -1) {
2896 nextItemInfos.push.apply(nextItemInfos, itemInfos);
2897 } else {
2898 nextItemInfos.splice.apply(nextItemInfos, __spreadArrays([index, 0], itemInfos));
2899 }
2900
2901 return this.syncItems(nextItemInfos);
2902 };
2903 /**
2904 * Add items based on group index.
2905 * @ko group의 index 기준으로 item들을 추가한다.
2906 * @param - group index to add <ko>추가하기 위한 group의 index</ko>
2907 * @param - items to be added <ko>추가할 아이템들</ko>
2908 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2909 * @return - An instance of a module itself<ko>모듈 자신의 인스턴스</ko>
2910 * @example
2911 * ```ts
2912 * ig.insertByGroupIndex(2, `<div class="item">test1</div><div class="item">test2</div>`);
2913 * ig.insertByGroupIndex(3, [`<div class="item">test1</div>`, `<div class="item">test2</div>`]);
2914 * ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]);
2915 * ```
2916 */
2917
2918
2919 __proto.insertByGroupIndex = function (groupIndex, items, groupKey) {
2920 var nextGroupInfos = this.groupManager.getGroups();
2921 var rightGroup = nextGroupInfos[groupIndex];
2922
2923 if (!rightGroup) {
2924 return this.append(items, groupKey);
2925 }
2926
2927 var nextItemInfos = this.groupManager.getGroupItems();
2928 var rightGroupKey = rightGroup.groupKey;
2929 var rightItemIndex = findIndex(nextItemInfos, function (item) {
2930 return item.groupKey === rightGroupKey;
2931 });
2932 return this.insert(rightItemIndex, items, groupKey);
2933 };
2934 /**
2935 * 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.
2936 * @ko 아이템의 위치 정보 등 모듈의 현재 상태 정보를 반환한다. 이 메서드가 반환한 정보를 저장해 두었다가 setStatus() 메서드로 복원할 수 있다
2937 * @param - STATUS_TYPE.NOT_REMOVE = Get all information about items. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = Get information on visible items only. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = Compress invisible items. You can replace it with a placeholder. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = Compress invisible groups. <ko> STATUS_TYPE.NOT_REMOVE = 모든 아이템들의 정보를 가져온다. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = 보이는 아이템들의 정보만 가져온다. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = 안보이는 아이템들을 압축한다. placeholder로 대체가 가능하다. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = 안보이는 그룹을 압축한다.</ko>
2938 * @param - Whether to include items corresponding to placeholders. <ko>placeholder에 해당하는 아이템들을 포함할지 여부.</ko>
2939 */
2940
2941
2942 __proto.getStatus = function (type, includePlaceholders) {
2943 return {
2944 containerManager: this.containerManager.getStatus(),
2945 itemRenderer: this.itemRenderer.getStatus(),
2946 groupManager: this.groupManager.getGroupStatus(type, includePlaceholders),
2947 scrollManager: this.scrollManager.getStatus()
2948 };
2949 };
2950 /**
2951 * You can set placeholders to restore status or wait for items to be added.
2952 * @ko status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다.
2953 * @param - The placeholder status. <ko>placeholder의 status</ko>
2954 */
2955
2956
2957 __proto.setPlaceholder = function (info) {
2958 this.groupManager.setPlaceholder(info);
2959 return this;
2960 };
2961 /**
2962 * You can set placeholders to restore status or wait for items to be added.
2963 * @ko status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다.
2964 * @param - The placeholder status. <ko>placeholder의 status</ko>
2965 */
2966
2967
2968 __proto.setLoading = function (info) {
2969 this.groupManager.setLoading(info);
2970 return this;
2971 };
2972 /**
2973 * Add the placeholder at the end.
2974 * @ko placeholder들을 마지막에 추가한다.
2975 * @param - Items that correspond to placeholders. If it is a number, it duplicates the number of copies. <ko>placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.</ko>
2976 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2977 */
2978
2979
2980 __proto.appendPlaceholders = function (items, groupKey) {
2981 var _this = this;
2982
2983 var result = this.groupManager.appendPlaceholders(items, groupKey);
2984
2985 this._syncGroups(true);
2986
2987 return __assign(__assign({}, result), {
2988 remove: function () {
2989 _this.removePlaceholders({
2990 groupKey: result.group.groupKey
2991 });
2992 }
2993 });
2994 };
2995 /**
2996 * Add the placeholder at the start.
2997 * @ko placeholder들을 처음에 추가한다.
2998 * @param - Items that correspond to placeholders. If it is a number, it duplicates the number of copies. <ko>placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.</ko>
2999 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
3000 */
3001
3002
3003 __proto.prependPlaceholders = function (items, groupKey) {
3004 var _this = this;
3005
3006 var result = this.groupManager.prependPlaceholders(items, groupKey);
3007
3008 this._syncGroups(true);
3009
3010 return __assign(__assign({}, result), {
3011 remove: function () {
3012 _this.removePlaceholders({
3013 groupKey: result.group.groupKey
3014 });
3015 }
3016 });
3017 };
3018 /**
3019 * Remove placeholders
3020 * @ko placeholder들을 삭제한다.
3021 * @param type - Remove the placeholders corresponding to the groupkey. When "start" or "end", remove all placeholders in that direction. <ko>groupkey에 해당하는 placeholder들을 삭제한다. "start" 또는 "end" 일 때 해당 방향의 모든 placeholder들을 삭제한다.</ko>
3022 */
3023
3024
3025 __proto.removePlaceholders = function (type) {
3026 this.groupManager.removePlaceholders(type);
3027
3028 this._syncGroups(true);
3029 };
3030 /**
3031 * Sets the status of the InfiniteGrid module with the information returned through a call to the getStatus() method.
3032 * @ko getStatus() 메서드가 저장한 정보로 InfiniteGrid 모듈의 상태를 설정한다.
3033 * @param - status object of the InfiniteGrid module. <ko>InfiniteGrid 모듈의 status 객체.</ko>
3034 * @param - Whether the first rendering has already been done. <ko>첫 렌더링이 이미 되어있는지 여부.</ko>
3035 */
3036
3037
3038 __proto.setStatus = function (status, useFirstRender) {
3039 this.itemRenderer.setStatus(status.itemRenderer);
3040 this.containerManager.setStatus(status.containerManager);
3041 this.scrollManager.setStatus(status.scrollManager);
3042 var groupManager = this.groupManager;
3043 var prevInlineSize = this.containerManager.getInlineSize();
3044 groupManager.setGroupStatus(status.groupManager);
3045
3046 this._syncInfinite();
3047
3048 this.infinite.setCursors(groupManager.getStartCursor(), groupManager.getEndCursor());
3049
3050 this._getRenderer().updateKey();
3051
3052 var state = {
3053 isResize: this.containerManager.getInlineSize() !== prevInlineSize,
3054 isRestore: true
3055 };
3056
3057 if (useFirstRender) {
3058 this._syncItems(state);
3059 } else {
3060 this._update(state);
3061 }
3062
3063 return this;
3064 };
3065 /**
3066 * Removes the group corresponding to index.
3067 * @ko index에 해당하는 그룹을 제거 한다.
3068 */
3069
3070
3071 __proto.removeGroupByIndex = function (index) {
3072 var nextGroups = this.getGroups();
3073 return this.removeGroupByKey(nextGroups[index].groupKey);
3074 };
3075 /**
3076 * Removes the group corresponding to key.
3077 * @ko key에 해당하는 그룹을 제거 한다.
3078 */
3079
3080
3081 __proto.removeGroupByKey = function (key) {
3082 var nextItemInfos = this.getItems();
3083 var firstIndex = findIndex(nextItemInfos, function (item) {
3084 return item.groupKey === key;
3085 });
3086 var lastIndex = findLastIndex(nextItemInfos, function (item) {
3087 return item.groupKey === key;
3088 });
3089
3090 if (firstIndex === -1) {
3091 return this;
3092 }
3093
3094 nextItemInfos.splice(firstIndex, lastIndex - firstIndex + 1);
3095 return this.syncItems(nextItemInfos);
3096 };
3097 /**
3098 * Removes the item corresponding to index.
3099 * @ko index에 해당하는 아이템을 제거 한다.
3100 */
3101
3102
3103 __proto.removeByIndex = function (index) {
3104 var nextItemInfos = this.getItems(true);
3105 nextItemInfos.splice(index, 1);
3106 return this.syncItems(nextItemInfos);
3107 };
3108 /**
3109 * Removes the item corresponding to key.
3110 * @ko key에 해당하는 아이템을 제거 한다.
3111 */
3112
3113
3114 __proto.removeByKey = function (key) {
3115 var nextItemInfos = this.getItems(true);
3116 var index = findIndex(nextItemInfos, function (item) {
3117 return item.key === key;
3118 });
3119 return this.removeByIndex(index);
3120 };
3121 /**
3122 * Update the size of the items and render them.
3123 * @ko 아이템들의 사이즈를 업데이트하고 렌더링을 한다.
3124 * @param - Items to be updated. <ko>업데이트할 아이템들.</ko>
3125 * @param - Options for rendering. <ko>렌더링을 하기 위한 옵션.</ko>
3126 */
3127
3128
3129 __proto.updateItems = function (items, options) {
3130 if (options === void 0) {
3131 options = {};
3132 }
3133
3134 this.groupManager.updateItems(items, options);
3135 return this;
3136 };
3137 /**
3138 * Return all items of InfiniteGrid.
3139 * @ko InfiniteGrid의 모든 아이템들을 반환한다.
3140 * @param - Whether to include items corresponding to placeholders. <ko>placeholder에 해당하는 아이템들을 포함할지 여부.</ko>
3141 */
3142
3143
3144 __proto.getItems = function (includePlaceholders) {
3145 return this.groupManager.getGroupItems(includePlaceholders);
3146 };
3147 /**
3148 * Return visible items of InfiniteGrid.
3149 * @ko InfiniteGrid의 보이는 아이템들을 반환한다.
3150 * @param - Whether to include items corresponding to placeholders. <ko>placeholder에 해당하는 아이템들을 포함할지 여부.</ko>
3151 */
3152
3153
3154 __proto.getVisibleItems = function (includePlaceholders) {
3155 return this.groupManager.getVisibleItems(includePlaceholders);
3156 };
3157 /**
3158 * Return rendering items of InfiniteGrid.
3159 * @ko InfiniteGrid의 렌더링 아이템들을 반환한다.
3160 */
3161
3162
3163 __proto.getRenderingItems = function () {
3164 return this.groupManager.getRenderingItems();
3165 };
3166 /**
3167 * Return all groups of InfiniteGrid.
3168 * @ko InfiniteGrid의 모든 그룹들을 반환한다.
3169 * @param - Whether to include groups corresponding to placeholders. <ko>placeholder에 해당하는 그룹들을 포함할지 여부.</ko>
3170 */
3171
3172
3173 __proto.getGroups = function (includePlaceholders) {
3174 return this.groupManager.getGroups(includePlaceholders);
3175 };
3176 /**
3177 * Return visible groups of InfiniteGrid.
3178 * @ko InfiniteGrid의 보이는 그룹들을 반환한다.
3179 * @param - Whether to include groups corresponding to placeholders. <ko>placeholder에 해당하는 그룹들을 포함할지 여부.</ko>
3180 */
3181
3182
3183 __proto.getVisibleGroups = function (includePlaceholders) {
3184 return this.groupManager.getVisibleGroups(includePlaceholders);
3185 };
3186 /**
3187 * Set to wait to request data.
3188 * @ko 데이터를 요청하기 위해 대기 상태로 설정한다.
3189 * @param direction - direction in which data will be added. <ko>데이터를 추가하기 위한 방향.</ko>
3190 */
3191
3192
3193 __proto.wait = function (direction) {
3194 if (direction === void 0) {
3195 direction = DIRECTION.END;
3196 }
3197
3198 this._waitType = direction;
3199
3200 this._checkStartLoading(direction);
3201 };
3202 /**
3203 * When the data request is complete, it is set to ready state.
3204 * @ko 데이터 요청이 끝났다면 준비 상태로 설정한다.
3205 */
3206
3207
3208 __proto.ready = function () {
3209 this._waitType = "";
3210 };
3211 /**
3212 * Returns whether it is set to wait to request data.
3213 * @ko 데이터를 요청하기 위해 대기 상태로 설정되어 있는지 여부를 반환한다.
3214 */
3215
3216
3217 __proto.isWait = function () {
3218 return !!this._waitType;
3219 };
3220 /**
3221 * Releases the instnace and events and returns the CSS of the container and elements.
3222 * @ko 인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다.
3223 */
3224
3225
3226 __proto.destroy = function () {
3227 this.off();
3228
3229 this._getRenderer().destroy();
3230
3231 this.containerManager.destroy();
3232 this.groupManager.destroy();
3233 this.scrollManager.destroy();
3234 this.infinite.destroy();
3235 };
3236
3237 __proto._getRenderer = function () {
3238 return this.options.renderer;
3239 };
3240
3241 __proto._getRendererItems = function () {
3242 return this.getRenderingItems().map(function (item) {
3243 return {
3244 element: item.element,
3245 key: item.type + "_" + item.key,
3246 orgItem: item
3247 };
3248 });
3249 };
3250
3251 __proto._syncItems = function (state) {
3252 this._getRenderer().syncItems(this._getRendererItems(), state);
3253 };
3254
3255 __proto._render = function (state) {
3256 this._getRenderer().render(this._getRendererItems(), state);
3257 };
3258
3259 __proto._update = function (state) {
3260 if (state === void 0) {
3261 state = {};
3262 }
3263
3264 this._getRenderer().update(state);
3265 };
3266
3267 __proto._resizeScroll = function () {
3268 var scrollManager = this.scrollManager;
3269 scrollManager.resize();
3270 this.infinite.setSize(scrollManager.getContentSize());
3271 };
3272
3273 __proto._syncGroups = function (isUpdate) {
3274 var infinite = this.infinite;
3275 var scrollManager = this.scrollManager;
3276
3277 if (!scrollManager.getContentSize()) {
3278 this._resizeScroll();
3279 }
3280
3281 this._syncInfinite();
3282
3283 this.groupManager.setCursors(infinite.getStartCursor(), infinite.getEndCursor());
3284
3285 if (isUpdate) {
3286 this._update();
3287 } else {
3288 this._render();
3289 }
3290 };
3291
3292 __proto._syncInfinite = function () {
3293 this.infinite.syncItems(this.getGroups(true).map(function (_a) {
3294 var groupKey = _a.groupKey,
3295 grid = _a.grid,
3296 type = _a.type;
3297 var outlines = grid.getOutlines();
3298 return {
3299 key: groupKey,
3300 isVirtual: type === GROUP_TYPE.VIRTUAL,
3301 startOutline: outlines.start,
3302 endOutline: outlines.end
3303 };
3304 }));
3305 };
3306
3307 __proto._scroll = function () {
3308 this.infinite.scroll(this.scrollManager.getRelativeScrollPos());
3309 };
3310
3311 __proto._onRequestInsert = function (direction, eventType, e) {
3312 var _this = this;
3313
3314 if (this._waitType) {
3315 this._checkStartLoading(this._waitType);
3316
3317 return;
3318 }
3319
3320 this.trigger(new ComponentEvent(eventType, {
3321 groupKey: e.key,
3322 nextGroupKey: e.nextKey,
3323 nextGroupKeys: e.nextKeys || [],
3324 isVirtual: e.isVirtual,
3325 wait: function () {
3326 _this.wait(direction);
3327 },
3328 ready: function () {
3329 _this.ready();
3330 }
3331 }));
3332 };
3333
3334 __proto._renderItems = function (options, isTrusted) {
3335 if (options === void 0) {
3336 options = {};
3337 }
3338
3339 if (!isTrusted && options.useResize) {
3340 this.containerManager.resize();
3341 }
3342
3343 this._resizeScroll();
3344
3345 if (!this.getRenderingItems().length) {
3346 var children = toArray(this.getContainerElement().children);
3347
3348 if (children.length > 0) {
3349 // no items, but has children
3350 this.groupManager.syncItems(convertInsertedItems(children));
3351
3352 this._syncInfinite();
3353
3354 this.setCursors(0, 0, true);
3355
3356 this._getRenderer().updated();
3357 } else {
3358 this.infinite.scroll(0);
3359 }
3360
3361 return this;
3362 }
3363
3364 if (!this.getVisibleGroups(true).length) {
3365 this.setCursors(0, 0);
3366 } else {
3367 this.groupManager.renderItems(options);
3368 }
3369
3370 return this;
3371 };
3372
3373 __proto._checkStartLoading = function (direction) {
3374 var groupManager = this.groupManager;
3375 var infinite = this.infinite;
3376
3377 if (!groupManager.getLoadingType() && infinite.isLoading(direction) && groupManager.startLoading(direction) && groupManager.hasLoadingItem()) {
3378 this._update();
3379 }
3380 };
3381
3382 __proto._checkEndLoading = function () {
3383 var groupManager = this.groupManager;
3384 var loadingType = this.groupManager.getLoadingType();
3385
3386 if (loadingType && (!this._waitType || !this.infinite.isLoading(loadingType)) && groupManager.endLoading() && groupManager.hasLoadingItem()) {
3387 this._update();
3388 }
3389 };
3390
3391 var InfiniteGrid_1;
3392 InfiniteGrid.defaultOptions = __assign(__assign({}, DEFAULT_GRID_OPTIONS), {
3393 container: false,
3394 containerTag: "div",
3395 renderer: null,
3396 threshold: 100,
3397 useRecycle: true
3398 });
3399 InfiniteGrid.propertyTypes = INFINITEGRID_PROPERTY_TYPES;
3400 InfiniteGrid = InfiniteGrid_1 = __decorate([InfiniteGridGetterSetter], InfiniteGrid);
3401 return InfiniteGrid;
3402}(Component);
3403
3404/**
3405 * MasonryInfiniteGrid is a grid that stacks items 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 item.
3406 * @ko MasonryInfiniteGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템을 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다.
3407 * @param {HTMLElement | string} container - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
3408 * @param {MasonryInfiniteGridOptions} options - The option object of the MasonryInfiniteGrid module <ko>MasonryInfiniteGrid 모듈의 옵션 객체</ko>
3409 */
3410
3411var MasonryInfiniteGrid =
3412/*#__PURE__*/
3413function (_super) {
3414 __extends(MasonryInfiniteGrid, _super);
3415
3416 function MasonryInfiniteGrid() {
3417 return _super !== null && _super.apply(this, arguments) || this;
3418 }
3419
3420 MasonryInfiniteGrid.propertyTypes = __assign(__assign({}, InfiniteGrid.propertyTypes), MasonryGrid.propertyTypes);
3421 MasonryInfiniteGrid.defaultOptions = __assign(__assign(__assign({}, InfiniteGrid.defaultOptions), MasonryGrid.defaultOptions), {
3422 gridConstructor: MasonryGrid
3423 });
3424 MasonryInfiniteGrid = __decorate([InfiniteGridGetterSetter], MasonryInfiniteGrid);
3425 return MasonryInfiniteGrid;
3426}(InfiniteGrid);
3427
3428/**
3429 * 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedInfiniteGrid is a grid that the item is filled up on the basis of a line given a size.
3430 * If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value.
3431 * If 'data-grid-maintained-target' is set for an element whose ratio is to be maintained, the item is rendered while maintaining the ratio of the element.
3432 * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedInfiniteGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다.
3433 * 아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다.
3434 * 비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다.
3435 * @param {HTMLElement | string} container - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
3436 * @param {JustifiedInfiniteGridOptions} options - The option object of the JustifiedInfiniteGrid module <ko>JustifiedInfiniteGrid 모듈의 옵션 객체</ko>
3437 */
3438
3439var JustifiedInfiniteGrid =
3440/*#__PURE__*/
3441function (_super) {
3442 __extends(JustifiedInfiniteGrid, _super);
3443
3444 function JustifiedInfiniteGrid() {
3445 return _super !== null && _super.apply(this, arguments) || this;
3446 }
3447
3448 JustifiedInfiniteGrid.propertyTypes = __assign(__assign({}, InfiniteGrid.propertyTypes), JustifiedGrid.propertyTypes);
3449 JustifiedInfiniteGrid.defaultOptions = __assign(__assign(__assign({}, InfiniteGrid.defaultOptions), JustifiedGrid.defaultOptions), {
3450 gridConstructor: JustifiedGrid
3451 });
3452 JustifiedInfiniteGrid = __decorate([InfiniteGridGetterSetter], JustifiedInfiniteGrid);
3453 return JustifiedInfiniteGrid;
3454}(InfiniteGrid);
3455
3456/**
3457 * 'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameInfiniteGrid is a grid that the item is filled up on the basis of a line given a size.
3458 * @ko 'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameInfiniteGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다.
3459 * @param {HTMLElement | string} container - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
3460 * @param {FrameInfiniteGridOptions} options - The option object of the FrameInfiniteGrid module <ko>FrameGrid 모듈의 옵션 객체</ko>
3461 */
3462
3463var FrameInfiniteGrid =
3464/*#__PURE__*/
3465function (_super) {
3466 __extends(FrameInfiniteGrid, _super);
3467
3468 function FrameInfiniteGrid() {
3469 return _super !== null && _super.apply(this, arguments) || this;
3470 }
3471
3472 FrameInfiniteGrid.propertyTypes = __assign(__assign({}, InfiniteGrid.propertyTypes), FrameGrid.propertyTypes);
3473 FrameInfiniteGrid.defaultOptions = __assign(__assign(__assign({}, InfiniteGrid.defaultOptions), FrameGrid.defaultOptions), {
3474 gridConstructor: FrameGrid
3475 });
3476 FrameInfiniteGrid = __decorate([InfiniteGridGetterSetter], FrameInfiniteGrid);
3477 return FrameInfiniteGrid;
3478}(InfiniteGrid);
3479
3480/**
3481 * The PackingInfiniteGrid is a grid that shows the important items bigger without sacrificing the weight of the items.
3482 * Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion.
3483 * If `sizeWeight` is higher than `ratioWeight`, the size of items is preserved as much as possible.
3484 * Conversely, if `ratioWeight` is higher than `sizeWeight`, the ratio of items is preserved as much as possible.
3485 * @ko PackingInfiniteGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다.
3486 * 행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다.
3487 * `sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다.
3488 * 반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다.
3489 * @param {HTMLElement | string} container - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
3490 * @param {PackingInfiniteGridOptions} options - The option object of the PackingInfiniteGrid module <ko>PackingInfiniteGrid 모듈의 옵션 객체</ko>
3491 */
3492
3493var PackingInfiniteGrid =
3494/*#__PURE__*/
3495function (_super) {
3496 __extends(PackingInfiniteGrid, _super);
3497
3498 function PackingInfiniteGrid() {
3499 return _super !== null && _super.apply(this, arguments) || this;
3500 }
3501
3502 PackingInfiniteGrid.propertyTypes = __assign(__assign({}, InfiniteGrid.propertyTypes), PackingGrid.propertyTypes);
3503 PackingInfiniteGrid.defaultOptions = __assign(__assign(__assign({}, InfiniteGrid.defaultOptions), PackingGrid.defaultOptions), {
3504 gridConstructor: PackingGrid
3505 });
3506 PackingInfiniteGrid = __decorate([InfiniteGridGetterSetter], PackingInfiniteGrid);
3507 return PackingInfiniteGrid;
3508}(InfiniteGrid);
3509
3510export default InfiniteGrid;
3511export { CONTAINER_CLASS_NAME, DIRECTION, FrameInfiniteGrid, GROUP_TYPE, IGNORE_PROPERITES_MAP, INFINITEGRID_EVENTS, INFINITEGRID_METHODS, INFINITEGRID_PROPERTY_TYPES, INVISIBLE_POS, IS_IOS, ITEM_INFO_PROPERTIES, ITEM_TYPE, InfiniteGridItem, JustifiedInfiniteGrid, MasonryInfiniteGrid, PackingInfiniteGrid, Renderer, STATUS_TYPE, getRenderingItems, mountRenderingItems, withInfiniteGridMethods };
3512//# sourceMappingURL=infinitegrid.esm.js.map