UNPKG

304 kBJavaScriptView Raw
1/*
2Copyright (c) 2015-present NAVER Corp.
3name: @egjs/flicking
4license: MIT
5author: NAVER Corp.
6repository: https://github.com/naver/egjs-flicking
7version: 4.11.3
8*/
9import Component, { ComponentEvent } from '@egjs/component';
10import Axes, { PanInput } from '@egjs/axes';
11import ImReady from '@egjs/imready';
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/* global Reflect, Promise, SuppressedError, Symbol */
28
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 return extendStatics(d, b);
38};
39function __extends(d, b) {
40 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
41 extendStatics(d, b);
42 function __() {
43 this.constructor = d;
44 }
45 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
46}
47var __assign = function () {
48 __assign = Object.assign || function __assign(t) {
49 for (var s, i = 1, n = arguments.length; i < n; i++) {
50 s = arguments[i];
51 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
52 }
53 return t;
54 };
55 return __assign.apply(this, arguments);
56};
57function __awaiter(thisArg, _arguments, P, generator) {
58 function adopt(value) {
59 return value instanceof P ? value : new P(function (resolve) {
60 resolve(value);
61 });
62 }
63 return new (P || (P = Promise))(function (resolve, reject) {
64 function fulfilled(value) {
65 try {
66 step(generator.next(value));
67 } catch (e) {
68 reject(e);
69 }
70 }
71 function rejected(value) {
72 try {
73 step(generator["throw"](value));
74 } catch (e) {
75 reject(e);
76 }
77 }
78 function step(result) {
79 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
80 }
81 step((generator = generator.apply(thisArg, _arguments || [])).next());
82 });
83}
84function __generator(thisArg, body) {
85 var _ = {
86 label: 0,
87 sent: function () {
88 if (t[0] & 1) throw t[1];
89 return t[1];
90 },
91 trys: [],
92 ops: []
93 },
94 f,
95 y,
96 t,
97 g;
98 return g = {
99 next: verb(0),
100 "throw": verb(1),
101 "return": verb(2)
102 }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
103 return this;
104 }), g;
105 function verb(n) {
106 return function (v) {
107 return step([n, v]);
108 };
109 }
110 function step(op) {
111 if (f) throw new TypeError("Generator is already executing.");
112 while (g && (g = 0, op[0] && (_ = 0)), _) try {
113 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
114 if (y = 0, t) op = [op[0] & 2, t.value];
115 switch (op[0]) {
116 case 0:
117 case 1:
118 t = op;
119 break;
120 case 4:
121 _.label++;
122 return {
123 value: op[1],
124 done: false
125 };
126 case 5:
127 _.label++;
128 y = op[1];
129 op = [0];
130 continue;
131 case 7:
132 op = _.ops.pop();
133 _.trys.pop();
134 continue;
135 default:
136 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
137 _ = 0;
138 continue;
139 }
140 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
141 _.label = op[1];
142 break;
143 }
144 if (op[0] === 6 && _.label < t[1]) {
145 _.label = t[1];
146 t = op;
147 break;
148 }
149 if (t && _.label < t[2]) {
150 _.label = t[2];
151 _.ops.push(op);
152 break;
153 }
154 if (t[2]) _.ops.pop();
155 _.trys.pop();
156 continue;
157 }
158 op = body.call(thisArg, _);
159 } catch (e) {
160 op = [6, e];
161 y = 0;
162 } finally {
163 f = t = 0;
164 }
165 if (op[0] & 5) throw op[1];
166 return {
167 value: op[0] ? op[1] : void 0,
168 done: true
169 };
170 }
171}
172function __values(o) {
173 var s = typeof Symbol === "function" && Symbol.iterator,
174 m = s && o[s],
175 i = 0;
176 if (m) return m.call(o);
177 if (o && typeof o.length === "number") return {
178 next: function () {
179 if (o && i >= o.length) o = void 0;
180 return {
181 value: o && o[i++],
182 done: !o
183 };
184 }
185 };
186 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
187}
188function __read(o, n) {
189 var m = typeof Symbol === "function" && o[Symbol.iterator];
190 if (!m) return o;
191 var i = m.call(o),
192 r,
193 ar = [],
194 e;
195 try {
196 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
197 } catch (error) {
198 e = {
199 error: error
200 };
201 } finally {
202 try {
203 if (r && !r.done && (m = i["return"])) m.call(i);
204 } finally {
205 if (e) throw e.error;
206 }
207 }
208 return ar;
209}
210
211/** @deprecated */
212function __spread() {
213 for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
214 return ar;
215}
216typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
217 var e = new Error(message);
218 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
219};
220
221/*
222 * Copyright (c) 2015 NAVER Corp.
223 * egjs projects are licensed under the MIT license
224 */
225/* eslint-disable @typescript-eslint/restrict-template-expressions */
226/**
227 * Error codes of {@link FlickingError}. Below are the conditions where each error code occurs.
228 * @ko {@link FlickingError}의 에러 코드. 아래는 각각의 에러 코드가 발생하는 조건입니다.
229 * @name ERROR_CODE
230 * @constant
231 * @type object
232 * @property {number} WRONG_TYPE Parameter type is wrong<ko>패러미터의 타입이 잘못되었을 경우</ko>
233 * @property {number} ELEMENT_NOT_FOUND Element is not found inside page with the given CSS selector<ko>주어진 CSS selector로 페이지 내에서 해당 엘리먼트를 찾지 못했을 경우</ko>
234 * @property {number} VAL_MUST_NOT_NULL Expected non-null value, but given `null` or `undefined`<ko>값을 기대했으나, `null`이나 `undefined`를 받은 경우</ko>
235 * @property {number} NOT_ATTACHED_TO_FLICKING When Flicking's component is not initialized (i.e. {@link Flicking#init} is not called)<ko>Flicking 내부 컴포넌트가 초기화되지 않은 경우 ({@link Flicking#init}이 호출되지 않은 경우)</ko>
236 * @property {number} WRONG_OPTION One of the options is wrong<ko>옵션들 중 잘못된 값이 있을 때</ko>
237 * @property {number} INDEX_OUT_OF_RANGE When the given index is out of possible range<ko>인덱스가 주어진 범위를 벗어난 경우</ko>
238 * @property {number} POSITION_NOT_REACHABLE When {@link Control#moveToPosition}'s position parameter is out of possible range.<ko>{@link Control#moveToPosition}의 `position` 패러미터가 도달 가능한 범위를 벗어난 경우</ko>
239 * @property {number} TRANSFORM_NOT_SUPPORTED CSS `transform` property is not available(<=IE8) <ko>CSS `transform` 속성을 사용할 수 없는 경우(<=IE8)</ko>
240 * @property {number} STOP_CALLED_BY_USER When the event's `stop()` is called by user.<ko>사용자에 의해 이벤트의 `stop()`이 호출된 경우</ko>
241 * @property {number} ANIMATION_INTERRUPTED When the animation is interrupted by user.<ko>사용자에 의해 애니메이션이 중단된 경우</ko>
242 * @property {number} ANIMATION_ALREADY_PLAYING When the animation is already playing.<ko>현재 애니메이션이 이미 진행중인 경우</ko>
243 * @property {number} NOT_ALLOWED_IN_FRAMEWORK When the non-allowed method is called from frameworks (React, Angular, Vue...)
244 * <ko>프레임워크(React, Angular, Vue ...)에서 사용 불가능한 메소드를 호출했을 경우</ko>
245 * @property {number} NOT_INITIALIZED When the {@link Flicking#init} is not called before but is needed<ko>{@link Flicking#init}의 호출이 필요하나, 아직 호출되지 않았을 경우</ko>
246 * @property {number} NO_ACTIVE When there're no active panel that flicking has selected. This may be due to the absence of any panels<ko>현재 Flicking이 선택한 패널이 없을 경우. 일반적으로 패널이 하나도 없는 경우에 발생할 수 있습니다</ko>
247 * @property {number} NOT_ALLOWED_IN_VIRTUAL When the non-allowed method is called while the virtual option is enabled<ko>virtual 옵션이 활성화된 상태에서 사용 불가능한 메소드가 호출되었을 경우</ko>
248 */
249var CODE = {
250 WRONG_TYPE: 0,
251 ELEMENT_NOT_FOUND: 1,
252 VAL_MUST_NOT_NULL: 2,
253 NOT_ATTACHED_TO_FLICKING: 3,
254 WRONG_OPTION: 4,
255 INDEX_OUT_OF_RANGE: 5,
256 POSITION_NOT_REACHABLE: 6,
257 TRANSFORM_NOT_SUPPORTED: 7,
258 STOP_CALLED_BY_USER: 8,
259 ANIMATION_INTERRUPTED: 9,
260 ANIMATION_ALREADY_PLAYING: 10,
261 NOT_ALLOWED_IN_FRAMEWORK: 11,
262 NOT_INITIALIZED: 12,
263 NO_ACTIVE: 13,
264 NOT_ALLOWED_IN_VIRTUAL: 14
265};
266var MESSAGE = {
267 WRONG_TYPE: function (wrongVal, correctTypes) {
268 return wrongVal + "(" + typeof wrongVal + ") is not a " + correctTypes.map(function (type) {
269 return "\"" + type + "\"";
270 }).join(" or ") + ".";
271 },
272 ELEMENT_NOT_FOUND: function (selector) {
273 return "Element with selector \"" + selector + "\" not found.";
274 },
275 VAL_MUST_NOT_NULL: function (val, name) {
276 return name + " should be provided. Given: " + val;
277 },
278 NOT_ATTACHED_TO_FLICKING: "This module is not attached to the Flicking instance. \"init()\" should be called first.",
279 WRONG_OPTION: function (optionName, val) {
280 return "Option \"" + optionName + "\" is not in correct format, given: " + val;
281 },
282 INDEX_OUT_OF_RANGE: function (val, min, max) {
283 return "Index \"" + val + "\" is out of range: should be between " + min + " and " + max + ".";
284 },
285 POSITION_NOT_REACHABLE: function (position) {
286 return "Position \"" + position + "\" is not reachable.";
287 },
288 TRANSFORM_NOT_SUPPORTED: "Browser does not support CSS transform.",
289 STOP_CALLED_BY_USER: "Event stop() is called by user.",
290 ANIMATION_INTERRUPTED: "Animation is interrupted by user input.",
291 ANIMATION_ALREADY_PLAYING: "Animation is already playing.",
292 NOT_ALLOWED_IN_FRAMEWORK: "This behavior is not allowed in the frameworks like React, Vue, or Angular.",
293 NOT_INITIALIZED: "Flicking is not initialized yet, call init() first.",
294 NO_ACTIVE: "There's no active panel that Flicking has selected. This may be due to the absence of any panels.",
295 NOT_ALLOWED_IN_VIRTUAL: "This behavior is not allowed when the virtual option is enabled"
296};
297
298/*
299 * Copyright (c) 2015 NAVER Corp.
300 * egjs projects are licensed under the MIT license
301 */
302/**
303 * Event type object with event name strings of {@link Flicking}
304 * @ko {@link Flicking}의 이벤트 이름 문자열들을 담은 객체
305 * @type {object}
306 * @property {"holdStart"} HOLD_START holdStart event<ko>holdStart 이벤트</ko>
307 * @property {"holdEnd"} HOLD_END holdEnd event<ko>holdEnd 이벤트</ko>
308 * @property {"moveStart"} MOVE_START moveStart event<ko>moveStart 이벤트</ko>
309 * @property {"move"} MOVE move event<ko>move 이벤트</ko>
310 * @property {"moveEnd"} MOVE_END moveEnd event<ko>moveEnd 이벤트</ko>
311 * @property {"willChange"} WILL_CHANGE willChange event<ko>willChange 이벤트</ko>
312 * @property {"changed"} CHANGED changed event<ko>changed 이벤트</ko>
313 * @property {"willRestore"} WILL_RESTORE willRestore event<ko>willRestore 이벤트</ko>
314 * @property {"restored"} RESTORED restored event<ko>restored 이벤트</ko>
315 * @property {"select"} SELECT select event<ko>select 이벤트</ko>
316 * @property {"needPanel"} NEED_PANEL needPanel event<ko>needPanel 이벤트</ko>
317 * @property {"panelChange"} PANEL_CHANGE panelChange event<ko>panelChange 이벤트</ko>
318 * @example
319 * ```ts
320 * import { EVENTS } from "@egjs/flicking";
321 * EVENTS.MOVE_START; // "moveStart"
322 * ```
323 */
324var EVENTS = {
325 READY: "ready",
326 BEFORE_RESIZE: "beforeResize",
327 AFTER_RESIZE: "afterResize",
328 HOLD_START: "holdStart",
329 HOLD_END: "holdEnd",
330 MOVE_START: "moveStart",
331 MOVE: "move",
332 MOVE_END: "moveEnd",
333 WILL_CHANGE: "willChange",
334 CHANGED: "changed",
335 WILL_RESTORE: "willRestore",
336 RESTORED: "restored",
337 SELECT: "select",
338 NEED_PANEL: "needPanel",
339 VISIBLE_CHANGE: "visibleChange",
340 REACH_EDGE: "reachEdge",
341 PANEL_CHANGE: "panelChange"
342};
343/**
344 * An object with all possible predefined literal string for the {@link Flicking#align align} option
345 * @ko {@link Flicking#align align} 옵션에 사용되는 미리 정의된 리터럴 상수들을 담고 있는 객체
346 * @type {object}
347 * @property {"prev"} PREV left/top align<ko>좌/상 정렬</ko>
348 * @property {"center"} CENTER center align<ko>중앙 정렬</ko>
349 * @property {"next"} NEXT right/bottom align<ko>우/하 정렬</ko>
350 */
351var ALIGN = {
352 PREV: "prev",
353 CENTER: "center",
354 NEXT: "next"
355};
356/**
357 * An object of directions
358 * @ko 방향을 나타내는 값들을 담고 있는 객체
359 * @type {object}
360 * @property {"PREV"} PREV "left" when {@link Flicking#horizontal horizontal} is true, and "top" when {@link Flicking#horizontal horizontal} is false
361 * <ko>{@link Flicking#horizontal horizontal}가 `true`일 경우 왼쪽, {@link Flicking#horizontal horizontal}가 `false`일 경우 위쪽을 의미합니다</ko>
362 * @property {"NEXT"} NEXT "right" when {@link Flicking#horizontal horizontal} is true, and "bottom" when {@link Flicking#horizontal horizontal} is false
363 * <ko>{@link Flicking#horizontal horizontal}가 `true`일 경우 오른쪽, {@link Flicking#horizontal horizontal}가 `false`일 경우 아래쪽을 의미합니다</ko>
364 * @property {null} NONE This value usually means it's the same position<ko>주로 제자리인 경우를 의미합니다</ko>
365 */
366var DIRECTION = {
367 PREV: "PREV",
368 NEXT: "NEXT",
369 NONE: null
370};
371/**
372 * An object with all possible {@link Flicking#moveType moveType}s
373 * @ko Flicking이 제공하는 {@link Flicking#moveType moveType}들을 담고 있는 객체
374 * @type {object}
375 * @property {"snap"} SNAP Flicking's {@link Flicking#moveType moveType} that enables {@link SnapControl} as a Flicking's {@link Flicking#control control}
376 * <ko>Flicking의 {@link Flicking#control control}을 {@link SnapControl}로 설정하게 하는 {@link Flicking#moveType moveType}</ko>
377 * @property {"freeScroll"} FREE_SCROLL Flicking's {@link Flicking#moveType moveType} that enables {@link FreeControl} as a Flicking's {@link Flicking#control control}
378 * <ko>Flicking의 {@link Flicking#control control}을 {@link FreeControl}로 설정하게 하는 {@link Flicking#moveType moveType}</ko>
379 * @property {"strict"} STRICT Flicking's {@link Flicking#moveType moveType} that enables {@link StrictControl} as a Flicking's {@link Flicking#control control}
380 * <ko>Flicking의 {@link Flicking#control control}을 {@link StrictControl}로 설정하게 하는 {@link Flicking#moveType moveType}</ko>
381 */
382var MOVE_TYPE = {
383 SNAP: "snap",
384 FREE_SCROLL: "freeScroll",
385 STRICT: "strict"
386};
387var CLASS = {
388 VERTICAL: "vertical",
389 HIDDEN: "flicking-hidden",
390 DEFAULT_VIRTUAL: "flicking-panel"
391};
392/**
393 * An object with all possible {@link Flicking#circularFallback circularFallback}s
394 * @ko Flicking의 {@link Flicking#circularFallback circularFallback}에 설정 가능한 값들을 담고 있는 객체
395 * @type {object}
396 * @property {string} LINEAR "linear"
397 * @property {string} BOUND "bound"
398 */
399var CIRCULAR_FALLBACK = {
400 LINEAR: "linear",
401 BOUND: "bound"
402};
403/**
404 * An object for identifying {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
405 * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성을 구분하기 위한 객체
406 * @type {object}
407 * @property {string} LTR "ltr"
408 * @property {string} RTL "rtl"
409 */
410var ORDER = {
411 LTR: "ltr",
412 RTL: "rtl"
413};
414
415// eslint-disable-next-line @typescript-eslint/ban-types
416var merge = function (target) {
417 var sources = [];
418 for (var _i = 1; _i < arguments.length; _i++) {
419 sources[_i - 1] = arguments[_i];
420 }
421 sources.forEach(function (source) {
422 Object.keys(source).forEach(function (key) {
423 target[key] = source[key];
424 });
425 });
426 return target;
427};
428var getElement = function (el, parent) {
429 var targetEl = null;
430 if (isString(el)) {
431 var parentEl = parent ? parent : document;
432 var queryResult = parentEl.querySelector(el);
433 if (!queryResult) {
434 throw new FlickingError(MESSAGE.ELEMENT_NOT_FOUND(el), CODE.ELEMENT_NOT_FOUND);
435 }
436 targetEl = queryResult;
437 } else if (el && el.nodeType === Node.ELEMENT_NODE) {
438 targetEl = el;
439 }
440 if (!targetEl) {
441 throw new FlickingError(MESSAGE.WRONG_TYPE(el, ["HTMLElement", "string"]), CODE.WRONG_TYPE);
442 }
443 return targetEl;
444};
445var checkExistence = function (value, nameOnErrMsg) {
446 if (value == null) {
447 throw new FlickingError(MESSAGE.VAL_MUST_NOT_NULL(value, nameOnErrMsg), CODE.VAL_MUST_NOT_NULL);
448 }
449};
450var clamp = function (x, min, max) {
451 return Math.max(Math.min(x, max), min);
452};
453var getFlickingAttached = function (val) {
454 if (!val) {
455 throw new FlickingError(MESSAGE.NOT_ATTACHED_TO_FLICKING, CODE.NOT_ATTACHED_TO_FLICKING);
456 }
457 return val;
458};
459var toArray = function (iterable) {
460 return [].slice.call(iterable);
461};
462var parseAlign$1 = function (align, size) {
463 var alignPoint;
464 if (isString(align)) {
465 switch (align) {
466 case ALIGN.PREV:
467 alignPoint = 0;
468 break;
469 case ALIGN.CENTER:
470 alignPoint = 0.5 * size;
471 break;
472 case ALIGN.NEXT:
473 alignPoint = size;
474 break;
475 default:
476 alignPoint = parseArithmeticSize(align, size);
477 if (alignPoint == null) {
478 throw new FlickingError(MESSAGE.WRONG_OPTION("align", align), CODE.WRONG_OPTION);
479 }
480 }
481 } else {
482 alignPoint = align;
483 }
484 return alignPoint;
485};
486var parseBounce = function (bounce, size) {
487 var parsedBounce;
488 if (Array.isArray(bounce)) {
489 parsedBounce = bounce.map(function (val) {
490 return parseArithmeticSize(val, size);
491 });
492 } else {
493 var parsedVal = parseArithmeticSize(bounce, size);
494 parsedBounce = [parsedVal, parsedVal];
495 }
496 return parsedBounce.map(function (val) {
497 if (val == null) {
498 throw new FlickingError(MESSAGE.WRONG_OPTION("bounce", bounce), CODE.WRONG_OPTION);
499 }
500 return val;
501 });
502};
503var parseArithmeticSize = function (cssValue, base) {
504 var parsed = parseArithmeticExpression(cssValue);
505 if (parsed == null) return null;
506 return parsed.percentage * base + parsed.absolute;
507};
508var parseArithmeticExpression = function (cssValue) {
509 var cssRegex = /(?:(\+|\-)\s*)?(\d+(?:\.\d+)?(%|px)?)/g;
510 if (typeof cssValue === "number") {
511 return {
512 percentage: 0,
513 absolute: cssValue
514 };
515 }
516 var parsed = {
517 percentage: 0,
518 absolute: 0
519 };
520 var idx = 0;
521 var matchResult = cssRegex.exec(cssValue);
522 while (matchResult != null) {
523 var sign = matchResult[1];
524 var value = matchResult[2];
525 var unit = matchResult[3];
526 var parsedValue = parseFloat(value);
527 if (idx <= 0) {
528 sign = sign || "+";
529 }
530 // Return default value for values not in good form
531 if (!sign) {
532 return null;
533 }
534 var signMultiplier = sign === "+" ? 1 : -1;
535 if (unit === "%") {
536 parsed.percentage += signMultiplier * (parsedValue / 100);
537 } else {
538 parsed.absolute += signMultiplier * parsedValue;
539 }
540 // Match next occurrence
541 ++idx;
542 matchResult = cssRegex.exec(cssValue);
543 }
544 // None-matched
545 if (idx === 0) {
546 return null;
547 }
548 return parsed;
549};
550var parseCSSSizeValue = function (val) {
551 return isString(val) ? val : val + "px";
552};
553var parsePanelAlign = function (align) {
554 return typeof align === "object" ? align.panel : align;
555};
556var getDirection = function (start, end) {
557 if (start === end) return DIRECTION.NONE;
558 return start < end ? DIRECTION.NEXT : DIRECTION.PREV;
559};
560var parseElement = function (element) {
561 if (!Array.isArray(element)) {
562 element = [element];
563 }
564 var elements = [];
565 element.forEach(function (el) {
566 if (isString(el)) {
567 var tempDiv = document.createElement("div");
568 tempDiv.innerHTML = el;
569 elements.push.apply(elements, __spread(toArray(tempDiv.children)));
570 while (tempDiv.firstChild) {
571 tempDiv.removeChild(tempDiv.firstChild);
572 }
573 } else if (el && el.nodeType === Node.ELEMENT_NODE) {
574 elements.push(el);
575 } else {
576 throw new FlickingError(MESSAGE.WRONG_TYPE(el, ["HTMLElement", "string"]), CODE.WRONG_TYPE);
577 }
578 });
579 return elements;
580};
581var getMinusCompensatedIndex = function (idx, max) {
582 return idx < 0 ? clamp(idx + max, 0, max) : clamp(idx, 0, max);
583};
584var includes = function (array, target) {
585 var e_1, _a;
586 try {
587 for (var array_1 = __values(array), array_1_1 = array_1.next(); !array_1_1.done; array_1_1 = array_1.next()) {
588 var val = array_1_1.value;
589 if (val === target) return true;
590 }
591 } catch (e_1_1) {
592 e_1 = {
593 error: e_1_1
594 };
595 } finally {
596 try {
597 if (array_1_1 && !array_1_1.done && (_a = array_1.return)) _a.call(array_1);
598 } finally {
599 if (e_1) throw e_1.error;
600 }
601 }
602 return false;
603};
604var isString = function (val) {
605 return typeof val === "string";
606};
607var circulatePosition = function (pos, min, max) {
608 var size = max - min;
609 if (pos < min) {
610 var offset = (min - pos) % size;
611 pos = max - offset;
612 } else if (pos > max) {
613 var offset = (pos - max) % size;
614 pos = min + offset;
615 }
616 return pos;
617};
618var find = function (array, checker) {
619 var e_2, _a;
620 try {
621 for (var array_2 = __values(array), array_2_1 = array_2.next(); !array_2_1.done; array_2_1 = array_2.next()) {
622 var val = array_2_1.value;
623 if (checker(val)) {
624 return val;
625 }
626 }
627 } catch (e_2_1) {
628 e_2 = {
629 error: e_2_1
630 };
631 } finally {
632 try {
633 if (array_2_1 && !array_2_1.done && (_a = array_2.return)) _a.call(array_2);
634 } finally {
635 if (e_2) throw e_2.error;
636 }
637 }
638 return null;
639};
640var findRight = function (array, checker) {
641 for (var idx = array.length - 1; idx >= 0; idx--) {
642 var val = array[idx];
643 if (checker(val)) {
644 return val;
645 }
646 }
647 return null;
648};
649var findIndex = function (array, checker) {
650 for (var idx = 0; idx < array.length; idx++) {
651 if (checker(array[idx])) {
652 return idx;
653 }
654 }
655 return -1;
656};
657var getProgress = function (pos, prev, next) {
658 return (pos - prev) / (next - prev);
659};
660// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
661var getStyle = function (el) {
662 return window.getComputedStyle(el) || el.currentStyle;
663};
664var setSize = function (el, _a) {
665 var width = _a.width,
666 height = _a.height;
667 if (width != null) {
668 if (isString(width)) {
669 el.style.width = width;
670 } else {
671 el.style.width = width + "px";
672 }
673 }
674 if (height != null) {
675 if (isString(height)) {
676 el.style.height = height;
677 } else {
678 el.style.height = height + "px";
679 }
680 }
681};
682var isBetween = function (val, min, max) {
683 return val >= min && val <= max;
684};
685var circulateIndex = function (index, max) {
686 if (index >= max) {
687 return index % max;
688 } else if (index < 0) {
689 return getMinusCompensatedIndex((index + 1) % max - 1, max);
690 } else {
691 return index;
692 }
693};
694var range = function (end) {
695 var arr = new Array(end);
696 for (var i = 0; i < end; i++) {
697 arr[i] = i;
698 }
699 return arr;
700};
701var getElementSize = function (_a) {
702 var el = _a.el,
703 horizontal = _a.horizontal,
704 useFractionalSize = _a.useFractionalSize,
705 useOffset = _a.useOffset,
706 style = _a.style;
707 var size = 0;
708 if (useFractionalSize) {
709 var baseSize = parseFloat(horizontal ? style.width : style.height) || 0;
710 var isBorderBoxSizing = style.boxSizing === "border-box";
711 var border = horizontal ? parseFloat(style.borderLeftWidth || "0") + parseFloat(style.borderRightWidth || "0") : parseFloat(style.borderTopWidth || "0") + parseFloat(style.borderBottomWidth || "0");
712 if (isBorderBoxSizing) {
713 size = useOffset ? baseSize : baseSize - border;
714 } else {
715 var padding = horizontal ? parseFloat(style.paddingLeft || "0") + parseFloat(style.paddingRight || "0") : parseFloat(style.paddingTop || "0") + parseFloat(style.paddingBottom || "0");
716 size = useOffset ? baseSize + padding + border : baseSize + padding;
717 }
718 } else {
719 var sizeStr = horizontal ? "Width" : "Height";
720 size = useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
721 }
722 return Math.max(size, 0);
723};
724var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
725 obj.__proto__ = proto;
726 return obj;
727};
728
729/*
730 * Copyright (c) 2015 NAVER Corp.
731 * egjs projects are licensed under the MIT license
732 */
733/**
734 * Special type of known error that {@link Flicking} throws.
735 * @ko Flicking 내부에서 알려진 오류 발생시 throw되는 에러
736 * @property {number} code Error code<ko>에러 코드</ko>
737 * @property {string} message Error message<ko>에러 메시지</ko>
738 * @see {@link ERROR_CODE ERROR_CODE}
739 * @example
740 * ```ts
741 * import Flicking, { FlickingError, ERROR_CODES } from "@egjs/flicking";
742 * try {
743 * const flicking = new Flicking(".flicking-viewport")
744 * } catch (e) {
745 * if (e instanceof FlickingError && e.code === ERROR_CODES.ELEMENT_NOT_FOUND) {
746 * console.error("Element not found")
747 * }
748 * }
749 * ```
750 */
751var FlickingError = /*#__PURE__*/function (_super) {
752 __extends(FlickingError, _super);
753 /**
754 * @param message Error message<ko>에러 메시지</ko>
755 * @param code Error code<ko>에러 코드</ko>
756 */
757 function FlickingError(message, code) {
758 var _this = _super.call(this, message) || this;
759 setPrototypeOf(_this, FlickingError.prototype);
760 _this.name = "FlickingError";
761 _this.code = code;
762 return _this;
763 }
764 return FlickingError;
765}(Error);
766
767/**
768 * A component that manages viewport size
769 * @ko 뷰포트 크기 정보를 담당하는 컴포넌트
770 */
771var Viewport = /*#__PURE__*/function () {
772 /**
773 * @param el A viewport element<ko>뷰포트 엘리먼트</ko>
774 */
775 function Viewport(flicking, el) {
776 this._flicking = flicking;
777 this._el = el;
778 this._width = 0;
779 this._height = 0;
780 this._padding = {
781 left: 0,
782 right: 0,
783 top: 0,
784 bottom: 0
785 };
786 this._isBorderBoxSizing = false;
787 }
788 var __proto = Viewport.prototype;
789 Object.defineProperty(__proto, "element", {
790 /**
791 * A viewport(root) element
792 * @ko 뷰포트(root) 엘리먼트
793 * @type {HTMLElement}
794 * @readonly
795 */
796 get: function () {
797 return this._el;
798 },
799 enumerable: false,
800 configurable: true
801 });
802 Object.defineProperty(__proto, "width", {
803 /**
804 * Viewport width, without paddings
805 * @ko 뷰포트 너비
806 * @type {number}
807 * @readonly
808 */
809 get: function () {
810 return this._width - this._padding.left - this._padding.right;
811 },
812 enumerable: false,
813 configurable: true
814 });
815 Object.defineProperty(__proto, "height", {
816 /**
817 * Viewport height, without paddings
818 * @ko 뷰포트 높이
819 * @type {number}
820 * @readonly
821 */
822 get: function () {
823 return this._height - this._padding.top - this._padding.bottom;
824 },
825 enumerable: false,
826 configurable: true
827 });
828 Object.defineProperty(__proto, "padding", {
829 /**
830 * Viewport paddings
831 * @ko 뷰포트 CSS padding 값
832 * @type {object}
833 * @property {number} left CSS `padding-left`
834 * @property {number} right CSS `padding-right`
835 * @property {number} top CSS `padding-top`
836 * @property {number} bottom CSS `padding-bottom`
837 * @readonly
838 */
839 get: function () {
840 return this._padding;
841 },
842 enumerable: false,
843 configurable: true
844 });
845 /**
846 * Change viewport's size.
847 * This will change the actual size of `.flicking-viewport` element by changing its CSS width/height property
848 * @ko 뷰포트 크기를 변경합니다.
849 * `.flicking-viewport` 엘리먼트에 해당 크기의 CSS width/height를 적용합니다
850 * @param {object} [size] New viewport size<ko>새 뷰포트 크기</ko>
851 * @param {number|string} [size.width] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
852 * @param {number|string} [size.height] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
853 */
854 __proto.setSize = function (_a) {
855 var width = _a.width,
856 height = _a.height;
857 var el = this._el;
858 var padding = this._padding;
859 var isBorderBoxSizing = this._isBorderBoxSizing;
860 if (width != null) {
861 if (isString(width)) {
862 el.style.width = width;
863 } else {
864 var newWidth = isBorderBoxSizing ? width + padding.left + padding.right : width;
865 el.style.width = newWidth + "px";
866 }
867 }
868 if (height != null) {
869 if (isString(height)) {
870 el.style.height = height;
871 } else {
872 var newHeight = isBorderBoxSizing ? height + padding.top + padding.bottom : height;
873 el.style.height = newHeight + "px";
874 }
875 }
876 this.resize();
877 };
878 /**
879 * Update width/height to the current viewport element's size
880 * @ko 현재 뷰포트 엘리먼트의 크기로 너비/높이를 업데이트합니다
881 */
882 __proto.resize = function () {
883 var el = this._el;
884 var elStyle = getStyle(el);
885 var useFractionalSize = this._flicking.useFractionalSize;
886 this._width = getElementSize({
887 el: el,
888 horizontal: true,
889 useFractionalSize: useFractionalSize,
890 useOffset: false,
891 style: elStyle
892 });
893 this._height = getElementSize({
894 el: el,
895 horizontal: false,
896 useFractionalSize: useFractionalSize,
897 useOffset: false,
898 style: elStyle
899 });
900 this._padding = {
901 left: elStyle.paddingLeft ? parseFloat(elStyle.paddingLeft) : 0,
902 right: elStyle.paddingRight ? parseFloat(elStyle.paddingRight) : 0,
903 top: elStyle.paddingTop ? parseFloat(elStyle.paddingTop) : 0,
904 bottom: elStyle.paddingBottom ? parseFloat(elStyle.paddingBottom) : 0
905 };
906 this._isBorderBoxSizing = elStyle.boxSizing === "border-box";
907 };
908 return Viewport;
909}();
910
911var AutoResizer = /*#__PURE__*/function () {
912 function AutoResizer(flicking) {
913 var _this = this;
914 this._onResize = function () {
915 var flicking = _this._flicking;
916 var resizeDebounce = flicking.resizeDebounce;
917 var maxResizeDebounce = flicking.maxResizeDebounce;
918 if (resizeDebounce <= 0) {
919 void flicking.resize();
920 } else {
921 if (_this._maxResizeDebounceTimer <= 0) {
922 if (maxResizeDebounce > 0 && maxResizeDebounce >= resizeDebounce) {
923 _this._maxResizeDebounceTimer = window.setTimeout(_this._doScheduledResize, maxResizeDebounce);
924 }
925 }
926 if (_this._resizeTimer > 0) {
927 clearTimeout(_this._resizeTimer);
928 _this._resizeTimer = 0;
929 }
930 _this._resizeTimer = window.setTimeout(_this._doScheduledResize, resizeDebounce);
931 }
932 };
933 this._doScheduledResize = function () {
934 clearTimeout(_this._resizeTimer);
935 clearTimeout(_this._maxResizeDebounceTimer);
936 _this._maxResizeDebounceTimer = -1;
937 _this._resizeTimer = -1;
938 void _this._flicking.resize();
939 };
940 // eslint-disable-next-line @typescript-eslint/member-ordering
941 this._skipFirstResize = function () {
942 var isFirstResize = true;
943 return function () {
944 if (isFirstResize) {
945 isFirstResize = false;
946 return;
947 }
948 _this._onResize();
949 };
950 }();
951 this._flicking = flicking;
952 this._enabled = false;
953 this._resizeObserver = null;
954 this._resizeTimer = -1;
955 this._maxResizeDebounceTimer = -1;
956 }
957 var __proto = AutoResizer.prototype;
958 Object.defineProperty(__proto, "enabled", {
959 get: function () {
960 return this._enabled;
961 },
962 enumerable: false,
963 configurable: true
964 });
965 __proto.enable = function () {
966 var flicking = this._flicking;
967 var viewport = flicking.viewport;
968 if (this._enabled) {
969 this.disable();
970 }
971 if (flicking.useResizeObserver && !!window.ResizeObserver) {
972 var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
973 var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
974 resizeObserver.observe(flicking.viewport.element);
975 this._resizeObserver = resizeObserver;
976 } else {
977 window.addEventListener("resize", this._onResize);
978 }
979 this._enabled = true;
980 return this;
981 };
982 __proto.disable = function () {
983 if (!this._enabled) return this;
984 var resizeObserver = this._resizeObserver;
985 if (resizeObserver) {
986 resizeObserver.disconnect();
987 this._resizeObserver = null;
988 } else {
989 window.removeEventListener("resize", this._onResize);
990 }
991 this._enabled = false;
992 return this;
993 };
994 return AutoResizer;
995}();
996
997/**
998 * @internal
999 */
1000var VanillaElementProvider = /*#__PURE__*/function () {
1001 function VanillaElementProvider(element) {
1002 this._element = element;
1003 this._rendered = true;
1004 }
1005 var __proto = VanillaElementProvider.prototype;
1006 Object.defineProperty(__proto, "element", {
1007 get: function () {
1008 return this._element;
1009 },
1010 enumerable: false,
1011 configurable: true
1012 });
1013 Object.defineProperty(__proto, "rendered", {
1014 get: function () {
1015 return this._rendered;
1016 },
1017 enumerable: false,
1018 configurable: true
1019 });
1020 __proto.show = function (flicking) {
1021 var el = this.element;
1022 var cameraEl = flicking.camera.element;
1023 if (el.parentElement !== cameraEl) {
1024 cameraEl.appendChild(el);
1025 this._rendered = true;
1026 }
1027 };
1028 __proto.hide = function (flicking) {
1029 var el = this.element;
1030 var cameraEl = flicking.camera.element;
1031 if (el.parentElement === cameraEl) {
1032 cameraEl.removeChild(el);
1033 this._rendered = false;
1034 }
1035 };
1036 return VanillaElementProvider;
1037}();
1038
1039/*
1040 * Copyright (c) 2015 NAVER Corp.
1041 * egjs projects are licensed under the MIT license
1042 */
1043/**
1044 * @internal
1045 */
1046var VirtualElementProvider = /*#__PURE__*/function () {
1047 function VirtualElementProvider(flicking) {
1048 this._flicking = flicking;
1049 }
1050 var __proto = VirtualElementProvider.prototype;
1051 Object.defineProperty(__proto, "element", {
1052 get: function () {
1053 return this._virtualElement.nativeElement;
1054 },
1055 enumerable: false,
1056 configurable: true
1057 });
1058 Object.defineProperty(__proto, "rendered", {
1059 get: function () {
1060 return this._virtualElement.visible;
1061 },
1062 enumerable: false,
1063 configurable: true
1064 });
1065 Object.defineProperty(__proto, "_virtualElement", {
1066 get: function () {
1067 var flicking = this._flicking;
1068 var elIndex = this._panel.elementIndex;
1069 var virtualElements = flicking.virtual.elements;
1070 return virtualElements[elIndex];
1071 },
1072 enumerable: false,
1073 configurable: true
1074 });
1075 __proto.init = function (panel) {
1076 this._panel = panel;
1077 };
1078 __proto.show = function () {
1079 // DO_NOTHING
1080 // Actual element visibility is controlled by VirtualManager
1081 };
1082 __proto.hide = function () {
1083 // DO_NOTHING
1084 // Actual element visibility is controlled by VirtualManager
1085 };
1086 return VirtualElementProvider;
1087}();
1088
1089/**
1090 * A manager class to add / remove virtual panels
1091 */
1092var VirtualManager = /*#__PURE__*/function () {
1093 function VirtualManager(flicking, options) {
1094 var _a, _b, _c, _d;
1095 this._flicking = flicking;
1096 this._renderPanel = (_a = options === null || options === void 0 ? void 0 : options.renderPanel) !== null && _a !== void 0 ? _a : function () {
1097 return "";
1098 };
1099 this._initialPanelCount = (_b = options === null || options === void 0 ? void 0 : options.initialPanelCount) !== null && _b !== void 0 ? _b : -1;
1100 this._cache = (_c = options === null || options === void 0 ? void 0 : options.cache) !== null && _c !== void 0 ? _c : false;
1101 this._panelClass = (_d = options === null || options === void 0 ? void 0 : options.panelClass) !== null && _d !== void 0 ? _d : CLASS.DEFAULT_VIRTUAL;
1102 this._elements = [];
1103 }
1104 var __proto = VirtualManager.prototype;
1105 Object.defineProperty(__proto, "elements", {
1106 get: function () {
1107 return this._elements;
1108 },
1109 enumerable: false,
1110 configurable: true
1111 });
1112 Object.defineProperty(__proto, "renderPanel", {
1113 // Options
1114 /**
1115 * A rendering function for the panel element's innerHTML
1116 * @ko 패널 엘리먼트의 innerHTML을 렌더링하는 함수
1117 * @type {function}
1118 * @param {VirtualPanel} panel Instance of the panel<ko>패널 인스턴스</ko>
1119 * @param {number} index Index of the panel<ko>패널 인덱스</ko>
1120 * @default "() => {}"
1121 */
1122 get: function () {
1123 return this._renderPanel;
1124 },
1125 set: function (val) {
1126 this._renderPanel = val;
1127 this._flicking.renderer.panels.forEach(function (panel) {
1128 return panel.uncacheRenderResult();
1129 });
1130 },
1131 enumerable: false,
1132 configurable: true
1133 });
1134 Object.defineProperty(__proto, "initialPanelCount", {
1135 /**
1136 * Initial panel count to render
1137 * @ko 최초로 렌더링할 패널의 개수
1138 * @readonly
1139 * @type {number}
1140 * @default -1
1141 */
1142 get: function () {
1143 return this._initialPanelCount;
1144 },
1145 enumerable: false,
1146 configurable: true
1147 });
1148 Object.defineProperty(__proto, "cache", {
1149 /**
1150 * Whether to cache rendered panel's innerHTML
1151 * @ko 렌더링된 패널의 innerHTML 정보를 캐시할지 여부
1152 * @type {boolean}
1153 * @default false
1154 */
1155 get: function () {
1156 return this._cache;
1157 },
1158 set: function (val) {
1159 this._cache = val;
1160 },
1161 enumerable: false,
1162 configurable: true
1163 });
1164 Object.defineProperty(__proto, "panelClass", {
1165 /**
1166 * The class name that will be applied to rendered panel elements
1167 * @ko 렌더링되는 패널 엘리먼트에 적용될 클래스 이름
1168 * @type {string}
1169 * @default "flicking-panel"
1170 */
1171 get: function () {
1172 return this._panelClass;
1173 },
1174 set: function (val) {
1175 this._panelClass = val;
1176 },
1177 enumerable: false,
1178 configurable: true
1179 });
1180 __proto.init = function () {
1181 var flicking = this._flicking;
1182 if (!flicking.virtualEnabled) return;
1183 if (!flicking.externalRenderer && !flicking.renderExternal) {
1184 this._initVirtualElements();
1185 }
1186 var virtualElements = flicking.camera.children;
1187 this._elements = virtualElements.map(function (el) {
1188 return {
1189 nativeElement: el,
1190 visible: true
1191 };
1192 });
1193 };
1194 __proto.show = function (index) {
1195 var el = this._elements[index];
1196 var nativeEl = el.nativeElement;
1197 el.visible = true;
1198 if (nativeEl.style.display) {
1199 nativeEl.style.display = "";
1200 }
1201 };
1202 __proto.hide = function (index) {
1203 var el = this._elements[index];
1204 var nativeEl = el.nativeElement;
1205 el.visible = false;
1206 nativeEl.style.display = "none";
1207 };
1208 /**
1209 * Add new virtual panels at the end of the list
1210 * @ko 새로운 가상 패널들을 리스트의 끝에 추가합니다
1211 * @param {number} count The number of panels to add<ko>추가할 패널의 개수</ko>
1212 * @returns {Array<VirtualPanel>} The new panels added<ko>새롭게 추가된 패널들</ko>
1213 */
1214 __proto.append = function (count) {
1215 if (count === void 0) {
1216 count = 1;
1217 }
1218 var flicking = this._flicking;
1219 return this.insert(flicking.panels.length, count);
1220 };
1221 /**
1222 * Add new virtual panels at the start of the list
1223 * @ko 새로운 가상 패널들을 리스트의 시작에 추가합니다
1224 * @param {number} count The number of panels to add<ko>추가할 패널의 개수</ko>
1225 * @returns {Array<VirtualPanel>} The new panels added<ko>새롭게 추가된 패널들</ko>
1226 */
1227 __proto.prepend = function (count) {
1228 if (count === void 0) {
1229 count = 1;
1230 }
1231 return this.insert(0, count);
1232 };
1233 /**
1234 * Add new virtual panels at the given index
1235 * @ko 새로운 가상 패널들을 주어진 인덱스에 추가합니다
1236 * @param {number} count The number of panels to add<ko>추가할 패널의 개수</ko>
1237 * @returns {Array<VirtualPanel>} The new panels added<ko>새롭게 추가된 패널들</ko>
1238 */
1239 __proto.insert = function (index, count) {
1240 if (count === void 0) {
1241 count = 1;
1242 }
1243 if (count <= 0) return [];
1244 var flicking = this._flicking;
1245 return flicking.renderer.batchInsert({
1246 index: index,
1247 elements: range(count),
1248 hasDOMInElements: false
1249 });
1250 };
1251 /**
1252 * Remove panels at the given index
1253 * @ko 주어진 인덱스에서 패널들을 삭제합니다
1254 * @param {number} count The number of panels to remove<ko>삭제할 패널의 개수</ko>
1255 * @returns {Array<VirtualPanel>} The panels removed<ko>삭제된 패널들</ko>
1256 */
1257 __proto.remove = function (index, count) {
1258 if (count <= 0) return [];
1259 var flicking = this._flicking;
1260 return flicking.renderer.batchRemove({
1261 index: index,
1262 deleteCount: count,
1263 hasDOMInElements: false
1264 });
1265 };
1266 __proto._initVirtualElements = function () {
1267 var _this = this;
1268 var flicking = this._flicking;
1269 var cameraElement = flicking.camera.element;
1270 var panelsPerView = flicking.panelsPerView;
1271 var fragment = document.createDocumentFragment();
1272 var newElements = range(panelsPerView + 1).map(function (idx) {
1273 var panelEl = document.createElement("div");
1274 panelEl.className = _this._panelClass;
1275 panelEl.dataset.elementIndex = idx.toString();
1276 return panelEl;
1277 });
1278 newElements.forEach(function (el) {
1279 fragment.appendChild(el);
1280 });
1281 cameraElement.appendChild(fragment);
1282 };
1283 return VirtualManager;
1284}();
1285
1286/**
1287 * All possible @egjs/axes event keys
1288 * @internal
1289 */
1290var EVENT = {
1291 HOLD: "hold",
1292 CHANGE: "change",
1293 RELEASE: "release",
1294 ANIMATION_END: "animationEnd",
1295 FINISH: "finish"
1296};
1297/**
1298 * An Axis key that Flicking uses
1299 * @internal
1300 */
1301var POSITION_KEY = "flick";
1302
1303var STATE_TYPE;
1304(function (STATE_TYPE) {
1305 STATE_TYPE[STATE_TYPE["IDLE"] = 0] = "IDLE";
1306 STATE_TYPE[STATE_TYPE["HOLDING"] = 1] = "HOLDING";
1307 STATE_TYPE[STATE_TYPE["DRAGGING"] = 2] = "DRAGGING";
1308 STATE_TYPE[STATE_TYPE["ANIMATING"] = 3] = "ANIMATING";
1309 STATE_TYPE[STATE_TYPE["DISABLED"] = 4] = "DISABLED";
1310})(STATE_TYPE || (STATE_TYPE = {}));
1311/**
1312 * A component that shows the current status of the user input or the animation
1313 * @ko 현재 사용자 입력 또는 애니메이션 상태를 나타내는 컴포넌트
1314 * @internal
1315 */
1316var State = /*#__PURE__*/function () {
1317 function State() {
1318 this._delta = 0;
1319 this._targetPanel = null;
1320 }
1321 var __proto = State.prototype;
1322 Object.defineProperty(__proto, "delta", {
1323 /**
1324 * A sum of delta values of change events from the last hold event of Axes
1325 * @ko 이전 hold이벤트부터 change에 의해 발생한 이동 delta값의 합산
1326 * @type {number}
1327 * @readonly
1328 */
1329 get: function () {
1330 return this._delta;
1331 },
1332 enumerable: false,
1333 configurable: true
1334 });
1335 Object.defineProperty(__proto, "targetPanel", {
1336 /**
1337 * A panel to set as {@link Control#activePanel} after the animation is finished
1338 * @ko 애니메이션 종료시 {@link Control#activePanel}로 설정할 패널
1339 * @type {number}
1340 * @readonly
1341 */
1342 get: function () {
1343 return this._targetPanel;
1344 },
1345 set: function (val) {
1346 this._targetPanel = val;
1347 },
1348 enumerable: false,
1349 configurable: true
1350 });
1351 /**
1352 * An callback which is called when state has changed to this state
1353 * @ko 현재 상태로 돌입했을때 호출되는 콜백 함수
1354 * @param {State} prevState An previous state<ko>이전 상태값</ko>
1355 * @return {void}
1356 */
1357 __proto.onEnter = function (prevState) {
1358 this._delta = prevState._delta;
1359 this._targetPanel = prevState._targetPanel;
1360 };
1361 /**
1362 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} event
1363 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} 이벤트 핸들러
1364 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
1365 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
1366 * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} event of Axes
1367 * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} 이벤트</ko>
1368 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
1369 * @return {void}
1370 */
1371 __proto.onHold = function (ctx) {
1372 // DO NOTHING
1373 };
1374 /**
1375 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} event
1376 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} 이벤트 핸들러
1377 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
1378 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
1379 * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} event of Axes
1380 * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} 이벤트</ko>
1381 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
1382 * @return {void}
1383 */
1384 __proto.onChange = function (ctx) {
1385 // DO NOTHING
1386 };
1387 /**
1388 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event
1389 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트 핸들러
1390 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
1391 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
1392 * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of Axes
1393 * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
1394 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
1395 * @return {void}
1396 */
1397 __proto.onRelease = function (ctx) {
1398 // DO NOTHING
1399 };
1400 /**
1401 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} event
1402 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} 이벤트 핸들러
1403 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
1404 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
1405 * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} event of Axes
1406 * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} 이벤트</ko>
1407 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
1408 * @return {void}
1409 */
1410 __proto.onAnimationEnd = function (ctx) {
1411 // DO NOTHING
1412 };
1413 /**
1414 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} event
1415 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} 이벤트 핸들러
1416 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
1417 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
1418 * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} event of Axes<ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} 이벤트</ko>
1419 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
1420 * @return {void}
1421 */
1422 __proto.onFinish = function (ctx) {
1423 // DO NOTHING
1424 };
1425 __proto._moveToChangedPosition = function (ctx) {
1426 var flicking = ctx.flicking,
1427 axesEvent = ctx.axesEvent,
1428 transitTo = ctx.transitTo;
1429 var delta = axesEvent.delta[POSITION_KEY];
1430 if (!delta) {
1431 return;
1432 }
1433 this._delta += delta;
1434 var camera = flicking.camera;
1435 var prevPosition = camera.position;
1436 var position = axesEvent.pos[POSITION_KEY];
1437 var newPosition = flicking.circularEnabled ? circulatePosition(position, camera.range.min, camera.range.max) : position;
1438 camera.lookAt(newPosition);
1439 var moveEvent = new ComponentEvent(EVENTS.MOVE, {
1440 isTrusted: axesEvent.isTrusted,
1441 holding: this.holding,
1442 direction: getDirection(0, axesEvent.delta[POSITION_KEY]),
1443 axesEvent: axesEvent
1444 });
1445 flicking.trigger(moveEvent);
1446 if (moveEvent.isCanceled()) {
1447 // Return to previous position
1448 camera.lookAt(prevPosition);
1449 transitTo(STATE_TYPE.DISABLED);
1450 }
1451 };
1452 return State;
1453}();
1454
1455/**
1456 * A default state when there's no user input and no animation's playing
1457 * @ko 사용자의 입력이 없고, 애니메이션이 동작하고있지 않은 기본 상태
1458 * @internal
1459 */
1460var IdleState = /*#__PURE__*/function (_super) {
1461 __extends(IdleState, _super);
1462 function IdleState() {
1463 var _this = _super !== null && _super.apply(this, arguments) || this;
1464 /**
1465 * Whether user is clicking or touching
1466 * @ko 현재 사용자가 클릭/터치중인지 여부
1467 * @type {false}
1468 * @readonly
1469 */
1470 _this.holding = false;
1471 /**
1472 * Whether Flicking's animating
1473 * @ko 현재 애니메이션 동작 여부
1474 * @type {false}
1475 * @readonly
1476 */
1477 _this.animating = false;
1478 return _this;
1479 }
1480 var __proto = IdleState.prototype;
1481 __proto.onEnter = function () {
1482 this._delta = 0;
1483 this._targetPanel = null;
1484 };
1485 __proto.onHold = function (ctx) {
1486 // Shouldn't do any action until any panels on flicking area
1487 var flicking = ctx.flicking,
1488 axesEvent = ctx.axesEvent,
1489 transitTo = ctx.transitTo;
1490 if (flicking.renderer.panelCount <= 0) {
1491 transitTo(STATE_TYPE.DISABLED);
1492 return;
1493 }
1494 var holdStartEvent = new ComponentEvent(EVENTS.HOLD_START, {
1495 axesEvent: axesEvent
1496 });
1497 flicking.trigger(holdStartEvent);
1498 if (holdStartEvent.isCanceled()) {
1499 transitTo(STATE_TYPE.DISABLED);
1500 } else {
1501 transitTo(STATE_TYPE.HOLDING);
1502 }
1503 };
1504 // By methods call
1505 __proto.onChange = function (ctx) {
1506 var flicking = ctx.flicking,
1507 axesEvent = ctx.axesEvent,
1508 transitTo = ctx.transitTo;
1509 var controller = flicking.control.controller;
1510 var animatingContext = controller.animatingContext;
1511 var moveStartEvent = new ComponentEvent(EVENTS.MOVE_START, {
1512 isTrusted: axesEvent.isTrusted,
1513 holding: this.holding,
1514 direction: getDirection(animatingContext.start, animatingContext.end),
1515 axesEvent: axesEvent
1516 });
1517 flicking.trigger(moveStartEvent);
1518 if (moveStartEvent.isCanceled()) {
1519 transitTo(STATE_TYPE.DISABLED);
1520 } else {
1521 // Trigger AnimatingState's onChange, to trigger "move" event immediately
1522 transitTo(STATE_TYPE.ANIMATING).onChange(ctx);
1523 }
1524 };
1525 return IdleState;
1526}(State);
1527
1528/**
1529 * A state that activates when user's holding the Flicking area, but not moved a single pixel yet
1530 * @ko 사용자의 입력이 시작되었으나, 아직 움직이지는 않은 상태
1531 * @internal
1532 */
1533var HoldingState = /*#__PURE__*/function (_super) {
1534 __extends(HoldingState, _super);
1535 function HoldingState() {
1536 var _this = _super !== null && _super.apply(this, arguments) || this;
1537 /**
1538 * Whether user is clicking or touching
1539 * @ko 현재 사용자가 클릭/터치중인지 여부
1540 * @type {true}
1541 * @readonly
1542 */
1543 _this.holding = true;
1544 /**
1545 * Whether Flicking's animating
1546 * @ko 현재 애니메이션 동작 여부
1547 * @type {false}
1548 * @readonly
1549 */
1550 _this.animating = false;
1551 _this._releaseEvent = null;
1552 return _this;
1553 }
1554 var __proto = HoldingState.prototype;
1555 __proto.onChange = function (ctx) {
1556 var flicking = ctx.flicking,
1557 axesEvent = ctx.axesEvent,
1558 transitTo = ctx.transitTo;
1559 var inputEvent = axesEvent.inputEvent;
1560 var offset = flicking.horizontal ? inputEvent.offsetX : inputEvent.offsetY;
1561 var moveStartEvent = new ComponentEvent(EVENTS.MOVE_START, {
1562 isTrusted: axesEvent.isTrusted,
1563 holding: this.holding,
1564 direction: getDirection(0, -offset),
1565 axesEvent: axesEvent
1566 });
1567 flicking.trigger(moveStartEvent);
1568 if (moveStartEvent.isCanceled()) {
1569 transitTo(STATE_TYPE.DISABLED);
1570 } else {
1571 // Trigger DraggingState's onChange, to trigger "move" event immediately
1572 transitTo(STATE_TYPE.DRAGGING).onChange(ctx);
1573 }
1574 };
1575 __proto.onRelease = function (ctx) {
1576 var flicking = ctx.flicking,
1577 axesEvent = ctx.axesEvent,
1578 transitTo = ctx.transitTo;
1579 flicking.trigger(new ComponentEvent(EVENTS.HOLD_END, {
1580 axesEvent: axesEvent
1581 }));
1582 if (axesEvent.delta.flick !== 0) {
1583 // Sometimes "release" event on axes triggered before "change" event
1584 // Especially if user flicked panel fast in really short amount of time
1585 // if delta is not zero, that means above case happened.
1586 // Event flow should be HOLD_START -> MOVE_START -> MOVE -> HOLD_END
1587 // At least one move event should be included between holdStart and holdEnd
1588 axesEvent.setTo({
1589 flick: flicking.camera.position
1590 }, 0);
1591 transitTo(STATE_TYPE.IDLE);
1592 return;
1593 }
1594 // Can't handle select event here,
1595 // As "finish" axes event happens
1596 this._releaseEvent = axesEvent;
1597 };
1598 __proto.onFinish = function (ctx) {
1599 var e_1, _a;
1600 var flicking = ctx.flicking,
1601 transitTo = ctx.transitTo;
1602 // Should transite to IDLE state before select event
1603 // As user expects hold is already finished
1604 transitTo(STATE_TYPE.IDLE);
1605 if (!this._releaseEvent) {
1606 return;
1607 }
1608 // Handle release event here
1609 // To prevent finish event called twice
1610 var releaseEvent = this._releaseEvent;
1611 // Static click
1612 /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
1613 var srcEvent = releaseEvent.inputEvent.srcEvent;
1614 var clickedElement;
1615 if (srcEvent.type === "touchend") {
1616 var touchEvent = srcEvent;
1617 var touch = touchEvent.changedTouches[0];
1618 clickedElement = document.elementFromPoint(touch.clientX, touch.clientY);
1619 } else {
1620 clickedElement = srcEvent.target;
1621 }
1622 /* eslint-enable */
1623 var panels = flicking.renderer.panels;
1624 var clickedPanel = null;
1625 try {
1626 for (var panels_1 = __values(panels), panels_1_1 = panels_1.next(); !panels_1_1.done; panels_1_1 = panels_1.next()) {
1627 var panel = panels_1_1.value;
1628 if (panel.contains(clickedElement)) {
1629 clickedPanel = panel;
1630 break;
1631 }
1632 }
1633 } catch (e_1_1) {
1634 e_1 = {
1635 error: e_1_1
1636 };
1637 } finally {
1638 try {
1639 if (panels_1_1 && !panels_1_1.done && (_a = panels_1.return)) _a.call(panels_1);
1640 } finally {
1641 if (e_1) throw e_1.error;
1642 }
1643 }
1644 if (clickedPanel) {
1645 var cameraPosition = flicking.camera.position;
1646 var clickedPanelPosition = clickedPanel.position;
1647 flicking.trigger(new ComponentEvent(EVENTS.SELECT, {
1648 index: clickedPanel.index,
1649 panel: clickedPanel,
1650 // Direction to the clicked panel
1651 direction: getDirection(cameraPosition, clickedPanelPosition)
1652 }));
1653 }
1654 };
1655 return HoldingState;
1656}(State);
1657
1658/**
1659 * A state that activates when user's dragging the Flicking area
1660 * @ko 사용자가 드래깅중인 상태
1661 * @internal
1662 */
1663var DraggingState = /*#__PURE__*/function (_super) {
1664 __extends(DraggingState, _super);
1665 function DraggingState() {
1666 var _this = _super !== null && _super.apply(this, arguments) || this;
1667 /**
1668 * Whether user is clicking or touching
1669 * @ko 현재 사용자가 클릭/터치중인지 여부
1670 * @type {true}
1671 * @readonly
1672 */
1673 _this.holding = true;
1674 /**
1675 * Whether Flicking's animating
1676 * @ko 현재 애니메이션 동작 여부
1677 * @type {true}
1678 * @readonly
1679 */
1680 _this.animating = true;
1681 return _this;
1682 }
1683 var __proto = DraggingState.prototype;
1684 __proto.onChange = function (ctx) {
1685 this._moveToChangedPosition(ctx);
1686 };
1687 __proto.onRelease = function (ctx) {
1688 var _a;
1689 var flicking = ctx.flicking,
1690 axesEvent = ctx.axesEvent,
1691 transitTo = ctx.transitTo;
1692 // Update last position to cope with Axes's animating behavior
1693 // Axes uses start position when animation start
1694 flicking.trigger(new ComponentEvent(EVENTS.HOLD_END, {
1695 axesEvent: axesEvent
1696 }));
1697 if (flicking.renderer.panelCount <= 0) {
1698 // There're no panels
1699 transitTo(STATE_TYPE.IDLE);
1700 return;
1701 }
1702 transitTo(STATE_TYPE.ANIMATING);
1703 var control = flicking.control;
1704 var position = axesEvent.destPos[POSITION_KEY];
1705 var duration = Math.max(axesEvent.duration, flicking.duration);
1706 try {
1707 void control.moveToPosition(position, duration, axesEvent);
1708 } catch (err) {
1709 transitTo(STATE_TYPE.IDLE);
1710 axesEvent.setTo((_a = {}, _a[POSITION_KEY] = flicking.camera.position, _a), 0);
1711 }
1712 };
1713 return DraggingState;
1714}(State);
1715
1716/**
1717 * A state that activates when Flicking's animating by user input or method call
1718 * @ko 사용자 입력이나 메소드 호출에 의해 Flicking의 애니메이션이 동작중인 상태
1719 * @internal
1720 */
1721var AnimatingState = /*#__PURE__*/function (_super) {
1722 __extends(AnimatingState, _super);
1723 function AnimatingState() {
1724 var _this = _super !== null && _super.apply(this, arguments) || this;
1725 /**
1726 * Whether user is clicking or touching
1727 * @ko 현재 사용자가 클릭/터치중인지 여부
1728 * @type {false}
1729 * @readonly
1730 */
1731 _this.holding = false;
1732 /**
1733 * Whether Flicking's animating
1734 * @ko 현재 애니메이션 동작 여부
1735 * @type {true}
1736 * @readonly
1737 */
1738 _this.animating = true;
1739 return _this;
1740 }
1741 var __proto = AnimatingState.prototype;
1742 __proto.onHold = function (ctx) {
1743 var flicking = ctx.flicking,
1744 axesEvent = ctx.axesEvent,
1745 transitTo = ctx.transitTo;
1746 var targetPanel = this._targetPanel;
1747 var control = flicking.control;
1748 this._delta = 0;
1749 flicking.control.updateInput();
1750 if (flicking.changeOnHold && targetPanel) {
1751 control.setActive(targetPanel, control.activePanel, axesEvent.isTrusted);
1752 }
1753 var holdStartEvent = new ComponentEvent(EVENTS.HOLD_START, {
1754 axesEvent: axesEvent
1755 });
1756 flicking.trigger(holdStartEvent);
1757 if (holdStartEvent.isCanceled()) {
1758 transitTo(STATE_TYPE.DISABLED);
1759 } else {
1760 transitTo(STATE_TYPE.DRAGGING);
1761 }
1762 };
1763 __proto.onChange = function (ctx) {
1764 this._moveToChangedPosition(ctx);
1765 };
1766 __proto.onFinish = function (ctx) {
1767 var flicking = ctx.flicking,
1768 axesEvent = ctx.axesEvent,
1769 transitTo = ctx.transitTo;
1770 var control = flicking.control;
1771 var controller = control.controller;
1772 var animatingContext = controller.animatingContext;
1773 transitTo(STATE_TYPE.IDLE);
1774 flicking.trigger(new ComponentEvent(EVENTS.MOVE_END, {
1775 isTrusted: axesEvent.isTrusted,
1776 direction: getDirection(animatingContext.start, animatingContext.end),
1777 axesEvent: axesEvent
1778 }));
1779 var targetPanel = this._targetPanel;
1780 if (targetPanel) {
1781 control.setActive(targetPanel, control.activePanel, axesEvent.isTrusted);
1782 }
1783 };
1784 return AnimatingState;
1785}(State);
1786
1787/**
1788 * A state that activates when Flicking is stopped by event's `stop` method
1789 * @ko 이벤트의 `stop`호출에 의해 Flicking이 정지된 상태
1790 * @internal
1791 */
1792var DisabledState = /*#__PURE__*/function (_super) {
1793 __extends(DisabledState, _super);
1794 function DisabledState() {
1795 var _this = _super !== null && _super.apply(this, arguments) || this;
1796 /**
1797 * Whether user is clicking or touching
1798 * @ko 현재 사용자가 클릭/터치중인지 여부
1799 * @type {false}
1800 * @readonly
1801 */
1802 _this.holding = false;
1803 /**
1804 * Whether Flicking's animating
1805 * @ko 현재 애니메이션 동작 여부
1806 * @type {true}
1807 * @readonly
1808 */
1809 _this.animating = true;
1810 return _this;
1811 }
1812 var __proto = DisabledState.prototype;
1813 __proto.onAnimationEnd = function (ctx) {
1814 var transitTo = ctx.transitTo;
1815 transitTo(STATE_TYPE.IDLE);
1816 };
1817 __proto.onChange = function (ctx) {
1818 var axesEvent = ctx.axesEvent,
1819 transitTo = ctx.transitTo;
1820 // Can stop Axes's change event
1821 axesEvent.stop();
1822 transitTo(STATE_TYPE.IDLE);
1823 };
1824 __proto.onRelease = function (ctx) {
1825 var axesEvent = ctx.axesEvent,
1826 transitTo = ctx.transitTo;
1827 // This is needed when stopped hold start event
1828 if (axesEvent.delta.flick === 0) {
1829 transitTo(STATE_TYPE.IDLE);
1830 }
1831 };
1832 return DisabledState;
1833}(State);
1834
1835/**
1836 * @internal
1837 */
1838var StateMachine = /*#__PURE__*/function () {
1839 function StateMachine() {
1840 var _this = this;
1841 this.transitTo = function (nextStateType) {
1842 var nextState;
1843 switch (nextStateType) {
1844 case STATE_TYPE.IDLE:
1845 nextState = new IdleState();
1846 break;
1847 case STATE_TYPE.HOLDING:
1848 nextState = new HoldingState();
1849 break;
1850 case STATE_TYPE.DRAGGING:
1851 nextState = new DraggingState();
1852 break;
1853 case STATE_TYPE.ANIMATING:
1854 nextState = new AnimatingState();
1855 break;
1856 case STATE_TYPE.DISABLED:
1857 nextState = new DisabledState();
1858 break;
1859 }
1860 nextState.onEnter(_this._state);
1861 _this._state = nextState;
1862 return _this._state;
1863 };
1864 this._state = new IdleState();
1865 }
1866 var __proto = StateMachine.prototype;
1867 Object.defineProperty(__proto, "state", {
1868 get: function () {
1869 return this._state;
1870 },
1871 enumerable: false,
1872 configurable: true
1873 });
1874 __proto.fire = function (eventType, externalCtx) {
1875 var currentState = this._state;
1876 var ctx = __assign(__assign({}, externalCtx), {
1877 transitTo: this.transitTo
1878 });
1879 switch (eventType) {
1880 case EVENT.HOLD:
1881 currentState.onHold(ctx);
1882 break;
1883 case EVENT.CHANGE:
1884 currentState.onChange(ctx);
1885 break;
1886 case EVENT.RELEASE:
1887 currentState.onRelease(ctx);
1888 break;
1889 case EVENT.ANIMATION_END:
1890 currentState.onAnimationEnd(ctx);
1891 break;
1892 case EVENT.FINISH:
1893 currentState.onFinish(ctx);
1894 break;
1895 }
1896 };
1897 return StateMachine;
1898}();
1899
1900/**
1901 * A controller that handles the {@link https://naver.github.io/egjs-axes/ @egjs/axes} events
1902 * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 이벤트를 처리하는 컨트롤러 컴포넌트
1903 * @internal
1904 */
1905var AxesController = /*#__PURE__*/function () {
1906 /** */
1907 function AxesController() {
1908 var _this = this;
1909 this._onAxesHold = function () {
1910 _this._dragged = false;
1911 };
1912 this._onAxesChange = function () {
1913 var _a;
1914 _this._dragged = !!((_a = _this._panInput) === null || _a === void 0 ? void 0 : _a.isEnabled());
1915 };
1916 this._preventClickWhenDragged = function (e) {
1917 if (_this._dragged) {
1918 e.preventDefault();
1919 e.stopPropagation();
1920 }
1921 _this._dragged = false;
1922 };
1923 this._resetInternalValues();
1924 this._stateMachine = new StateMachine();
1925 }
1926 var __proto = AxesController.prototype;
1927 Object.defineProperty(__proto, "axes", {
1928 /**
1929 * An {@link https://naver.github.io/egjs-axes/docs/api/Axes Axes} instance
1930 * @ko {@link https://naver.github.io/egjs-axes/docs/api/Axes Axes}의 인스턴스
1931 * @type {Axes | null}
1932 * @see https://naver.github.io/egjs-axes/docs/api/Axes
1933 * @readonly
1934 */
1935 get: function () {
1936 return this._axes;
1937 },
1938 enumerable: false,
1939 configurable: true
1940 });
1941 Object.defineProperty(__proto, "panInput", {
1942 /**
1943 * An {@link https://naver.github.io/egjs-axes/docs/api/PanInput PanInput} instance
1944 * @ko {@link https://naver.github.io/egjs-axes/docs/api/PanInput PanInput}의 인스턴스
1945 * @type {PanInput | null}
1946 * @see https://naver.github.io/egjs-axes/docs/api/PanInput
1947 * @readonly
1948 */
1949 get: function () {
1950 return this._panInput;
1951 },
1952 enumerable: false,
1953 configurable: true
1954 });
1955 Object.defineProperty(__proto, "stateMachine", {
1956 /**
1957 * @internal
1958 */
1959 get: function () {
1960 return this._stateMachine;
1961 },
1962 enumerable: false,
1963 configurable: true
1964 });
1965 Object.defineProperty(__proto, "state", {
1966 /**
1967 * A activated {@link State} that shows the current status of the user input or the animation
1968 * @ko 현재 활성화된 {@link State} 인스턴스로 사용자 입력 또는 애니메이션 상태를 나타냅니다
1969 * @type {State}
1970 */
1971 get: function () {
1972 return this._stateMachine.state;
1973 },
1974 enumerable: false,
1975 configurable: true
1976 });
1977 Object.defineProperty(__proto, "animatingContext", {
1978 /**
1979 * A context of the current animation playing
1980 * @ko 현재 재생중인 애니메이션 정보
1981 * @type {object}
1982 * @property {number} start A start position of the animation<ko>애니메이션 시작 지점</ko>
1983 * @property {number} end A end position of the animation<ko>애니메이션 끝 지점</ko>
1984 * @property {number} offset camera offset<ko>카메라 오프셋</ko>
1985 * @readonly
1986 */
1987 get: function () {
1988 return this._animatingContext;
1989 },
1990 enumerable: false,
1991 configurable: true
1992 });
1993 Object.defineProperty(__proto, "controlParams", {
1994 /**
1995 * A current control parameters of the Axes instance
1996 * @ko 활성화된 현재 Axes 패러미터들
1997 * @type {ControlParams}
1998 */
1999 get: function () {
2000 var axes = this._axes;
2001 if (!axes) {
2002 return {
2003 range: {
2004 min: 0,
2005 max: 0
2006 },
2007 position: 0,
2008 circular: false
2009 };
2010 }
2011 var axis = axes.axis[POSITION_KEY];
2012 return {
2013 range: {
2014 min: axis.range[0],
2015 max: axis.range[1]
2016 },
2017 circular: axis.circular[0],
2018 position: this.position
2019 };
2020 },
2021 enumerable: false,
2022 configurable: true
2023 });
2024 Object.defineProperty(__proto, "enabled", {
2025 /**
2026 * A Boolean indicating whether the user input is enabled
2027 * @ko 현재 사용자 입력이 활성화되었는지를 나타내는 값
2028 * @type {boolean}
2029 * @readonly
2030 */
2031 get: function () {
2032 var _a, _b;
2033 return (_b = (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.isEnabled()) !== null && _b !== void 0 ? _b : false;
2034 },
2035 enumerable: false,
2036 configurable: true
2037 });
2038 Object.defineProperty(__proto, "position", {
2039 /**
2040 * Current position value in {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} instance
2041 * @ko {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} 인스턴스 내부의 현재 좌표 값
2042 * @type {number}
2043 * @readonly
2044 */
2045 get: function () {
2046 var _a, _b;
2047 return (_b = (_a = this._axes) === null || _a === void 0 ? void 0 : _a.get([POSITION_KEY])[POSITION_KEY]) !== null && _b !== void 0 ? _b : 0;
2048 },
2049 enumerable: false,
2050 configurable: true
2051 });
2052 Object.defineProperty(__proto, "range", {
2053 /**
2054 * Current range value in {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} instance
2055 * @ko {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} 인스턴스 내부의 현재 이동 범위 값
2056 * @type {number[]}
2057 * @readonly
2058 */
2059 get: function () {
2060 var _a, _b;
2061 return (_b = (_a = this._axes) === null || _a === void 0 ? void 0 : _a.axis[POSITION_KEY].range) !== null && _b !== void 0 ? _b : [0, 0];
2062 },
2063 enumerable: false,
2064 configurable: true
2065 });
2066 Object.defineProperty(__proto, "bounce", {
2067 /**
2068 * Actual bounce size(px)
2069 * @ko 적용된 bounce 크기(px 단위)
2070 * @type {number[]}
2071 * @readonly
2072 */
2073 get: function () {
2074 var _a;
2075 return (_a = this._axes) === null || _a === void 0 ? void 0 : _a.axis[POSITION_KEY].bounce;
2076 },
2077 enumerable: false,
2078 configurable: true
2079 });
2080 /**
2081 * Initialize AxesController
2082 * @ko AxesController를 초기화합니다
2083 * @param {Flicking} flicking An instance of Flicking
2084 * @chainable
2085 * @return {this}
2086 */
2087 __proto.init = function (flicking) {
2088 var _a;
2089 var _this = this;
2090 this._flicking = flicking;
2091 this._axes = new Axes((_a = {}, _a[POSITION_KEY] = {
2092 range: [0, 0],
2093 circular: false,
2094 bounce: [0, 0]
2095 }, _a), {
2096 deceleration: flicking.deceleration,
2097 interruptable: flicking.interruptable,
2098 nested: flicking.nested,
2099 easing: flicking.easing
2100 });
2101 this._panInput = new PanInput(flicking.viewport.element, {
2102 inputType: flicking.inputType,
2103 threshold: 1,
2104 iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
2105 preventDefaultOnDrag: flicking.preventDefaultOnDrag,
2106 scale: flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1],
2107 releaseOnScroll: true
2108 });
2109 var axes = this._axes;
2110 axes.connect(flicking.horizontal ? [POSITION_KEY, ""] : ["", POSITION_KEY], this._panInput);
2111 var _loop_1 = function (key) {
2112 var eventType = EVENT[key];
2113 axes.on(eventType, function (e) {
2114 _this._stateMachine.fire(eventType, {
2115 flicking: flicking,
2116 axesEvent: e
2117 });
2118 });
2119 };
2120 for (var key in EVENT) {
2121 _loop_1(key);
2122 }
2123 return this;
2124 };
2125 /**
2126 * Destroy AxesController and return to initial state
2127 * @ko AxesController를 초기 상태로 되돌립니다
2128 * @return {void}
2129 */
2130 __proto.destroy = function () {
2131 var _a;
2132 if (this._axes) {
2133 this.removePreventClickHandler();
2134 this._axes.destroy();
2135 }
2136 (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.destroy();
2137 this._resetInternalValues();
2138 };
2139 /**
2140 * Enable input from the user (mouse/touch)
2141 * @ko 사용자의 입력(마우스/터치)를 활성화합니다
2142 * @chainable
2143 * @return {this}
2144 */
2145 __proto.enable = function () {
2146 var _a;
2147 (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.enable();
2148 return this;
2149 };
2150 /**
2151 * Disable input from the user (mouse/touch)
2152 * @ko 사용자의 입력(마우스/터치)를 막습니다
2153 * @chainable
2154 * @return {this}
2155 */
2156 __proto.disable = function () {
2157 var _a;
2158 (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.disable();
2159 return this;
2160 };
2161 /**
2162 * Releases ongoing user input (mouse/touch)
2163 * @ko 사용자의 현재 입력(마우스/터치)를 중단시킵니다
2164 * @chainable
2165 * @return {this}
2166 */
2167 __proto.release = function () {
2168 var _a;
2169 (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.release();
2170 return this;
2171 };
2172 /**
2173 * Change the destination and duration of the animation currently playing
2174 * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
2175 * @param {number} position A position to move<ko>이동할 좌표</ko>
2176 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
2177 * @chainable
2178 * @return {this}
2179 */
2180 __proto.updateAnimation = function (position, duration) {
2181 var _a;
2182 var _b;
2183 this._animatingContext = __assign(__assign({}, this._animatingContext), {
2184 end: position
2185 });
2186 (_b = this._axes) === null || _b === void 0 ? void 0 : _b.updateAnimation({
2187 destPos: (_a = {}, _a[POSITION_KEY] = position, _a),
2188 duration: duration
2189 });
2190 return this;
2191 };
2192 /**
2193 * Stops the animation currently playing
2194 * @ko 재생 중인 애니메이션을 중단시킵니다
2195 * @chainable
2196 * @return {this}
2197 */
2198 __proto.stopAnimation = function () {
2199 var _a;
2200 (_a = this._axes) === null || _a === void 0 ? void 0 : _a.stopAnimation();
2201 return this;
2202 };
2203 /**
2204 * Update {@link https://naver.github.io/egjs-axes/ @egjs/axes}'s state
2205 * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 상태를 갱신합니다
2206 * @chainable
2207 * @throws {FlickingError}
2208 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link AxesController#init init} is not called before
2209 * <ko>{@link AxesController#init init}이 이전에 호출되지 않은 경우</ko>
2210 * @return {this}
2211 */
2212 __proto.update = function (controlParams) {
2213 var _a;
2214 var flicking = getFlickingAttached(this._flicking);
2215 var camera = flicking.camera;
2216 var axes = this._axes;
2217 var axis = axes.axis[POSITION_KEY];
2218 axis.circular = [controlParams.circular, controlParams.circular];
2219 axis.range = [controlParams.range.min, controlParams.range.max];
2220 axis.bounce = parseBounce(flicking.bounce, camera.size);
2221 axes.axisManager.set((_a = {}, _a[POSITION_KEY] = controlParams.position, _a));
2222 return this;
2223 };
2224 /**
2225 * Attach a handler to the camera element to prevent click events during animation
2226 * @ko 카메라 엘리먼트에 애니메이션 도중에 클릭 이벤트를 방지하는 핸들러를 부착합니다
2227 * @return {this}
2228 */
2229 __proto.addPreventClickHandler = function () {
2230 var flicking = getFlickingAttached(this._flicking);
2231 var axes = this._axes;
2232 var cameraEl = flicking.camera.element;
2233 axes.on(EVENT.HOLD, this._onAxesHold);
2234 axes.on(EVENT.CHANGE, this._onAxesChange);
2235 cameraEl.addEventListener("click", this._preventClickWhenDragged, true);
2236 return this;
2237 };
2238 /**
2239 * Detach a handler to the camera element to prevent click events during animation
2240 * @ko 카메라 엘리먼트에 애니메이션 도중에 클릭 이벤트를 방지하는 핸들러를 탈착합니다
2241 * @return {this}
2242 */
2243 __proto.removePreventClickHandler = function () {
2244 var flicking = getFlickingAttached(this._flicking);
2245 var axes = this._axes;
2246 var cameraEl = flicking.camera.element;
2247 axes.off(EVENT.HOLD, this._onAxesHold);
2248 axes.off(EVENT.CHANGE, this._onAxesChange);
2249 cameraEl.removeEventListener("click", this._preventClickWhenDragged, true);
2250 return this;
2251 };
2252 /**
2253 * Run Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#setTo setTo} using the given position
2254 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#setTo setTo} 메소드를 주어진 좌표를 이용하여 수행합니다
2255 * @param {number} position A position to move<ko>이동할 좌표</ko>
2256 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
2257 * @param {number} [axesEvent] If provided, it'll use its {@link https://naver#github#io/egjs-axes/release/latest/doc/eg#Axes#html#setTo setTo} method instead<ko>이 값이 주어졌을 경우, 해당 이벤트의 {@link https://naver#github#io/egjs-axes/release/latest/doc/eg#Axes#html#setTo setTo} 메소드를 대신해서 사용합니다.</ko>
2258 * @throws {FlickingError}
2259 * |code|condition|
2260 * |---|---|
2261 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
2262 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
2263 * <ko>
2264 *
2265 * |code|condition|
2266 * |---|---|
2267 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
2268 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
2269 *
2270 * </ko>
2271 * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
2272 */
2273 __proto.animateTo = function (position, duration, axesEvent) {
2274 var _this = this;
2275 var _a;
2276 var axes = this._axes;
2277 var state = this._stateMachine.state;
2278 if (!axes) {
2279 return Promise.reject(new FlickingError(MESSAGE.NOT_ATTACHED_TO_FLICKING, CODE.NOT_ATTACHED_TO_FLICKING));
2280 }
2281 var startPos = axes.get([POSITION_KEY])[POSITION_KEY];
2282 if (startPos === position) {
2283 var flicking = getFlickingAttached(this._flicking);
2284 flicking.camera.lookAt(position);
2285 if (state.targetPanel) {
2286 flicking.control.setActive(state.targetPanel, flicking.control.activePanel, (_a = axesEvent === null || axesEvent === void 0 ? void 0 : axesEvent.isTrusted) !== null && _a !== void 0 ? _a : false);
2287 }
2288 return Promise.resolve();
2289 }
2290 this._animatingContext = {
2291 start: startPos,
2292 end: position,
2293 offset: 0
2294 };
2295 var animate = function () {
2296 var _a, _b;
2297 var resetContext = function () {
2298 _this._animatingContext = {
2299 start: 0,
2300 end: 0,
2301 offset: 0
2302 };
2303 };
2304 axes.once(EVENT.FINISH, resetContext);
2305 if (axesEvent) {
2306 axesEvent.setTo((_a = {}, _a[POSITION_KEY] = position, _a), duration);
2307 } else {
2308 axes.setTo((_b = {}, _b[POSITION_KEY] = position, _b), duration);
2309 }
2310 };
2311 return new Promise(function (resolve, reject) {
2312 var animationFinishHandler = function () {
2313 axes.off(EVENT.HOLD, interruptionHandler);
2314 resolve();
2315 };
2316 var interruptionHandler = function () {
2317 axes.off(EVENT.FINISH, animationFinishHandler);
2318 reject(new FlickingError(MESSAGE.ANIMATION_INTERRUPTED, CODE.ANIMATION_INTERRUPTED));
2319 };
2320 axes.once(EVENT.FINISH, animationFinishHandler);
2321 axes.once(EVENT.HOLD, interruptionHandler);
2322 animate();
2323 });
2324 };
2325 __proto.updateDirection = function () {
2326 var flicking = getFlickingAttached(this._flicking);
2327 var axes = this._axes;
2328 var panInput = this._panInput;
2329 axes.disconnect(panInput);
2330 axes.connect(flicking.horizontal ? [POSITION_KEY, ""] : ["", POSITION_KEY], panInput);
2331 panInput.options.scale = flicking.horizontal ? [flicking.camera.panelOrder === ORDER.RTL ? 1 : -1, 0] : [0, -1];
2332 };
2333 __proto._resetInternalValues = function () {
2334 this._flicking = null;
2335 this._axes = null;
2336 this._panInput = null;
2337 this._animatingContext = {
2338 start: 0,
2339 end: 0,
2340 offset: 0
2341 };
2342 this._dragged = false;
2343 };
2344 return AxesController;
2345}();
2346
2347/**
2348 * A component that manages inputs and animation of Flicking
2349 * @ko Flicking의 입력 장치 & 애니메이션을 담당하는 컴포넌트
2350 */
2351var Control = /*#__PURE__*/function () {
2352 /** */
2353 function Control() {
2354 this._flicking = null;
2355 this._controller = new AxesController();
2356 this._activePanel = null;
2357 }
2358 var __proto = Control.prototype;
2359 Object.defineProperty(__proto, "controller", {
2360 /**
2361 * A controller that handles the {@link https://naver.github.io/egjs-axes/ @egjs/axes} events
2362 * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 이벤트를 처리하는 컨트롤러 컴포넌트
2363 * @type {AxesController}
2364 * @readonly
2365 */
2366 get: function () {
2367 return this._controller;
2368 },
2369 enumerable: false,
2370 configurable: true
2371 });
2372 Object.defineProperty(__proto, "activeIndex", {
2373 /**
2374 * Index number of the {@link Flicking#currentPanel currentPanel}
2375 * @ko {@link Flicking#currentPanel currentPanel}의 인덱스 번호
2376 * @type {number}
2377 * @default 0
2378 * @readonly
2379 */
2380 get: function () {
2381 var _a, _b;
2382 return (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : -1;
2383 },
2384 enumerable: false,
2385 configurable: true
2386 });
2387 Object.defineProperty(__proto, "activePanel", {
2388 /**
2389 * An active panel
2390 * @ko 현재 선택된 패널
2391 * @type {Panel | null}
2392 * @readonly
2393 */
2394 get: function () {
2395 return this._activePanel;
2396 },
2397 enumerable: false,
2398 configurable: true
2399 });
2400 Object.defineProperty(__proto, "animating", {
2401 /**
2402 * Whether Flicking's animating
2403 * @ko 현재 애니메이션 동작 여부
2404 * @type {boolean}
2405 * @readonly
2406 */
2407 get: function () {
2408 return this._controller.state.animating;
2409 },
2410 enumerable: false,
2411 configurable: true
2412 });
2413 Object.defineProperty(__proto, "holding", {
2414 /**
2415 * Whether user is clicking or touching
2416 * @ko 현재 사용자가 클릭/터치중인지 여부
2417 * @type {boolean}
2418 * @readonly
2419 */
2420 get: function () {
2421 return this._controller.state.holding;
2422 },
2423 enumerable: false,
2424 configurable: true
2425 });
2426 /**
2427 * Initialize Control
2428 * @ko Control을 초기화합니다
2429 * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
2430 * @chainable
2431 * @return {this}
2432 */
2433 __proto.init = function (flicking) {
2434 this._flicking = flicking;
2435 this._controller.init(flicking);
2436 return this;
2437 };
2438 /**
2439 * Destroy Control and return to initial state
2440 * @ko Control을 초기 상태로 되돌립니다
2441 * @return {void}
2442 */
2443 __proto.destroy = function () {
2444 this._controller.destroy();
2445 this._flicking = null;
2446 this._activePanel = null;
2447 };
2448 /**
2449 * Enable input from the user (mouse/touch)
2450 * @ko 사용자의 입력(마우스/터치)를 활성화합니다
2451 * @chainable
2452 * @return {this}
2453 */
2454 __proto.enable = function () {
2455 this._controller.enable();
2456 return this;
2457 };
2458 /**
2459 * Disable input from the user (mouse/touch)
2460 * @ko 사용자의 입력(마우스/터치)를 막습니다
2461 * @chainable
2462 * @return {this}
2463 */
2464 __proto.disable = function () {
2465 this._controller.disable();
2466 return this;
2467 };
2468 /**
2469 * Releases ongoing user input (mouse/touch)
2470 * @ko 사용자의 현재 입력(마우스/터치)를 중단시킵니다
2471 * @chainable
2472 * @return {this}
2473 */
2474 __proto.release = function () {
2475 this._controller.release();
2476 return this;
2477 };
2478 /**
2479 * Change the destination and duration of the animation currently playing
2480 * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
2481 * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
2482 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
2483 * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
2484 * @chainable
2485 * @throws {FlickingError}
2486 * {@link ERROR_CODE POSITION_NOT_REACHABLE} When the given panel is already removed or not in the Camera's {@link Camera#range range}
2487 * <ko>{@link ERROR_CODE POSITION_NOT_REACHABLE} 주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우</ko>
2488 * @return {this}
2489 */
2490 __proto.updateAnimation = function (panel, duration, direction) {
2491 var state = this._controller.state;
2492 var position = this._getPosition(panel, direction !== null && direction !== void 0 ? direction : DIRECTION.NONE);
2493 state.targetPanel = panel;
2494 this._controller.updateAnimation(position, duration);
2495 return this;
2496 };
2497 /**
2498 * Stops the animation currently playing
2499 * @ko 재생 중인 애니메이션을 중단시킵니다
2500 * @chainable
2501 * @return {this}
2502 */
2503 __proto.stopAnimation = function () {
2504 var state = this._controller.state;
2505 state.targetPanel = null;
2506 this._controller.stopAnimation();
2507 return this;
2508 };
2509 /**
2510 * Update position after resizing
2511 * @ko resize 이후에 position을 업데이트합니다
2512 * @param {number} progressInPanel Previous camera's progress in active panel before resize<ko>Resize 이전 현재 선택된 패널 내에서의 카메라 progress 값</ko>
2513 * @throws {FlickingError}
2514 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
2515 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
2516 * @chainable
2517 * @return {Promise<void>}
2518 */
2519 __proto.updatePosition = function (progressInPanel) {
2520 var flicking = getFlickingAttached(this._flicking);
2521 var camera = flicking.camera;
2522 var activePanel = this._activePanel;
2523 if (activePanel) {
2524 camera.lookAt(camera.clampToReachablePosition(activePanel.position));
2525 }
2526 };
2527 /**
2528 * Update {@link Control#controller controller}'s state
2529 * @ko {@link Control#controller controller}의 내부 상태를 갱신합니다
2530 * @chainable
2531 * @return {this}
2532 */
2533 __proto.updateInput = function () {
2534 var flicking = getFlickingAttached(this._flicking);
2535 var camera = flicking.camera;
2536 this._controller.update(camera.controlParams);
2537 return this;
2538 };
2539 /**
2540 * Reset {@link Control#activePanel activePanel} to `null`
2541 * @ko {@link Control#activePanel activePanel}을 `null`로 초기화합니다
2542 * @chainable
2543 * @return {this}
2544 */
2545 __proto.resetActive = function () {
2546 this._activePanel = null;
2547 return this;
2548 };
2549 /**
2550 * Move {@link Camera} to the given panel
2551 * @ko {@link Camera}를 해당 패널 위로 이동합니다
2552 * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
2553 * @param {object} options An options object<ko>옵션 오브젝트</ko>
2554 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
2555 * @param {object} [axesEvent] {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of {@link https://naver.github.io/egjs-axes/ Axes}
2556 * <ko>{@link https://naver.github.io/egjs-axes/ Axes}의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
2557 * @param {DIRECTION} [direction=DIRECTION.NONE] Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
2558 * @fires Flicking#moveStart
2559 * @fires Flicking#move
2560 * @fires Flicking#moveEnd
2561 * @fires Flicking#willChange
2562 * @fires Flicking#changed
2563 * @fires Flicking#willRestore
2564 * @fires Flicking#restored
2565 * @fires Flicking#needPanel
2566 * @fires Flicking#visibleChange
2567 * @fires Flicking#reachEdge
2568 * @throws {FlickingError}
2569 * |code|condition|
2570 * |---|---|
2571 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
2572 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
2573 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
2574 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
2575 * <ko>
2576 *
2577 * |code|condition|
2578 * |---|---|
2579 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
2580 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
2581 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
2582 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
2583 *
2584 * </ko>
2585 * @return {Promise<void>} A Promise which will be resolved after reaching the target panel<ko>해당 패널 도달시에 resolve되는 Promise</ko>
2586 */
2587 __proto.moveToPanel = function (panel, _a) {
2588 var duration = _a.duration,
2589 _b = _a.direction,
2590 direction = _b === void 0 ? DIRECTION.NONE : _b,
2591 axesEvent = _a.axesEvent;
2592 return __awaiter(this, void 0, void 0, function () {
2593 var position;
2594 return __generator(this, function (_c) {
2595 position = this._getPosition(panel, direction);
2596 this._triggerIndexChangeEvent(panel, panel.position, axesEvent, direction);
2597 return [2 /*return*/, this._animateToPosition({
2598 position: position,
2599 duration: duration,
2600 newActivePanel: panel,
2601 axesEvent: axesEvent
2602 })];
2603 });
2604 });
2605 };
2606 /**
2607 * @internal
2608 */
2609 __proto.setActive = function (newActivePanel, prevActivePanel, isTrusted) {
2610 var _a;
2611 var flicking = getFlickingAttached(this._flicking);
2612 this._activePanel = newActivePanel;
2613 this._nextPanel = null;
2614 flicking.camera.updateAdaptiveHeight();
2615 if (newActivePanel !== prevActivePanel) {
2616 flicking.trigger(new ComponentEvent(EVENTS.CHANGED, {
2617 index: newActivePanel.index,
2618 panel: newActivePanel,
2619 prevIndex: (_a = prevActivePanel === null || prevActivePanel === void 0 ? void 0 : prevActivePanel.index) !== null && _a !== void 0 ? _a : -1,
2620 prevPanel: prevActivePanel,
2621 isTrusted: isTrusted,
2622 direction: prevActivePanel ? getDirection(prevActivePanel.position, newActivePanel.position) : DIRECTION.NONE
2623 }));
2624 } else {
2625 flicking.trigger(new ComponentEvent(EVENTS.RESTORED, {
2626 isTrusted: isTrusted
2627 }));
2628 }
2629 };
2630 /**
2631 * @internal
2632 */
2633 __proto.copy = function (control) {
2634 this._flicking = control._flicking;
2635 this._activePanel = control._activePanel;
2636 this._controller = control._controller;
2637 };
2638 __proto._triggerIndexChangeEvent = function (panel, position, axesEvent, direction) {
2639 var _a;
2640 var flicking = getFlickingAttached(this._flicking);
2641 var triggeringEvent = panel !== this._activePanel ? EVENTS.WILL_CHANGE : EVENTS.WILL_RESTORE;
2642 var camera = flicking.camera;
2643 var activePanel = this._activePanel;
2644 var event = new ComponentEvent(triggeringEvent, {
2645 index: panel.index,
2646 panel: panel,
2647 isTrusted: (axesEvent === null || axesEvent === void 0 ? void 0 : axesEvent.isTrusted) || false,
2648 direction: direction !== null && direction !== void 0 ? direction : getDirection((_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.position) !== null && _a !== void 0 ? _a : camera.position, position)
2649 });
2650 this._nextPanel = panel;
2651 flicking.trigger(event);
2652 if (event.isCanceled()) {
2653 throw new FlickingError(MESSAGE.STOP_CALLED_BY_USER, CODE.STOP_CALLED_BY_USER);
2654 }
2655 };
2656 __proto._animateToPosition = function (_a) {
2657 var position = _a.position,
2658 duration = _a.duration,
2659 newActivePanel = _a.newActivePanel,
2660 axesEvent = _a.axesEvent;
2661 return __awaiter(this, void 0, void 0, function () {
2662 var flicking, animate, state;
2663 var _this = this;
2664 return __generator(this, function (_b) {
2665 flicking = getFlickingAttached(this._flicking);
2666 animate = function () {
2667 return _this._controller.animateTo(position, duration, axesEvent);
2668 };
2669 state = this._controller.state;
2670 state.targetPanel = newActivePanel;
2671 if (duration <= 0) {
2672 return [2 /*return*/, animate()];
2673 } else {
2674 return [2 /*return*/, animate().then(function () {
2675 return __awaiter(_this, void 0, void 0, function () {
2676 return __generator(this, function (_a) {
2677 switch (_a.label) {
2678 case 0:
2679 return [4 /*yield*/, flicking.renderer.render()];
2680 case 1:
2681 _a.sent();
2682 return [2 /*return*/];
2683 }
2684 });
2685 });
2686 }).catch(function (err) {
2687 if (axesEvent && err instanceof FlickingError && err.code === CODE.ANIMATION_INTERRUPTED) return;
2688 throw err;
2689 })];
2690 }
2691 });
2692 });
2693 };
2694
2695 __proto._getPosition = function (panel, direction) {
2696 if (direction === void 0) {
2697 direction = DIRECTION.NONE;
2698 }
2699 var flicking = getFlickingAttached(this._flicking);
2700 var camera = flicking.camera;
2701 var position = panel.position;
2702 var nearestAnchor = camera.findNearestAnchor(position);
2703 if (panel.removed || !nearestAnchor) {
2704 throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE);
2705 }
2706 if (!camera.canReach(panel)) {
2707 // Override position & panel if that panel is not reachable
2708 position = nearestAnchor.position;
2709 panel = nearestAnchor.panel;
2710 } else if (flicking.circularEnabled) {
2711 // Circular mode is enabled, find nearest distance to panel
2712 var camPos_1 = this._controller.position; // Actual position of the Axes
2713 var camRangeDiff = camera.rangeDiff;
2714 var possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
2715 if (direction === DIRECTION.NONE) return true;
2716 return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
2717 });
2718 position = possiblePositions.reduce(function (nearestPosition, pos) {
2719 if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
2720 return pos;
2721 } else {
2722 return nearestPosition;
2723 }
2724 }, Infinity);
2725 }
2726 return position;
2727 };
2728 return Control;
2729}();
2730
2731/**
2732 * A data component that has actual position where the camera should be stopped at
2733 * @ko 카메라가 정지해야하는 실제 위치를 담고 있는 데이터 컴포넌트
2734 */
2735var AnchorPoint = /*#__PURE__*/function () {
2736 /**
2737 * @param {object} options An options object<ko>옵션 객체</ko>
2738 * @param {number} [options.index] Index of AnchorPoint<ko>AnchorPoint의 인덱스</ko>
2739 * @param {number} [options.position] Position of AnchorPoint<ko>AnchorPoint의 좌표</ko>
2740 * @param {Panel} [options.panel] A {@link Panel} instance AnchorPoint is referencing to<ko>AnchorPoint가 참조하고 있는 {@link Panel}</ko>
2741 */
2742 function AnchorPoint(_a) {
2743 var index = _a.index,
2744 position = _a.position,
2745 panel = _a.panel;
2746 this._index = index;
2747 this._pos = position;
2748 this._panel = panel;
2749 }
2750 var __proto = AnchorPoint.prototype;
2751 Object.defineProperty(__proto, "index", {
2752 /**
2753 * Index of AnchorPoint
2754 * @ko AnchorPoint의 인덱스
2755 * @type {number}
2756 * @readonly
2757 */
2758 get: function () {
2759 return this._index;
2760 },
2761 enumerable: false,
2762 configurable: true
2763 });
2764 Object.defineProperty(__proto, "position", {
2765 /**
2766 * Position of AnchorPoint
2767 * @ko AnchorPoint의 좌표
2768 * @type {number}
2769 * @readonly
2770 */
2771 get: function () {
2772 return this._pos;
2773 },
2774 enumerable: false,
2775 configurable: true
2776 });
2777 Object.defineProperty(__proto, "panel", {
2778 /**
2779 * A {@link Panel} instance AnchorPoint is referencing to
2780 * @ko AnchorPoint가 참조하고 있는 {@link Panel}
2781 * @type {Panel}
2782 * @readonly
2783 */
2784 get: function () {
2785 return this._panel;
2786 },
2787 enumerable: false,
2788 configurable: true
2789 });
2790 return AnchorPoint;
2791}();
2792
2793/**
2794 * A {@link Control} that uses a release momentum to choose destination panel
2795 * @ko 입력을 중단한 시점의 가속도에 영향받아 도달할 패널을 계산하는 이동 방식을 사용하는 {@link Control}
2796 */
2797var SnapControl = /*#__PURE__*/function (_super) {
2798 __extends(SnapControl, _super);
2799 /** */
2800 function SnapControl(_a) {
2801 var _b = (_a === void 0 ? {} : _a).count,
2802 count = _b === void 0 ? Infinity : _b;
2803 var _this = _super.call(this) || this;
2804 _this._count = count;
2805 return _this;
2806 }
2807 var __proto = SnapControl.prototype;
2808 Object.defineProperty(__proto, "count", {
2809 /**
2810 * Maximum number of panels can go after release
2811 * @ko 입력 중단 이후 통과하여 이동할 수 있는 패널의 최대 갯수
2812 * @type {number}
2813 * @default Infinity
2814 */
2815 get: function () {
2816 return this._count;
2817 },
2818 set: function (val) {
2819 this._count = val;
2820 },
2821 enumerable: false,
2822 configurable: true
2823 });
2824 /**
2825 * Move {@link Camera} to the given position
2826 * @ko {@link Camera}를 주어진 좌표로 이동합니다
2827 * @param {number} position The target position to move<ko>이동할 좌표</ko>
2828 * @param {number} duration Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
2829 * @param {object} [axesEvent] {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of {@link https://naver.github.io/egjs-axes/ Axes}
2830 * <ko>{@link https://naver.github.io/egjs-axes/ Axes}의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
2831 * @fires Flicking#moveStart
2832 * @fires Flicking#move
2833 * @fires Flicking#moveEnd
2834 * @fires Flicking#willChange
2835 * @fires Flicking#changed
2836 * @fires Flicking#willRestore
2837 * @fires Flicking#restored
2838 * @fires Flicking#needPanel
2839 * @fires Flicking#visibleChange
2840 * @fires Flicking#reachEdge
2841 * @throws {FlickingError}
2842 * |code|condition|
2843 * |---|---|
2844 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
2845 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
2846 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
2847 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
2848 * <ko>
2849 *
2850 * |code|condition|
2851 * |---|---|
2852 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
2853 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
2854 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
2855 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
2856 *
2857 * </ko>
2858 * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
2859 */
2860 __proto.moveToPosition = function (position, duration, axesEvent) {
2861 var flicking = getFlickingAttached(this._flicking);
2862 var camera = flicking.camera;
2863 var activeAnchor = camera.findActiveAnchor();
2864 var anchorAtCamera = camera.findNearestAnchor(camera.position);
2865 var state = this._controller.state;
2866 if (!activeAnchor || !anchorAtCamera) {
2867 return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
2868 }
2869 var snapThreshold = this._calcSnapThreshold(flicking.threshold, position, activeAnchor);
2870 var posDelta = flicking.animating ? state.delta : position - camera.position;
2871 var absPosDelta = Math.abs(posDelta);
2872 var snapDelta = axesEvent && axesEvent.delta[POSITION_KEY] !== 0 ? Math.abs(axesEvent.delta[POSITION_KEY]) : absPosDelta;
2873 var targetAnchor;
2874 if (snapDelta >= snapThreshold && snapDelta > 0) {
2875 // Move to anchor at position
2876 targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
2877 } else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
2878 // Move to the adjacent panel
2879 targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
2880 } else {
2881 // Fallback to nearest panel from current camera
2882 return this.moveToPanel(anchorAtCamera.panel, {
2883 duration: duration,
2884 axesEvent: axesEvent
2885 });
2886 }
2887 this._triggerIndexChangeEvent(targetAnchor.panel, position, axesEvent);
2888 return this._animateToPosition({
2889 position: camera.clampToReachablePosition(targetAnchor.position),
2890 duration: duration,
2891 newActivePanel: targetAnchor.panel,
2892 axesEvent: axesEvent
2893 });
2894 };
2895 __proto._findSnappedAnchor = function (position, anchorAtCamera) {
2896 var flicking = getFlickingAttached(this._flicking);
2897 var camera = flicking.camera;
2898 var count = this._count;
2899 var currentPos = camera.position;
2900 var clampedPosition = camera.clampToReachablePosition(position);
2901 var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
2902 if (!anchorAtCamera || !anchorAtPosition) {
2903 throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE);
2904 }
2905 if (!isFinite(count)) {
2906 return anchorAtPosition;
2907 }
2908 var panelCount = flicking.panelCount;
2909 var anchors = camera.anchorPoints;
2910 var loopCount = Math.sign(position - currentPos) * Math.floor(Math.abs(position - currentPos) / camera.rangeDiff);
2911 if (position > currentPos && anchorAtPosition.index < anchorAtCamera.index || anchorAtPosition.position > anchorAtCamera.position && anchorAtPosition.index === anchorAtCamera.index) {
2912 loopCount += 1;
2913 } else if (position < currentPos && anchorAtPosition.index > anchorAtCamera.index || anchorAtPosition.position < anchorAtCamera.position && anchorAtPosition.index === anchorAtCamera.index) {
2914 loopCount -= 1;
2915 }
2916 var circularIndexOffset = loopCount * panelCount;
2917 var anchorAtPositionIndex = anchorAtPosition.index + circularIndexOffset;
2918 if (Math.abs(anchorAtPositionIndex - anchorAtCamera.index) <= count) {
2919 var anchor = anchors[anchorAtPosition.index];
2920 return new AnchorPoint({
2921 index: anchor.index,
2922 position: anchor.position + loopCount * camera.rangeDiff,
2923 panel: anchor.panel
2924 });
2925 }
2926 if (flicking.circularEnabled) {
2927 var targetAnchor = anchors[circulateIndex(anchorAtCamera.index + Math.sign(position - currentPos) * count, panelCount)];
2928 var loop = Math.floor(count / panelCount);
2929 if (position > currentPos && targetAnchor.index < anchorAtCamera.index) {
2930 loop += 1;
2931 } else if (position < currentPos && targetAnchor.index > anchorAtCamera.index) {
2932 loop -= 1;
2933 }
2934 return new AnchorPoint({
2935 index: targetAnchor.index,
2936 position: targetAnchor.position + loop * camera.rangeDiff,
2937 panel: targetAnchor.panel
2938 });
2939 } else {
2940 return anchors[clamp(anchorAtCamera.index + Math.sign(position - currentPos) * count, 0, anchors.length - 1)];
2941 }
2942 };
2943 __proto._findAdjacentAnchor = function (position, posDelta, anchorAtCamera) {
2944 var _a;
2945 var flicking = getFlickingAttached(this._flicking);
2946 var camera = flicking.camera;
2947 if (camera.circularEnabled) {
2948 var anchorIncludePosition = camera.findAnchorIncludePosition(position);
2949 if (anchorIncludePosition && anchorIncludePosition.position !== anchorAtCamera.position) {
2950 return anchorIncludePosition;
2951 }
2952 }
2953 var adjacentAnchor = (_a = posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) !== null && _a !== void 0 ? _a : anchorAtCamera;
2954 return adjacentAnchor;
2955 };
2956 __proto._calcSnapThreshold = function (threshold, position, activeAnchor) {
2957 var isNextDirection = position > activeAnchor.position;
2958 var panel = activeAnchor.panel;
2959 var panelSize = panel.size;
2960 var alignPos = panel.alignPosition;
2961 // Minimum distance needed to decide prev/next panel as nearest
2962 /*
2963 * | Prev | Next |
2964 * |<------>|<------------>|
2965 * [ |<-Anchor ]
2966 */
2967 return Math.max(threshold, isNextDirection ? panelSize - alignPos + panel.margin.next : alignPos + panel.margin.prev);
2968 };
2969 return SnapControl;
2970}(Control);
2971
2972/**
2973 * A {@link Control} that can be scrolled freely without alignment
2974 * @ko 패널이 정해진 지점에 정렬되지 않고, 자유롭게 스크롤할 수 있는 이동 방식을 사용하는 {@link Control}
2975 */
2976var FreeControl = /*#__PURE__*/function (_super) {
2977 __extends(FreeControl, _super);
2978 /** */
2979 function FreeControl(_a) {
2980 var _b = (_a === void 0 ? {} : _a).stopAtEdge,
2981 stopAtEdge = _b === void 0 ? true : _b;
2982 var _this = _super.call(this) || this;
2983 _this._stopAtEdge = stopAtEdge;
2984 return _this;
2985 }
2986 var __proto = FreeControl.prototype;
2987 Object.defineProperty(__proto, "stopAtEdge", {
2988 /**
2989 * Make scroll animation to stop at the start/end of the scroll area, not going out the bounce area
2990 * @ko 스크롤 애니메이션을 스크롤 영역의 시작과 끝부분에서 멈추도록 하여, 바운스 영역을 넘어가지 않도록 합니다
2991 * @type {boolean}
2992 * @default true
2993 */
2994 get: function () {
2995 return this._stopAtEdge;
2996 },
2997 set: function (val) {
2998 this._stopAtEdge = val;
2999 },
3000 enumerable: false,
3001 configurable: true
3002 });
3003 /**
3004 * Update position after resizing
3005 * @ko resize 이후에 position을 업데이트합니다
3006 * @param {number} progressInPanel Previous camera's progress in active panel before resize<ko>Resize 이전 현재 선택된 패널 내에서의 카메라 progress 값</ko>
3007 * @throws {FlickingError}
3008 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
3009 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
3010 * @chainable
3011 * @return {Promise<void>}
3012 */
3013 __proto.updatePosition = function (progressInPanel) {
3014 var flicking = getFlickingAttached(this._flicking);
3015 var camera = flicking.camera;
3016 var activePanel = this._activePanel;
3017 if (activePanel) {
3018 var panelRange = activePanel.range;
3019 var newPosition = panelRange.min + (panelRange.max - panelRange.min) * progressInPanel;
3020 camera.lookAt(camera.clampToReachablePosition(newPosition));
3021 }
3022 };
3023 /**
3024 * Move {@link Camera} to the given position
3025 * @ko {@link Camera}를 주어진 좌표로 이동합니다
3026 * @param {number} position The target position to move<ko>이동할 좌표</ko>
3027 * @param {number} duration Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
3028 * @param {object} [axesEvent] {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of {@link https://naver.github.io/egjs-axes/ Axes}
3029 * <ko>{@link https://naver.github.io/egjs-axes/ Axes}의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
3030 * @fires Flicking#moveStart
3031 * @fires Flicking#move
3032 * @fires Flicking#moveEnd
3033 * @fires Flicking#willChange
3034 * @fires Flicking#changed
3035 * @fires Flicking#willRestore
3036 * @fires Flicking#restored
3037 * @fires Flicking#needPanel
3038 * @fires Flicking#visibleChange
3039 * @fires Flicking#reachEdge
3040 * @throws {FlickingError}
3041 * |code|condition|
3042 * |---|---|
3043 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
3044 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
3045 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
3046 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
3047 * <ko>
3048 *
3049 * |code|condition|
3050 * |---|---|
3051 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
3052 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
3053 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
3054 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
3055 *
3056 * </ko>
3057 * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
3058 */
3059 __proto.moveToPosition = function (position, duration, axesEvent) {
3060 var flicking = getFlickingAttached(this._flicking);
3061 var camera = flicking.camera;
3062 var targetPos = camera.clampToReachablePosition(position);
3063 var anchorAtPosition = camera.findAnchorIncludePosition(targetPos);
3064 if (!anchorAtPosition) {
3065 return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
3066 }
3067 var targetPanel = anchorAtPosition.panel;
3068 // Trigger only change event
3069 if (targetPanel !== this._activePanel) {
3070 this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
3071 }
3072 return this._animateToPosition({
3073 position: this._stopAtEdge ? targetPos : position,
3074 duration: duration,
3075 newActivePanel: targetPanel,
3076 axesEvent: axesEvent
3077 });
3078 };
3079 return FreeControl;
3080}(Control);
3081
3082/**
3083 * A {@link Control} that allow you to select the maximum number of panels to move at a time
3084 * @ko 한번에 최대로 이동할 패널의 개수를 선택 가능한 {@link Control}
3085 */
3086var StrictControl = /*#__PURE__*/function (_super) {
3087 __extends(StrictControl, _super);
3088 /** */
3089 function StrictControl(_a) {
3090 var _b = (_a === void 0 ? {} : _a).count,
3091 count = _b === void 0 ? 1 : _b;
3092 var _this = _super.call(this) || this;
3093 _this.setActive = function (newActivePanel, prevActivePanel, isTrusted) {
3094 _super.prototype.setActive.call(_this, newActivePanel, prevActivePanel, isTrusted);
3095 _this.updateInput();
3096 };
3097 _this._count = count;
3098 _this._resetIndexRange();
3099 return _this;
3100 }
3101 var __proto = StrictControl.prototype;
3102 Object.defineProperty(__proto, "count", {
3103 /**
3104 * Maximum number of panels that can be moved at a time
3105 * @ko 최대로 움직일 수 있는 패널의 개수
3106 * @type {number}
3107 * @default 1
3108 */
3109 get: function () {
3110 return this._count;
3111 },
3112 set: function (val) {
3113 this._count = val;
3114 },
3115 enumerable: false,
3116 configurable: true
3117 });
3118 /**
3119 * Destroy Control and return to initial state
3120 * @ko Control을 초기 상태로 되돌립니다
3121 * @return {void}
3122 */
3123 __proto.destroy = function () {
3124 _super.prototype.destroy.call(this);
3125 this._resetIndexRange();
3126 };
3127 /**
3128 * Update {@link Control#controller controller}'s state
3129 * @ko {@link Control#controller controller}의 내부 상태를 갱신합니다
3130 * @chainable
3131 * @return {this}
3132 */
3133 __proto.updateInput = function () {
3134 var _a;
3135 var flicking = getFlickingAttached(this._flicking);
3136 var camera = flicking.camera;
3137 var renderer = flicking.renderer;
3138 var controller = this._controller;
3139 var controlParams = camera.controlParams;
3140 var count = this._count;
3141 var activePanel = controller.state.animating ? (_a = camera.findNearestAnchor(camera.position)) === null || _a === void 0 ? void 0 : _a.panel : this._activePanel;
3142 if (!activePanel) {
3143 controller.update(controlParams);
3144 this._resetIndexRange();
3145 return this;
3146 }
3147 var cameraRange = controlParams.range;
3148 var currentPos = activePanel.position;
3149 var currentIndex = activePanel.index;
3150 var panelCount = renderer.panelCount;
3151 var prevPanelIndex = currentIndex - count;
3152 var nextPanelIndex = currentIndex + count;
3153 if (prevPanelIndex < 0) {
3154 prevPanelIndex = flicking.circularEnabled ? getMinusCompensatedIndex((prevPanelIndex + 1) % panelCount - 1, panelCount) : clamp(prevPanelIndex, 0, panelCount - 1);
3155 }
3156 if (nextPanelIndex >= panelCount) {
3157 nextPanelIndex = flicking.circularEnabled ? nextPanelIndex % panelCount : clamp(nextPanelIndex, 0, panelCount - 1);
3158 }
3159 var prevPanel = renderer.panels[prevPanelIndex];
3160 var nextPanel = renderer.panels[nextPanelIndex];
3161 var prevPos = Math.max(prevPanel.position, cameraRange.min);
3162 var nextPos = Math.min(nextPanel.position, cameraRange.max);
3163 if (prevPos > currentPos) {
3164 prevPos -= camera.rangeDiff;
3165 }
3166 if (nextPos < currentPos) {
3167 nextPos += camera.rangeDiff;
3168 }
3169 controlParams.range = {
3170 min: prevPos,
3171 max: nextPos
3172 };
3173 if (controlParams.circular) {
3174 if (controlParams.position < prevPos) {
3175 controlParams.position += camera.rangeDiff;
3176 }
3177 if (controlParams.position > nextPos) {
3178 controlParams.position -= camera.rangeDiff;
3179 }
3180 }
3181 controlParams.circular = false;
3182 controller.update(controlParams);
3183 this._indexRange = {
3184 min: prevPanel.index,
3185 max: nextPanel.index
3186 };
3187 return this;
3188 };
3189 __proto.moveToPanel = function (panel, options) {
3190 return __awaiter(this, void 0, void 0, function () {
3191 var flicking, camera, controller;
3192 return __generator(this, function (_a) {
3193 flicking = getFlickingAttached(this._flicking);
3194 camera = flicking.camera;
3195 controller = this._controller;
3196 controller.update(camera.controlParams);
3197 return [2 /*return*/, _super.prototype.moveToPanel.call(this, panel, options)];
3198 });
3199 });
3200 };
3201 /**
3202 * Move {@link Camera} to the given position
3203 * @ko {@link Camera}를 주어진 좌표로 이동합니다
3204 * @param {number} position The target position to move<ko>이동할 좌표</ko>
3205 * @param {number} duration Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
3206 * @param {object} [axesEvent] {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of {@link https://naver.github.io/egjs-axes/ Axes}
3207 * <ko>{@link https://naver.github.io/egjs-axes/ Axes}의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
3208 * @fires Flicking#moveStart
3209 * @fires Flicking#move
3210 * @fires Flicking#moveEnd
3211 * @fires Flicking#willChange
3212 * @fires Flicking#changed
3213 * @fires Flicking#willRestore
3214 * @fires Flicking#restored
3215 * @fires Flicking#needPanel
3216 * @fires Flicking#visibleChange
3217 * @fires Flicking#reachEdge
3218 * @throws {FlickingError}
3219 * |code|condition|
3220 * |---|---|
3221 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
3222 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
3223 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
3224 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
3225 * <ko>
3226 *
3227 * |code|condition|
3228 * |---|---|
3229 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
3230 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
3231 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
3232 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
3233 *
3234 * </ko>
3235 * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
3236 */
3237 __proto.moveToPosition = function (position, duration, axesEvent) {
3238 var _a;
3239 var flicking = getFlickingAttached(this._flicking);
3240 var camera = flicking.camera;
3241 var currentPanel = (_a = this._nextPanel) !== null && _a !== void 0 ? _a : this._activePanel;
3242 var axesRange = this._controller.range;
3243 var indexRange = this._indexRange;
3244 var cameraRange = camera.range;
3245 var state = this._controller.state;
3246 var clampedPosition = clamp(camera.clampToReachablePosition(position), axesRange[0], axesRange[1]);
3247 var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
3248 if (!anchorAtPosition || !currentPanel) {
3249 return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
3250 }
3251 var prevPos = currentPanel.position;
3252 var posDelta = flicking.animating ? state.delta : position - camera.position;
3253 var isOverThreshold = Math.abs(posDelta) >= flicking.threshold;
3254 var adjacentAnchor = position > prevPos ? camera.getNextAnchor(anchorAtPosition) : camera.getPrevAnchor(anchorAtPosition);
3255 var targetPos;
3256 var targetPanel;
3257 var anchors = camera.anchorPoints;
3258 var firstAnchor = anchors[0];
3259 var lastAnchor = anchors[anchors.length - 1];
3260 var shouldBounceToFirst = position <= cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
3261 var shouldBounceToLast = position >= cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
3262 var isAdjacent = adjacentAnchor && (indexRange.min <= indexRange.max ? isBetween(adjacentAnchor.index, indexRange.min, indexRange.max) : adjacentAnchor.index >= indexRange.min || adjacentAnchor.index <= indexRange.max);
3263 if (shouldBounceToFirst || shouldBounceToLast) {
3264 // In bounce area
3265 var targetAnchor = position < cameraRange.min ? firstAnchor : lastAnchor;
3266 targetPanel = targetAnchor.panel;
3267 targetPos = targetAnchor.position;
3268 } else if (isOverThreshold && anchorAtPosition.position !== currentPanel.position) {
3269 // Move to anchor at position
3270 targetPanel = anchorAtPosition.panel;
3271 targetPos = anchorAtPosition.position;
3272 } else if (isOverThreshold && isAdjacent) {
3273 // Move to adjacent anchor
3274 targetPanel = adjacentAnchor.panel;
3275 targetPos = adjacentAnchor.position;
3276 } else {
3277 // Fallback to nearest panel from current camera
3278 var anchorAtCamera = camera.findNearestAnchor(camera.position);
3279 if (!anchorAtCamera) {
3280 return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
3281 }
3282 return this.moveToPanel(anchorAtCamera.panel, {
3283 duration: duration,
3284 axesEvent: axesEvent
3285 });
3286 }
3287 this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
3288 return this._animateToPosition({
3289 position: targetPos,
3290 duration: duration,
3291 newActivePanel: targetPanel,
3292 axesEvent: axesEvent
3293 });
3294 };
3295 __proto._resetIndexRange = function () {
3296 this._indexRange = {
3297 min: 0,
3298 max: 0
3299 };
3300 };
3301 return StrictControl;
3302}(Control);
3303
3304/**
3305 * A mode of camera
3306 */
3307var CameraMode = /*#__PURE__*/function () {
3308 /** */
3309 function CameraMode(flicking) {
3310 this._flicking = flicking;
3311 }
3312 var __proto = CameraMode.prototype;
3313 __proto.getAnchors = function () {
3314 var panels = this._flicking.renderer.panels;
3315 return panels.map(function (panel, index) {
3316 return new AnchorPoint({
3317 index: index,
3318 position: panel.position,
3319 panel: panel
3320 });
3321 });
3322 };
3323 __proto.findAnchorIncludePosition = function (position) {
3324 var anchors = this._flicking.camera.anchorPoints;
3325 var anchorsIncludingPosition = anchors.filter(function (anchor) {
3326 return anchor.panel.includePosition(position, true);
3327 });
3328 return anchorsIncludingPosition.reduce(function (nearest, anchor) {
3329 if (!nearest) return anchor;
3330 return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3331 }, null);
3332 };
3333 __proto.findNearestAnchor = function (position) {
3334 var anchors = this._flicking.camera.anchorPoints;
3335 if (anchors.length <= 0) return null;
3336 var prevDist = Infinity;
3337 for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
3338 var anchor = anchors[anchorIdx];
3339 var dist = Math.abs(anchor.position - position);
3340 if (dist > prevDist) {
3341 // Return previous anchor
3342 return anchors[anchorIdx - 1];
3343 }
3344 prevDist = dist;
3345 }
3346 // Return last anchor
3347 return anchors[anchors.length - 1];
3348 };
3349 __proto.clampToReachablePosition = function (position) {
3350 var camera = this._flicking.camera;
3351 var range = camera.range;
3352 return clamp(position, range.min, range.max);
3353 };
3354 __proto.getCircularOffset = function () {
3355 return 0;
3356 };
3357 __proto.canReach = function (panel) {
3358 var camera = this._flicking.camera;
3359 var range = camera.range;
3360 if (panel.removed) return false;
3361 var panelPos = panel.position;
3362 return panelPos >= range.min && panelPos <= range.max;
3363 };
3364 __proto.canSee = function (panel) {
3365 var camera = this._flicking.camera;
3366 var visibleRange = camera.visibleRange;
3367 // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
3368 return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
3369 };
3370 return CameraMode;
3371}();
3372
3373var LinearCameraMode = /*#__PURE__*/function (_super) {
3374 __extends(LinearCameraMode, _super);
3375 function LinearCameraMode() {
3376 return _super !== null && _super.apply(this, arguments) || this;
3377 }
3378 var __proto = LinearCameraMode.prototype;
3379 __proto.checkAvailability = function () {
3380 // It's always available
3381 return true;
3382 };
3383 __proto.getRange = function () {
3384 var _a, _b;
3385 var renderer = this._flicking.renderer;
3386 var firstPanel = renderer.getPanel(0);
3387 var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3388 return {
3389 min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
3390 max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
3391 };
3392 };
3393 return LinearCameraMode;
3394}(CameraMode);
3395
3396/**
3397 * A {@link Camera} mode that connects the last panel and the first panel, enabling continuous loop
3398 * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera} 모드
3399 */
3400var CircularCameraMode = /*#__PURE__*/function (_super) {
3401 __extends(CircularCameraMode, _super);
3402 function CircularCameraMode() {
3403 return _super !== null && _super.apply(this, arguments) || this;
3404 }
3405 var __proto = CircularCameraMode.prototype;
3406 __proto.checkAvailability = function () {
3407 var flicking = this._flicking;
3408 var renderer = flicking.renderer;
3409 var panels = renderer.panels;
3410 if (panels.length <= 0) {
3411 return false;
3412 }
3413 var firstPanel = panels[0];
3414 var lastPanel = panels[panels.length - 1];
3415 var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
3416 var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
3417 var visibleSize = flicking.camera.size;
3418 var panelSizeSum = lastPanelNext - firstPanelPrev;
3419 var canSetCircularMode = panels.every(function (panel) {
3420 return panelSizeSum - panel.size >= visibleSize;
3421 });
3422 return canSetCircularMode;
3423 };
3424 __proto.getRange = function () {
3425 var flicking = this._flicking;
3426 var panels = flicking.renderer.panels;
3427 if (panels.length <= 0) {
3428 return {
3429 min: 0,
3430 max: 0
3431 };
3432 }
3433 var firstPanel = panels[0];
3434 var lastPanel = panels[panels.length - 1];
3435 var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
3436 var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
3437 return {
3438 min: firstPanelPrev,
3439 max: lastPanelNext
3440 };
3441 };
3442 __proto.getAnchors = function () {
3443 var flicking = this._flicking;
3444 var panels = flicking.renderer.panels;
3445 return panels.map(function (panel, index) {
3446 return new AnchorPoint({
3447 index: index,
3448 position: panel.position,
3449 panel: panel
3450 });
3451 });
3452 };
3453 __proto.findNearestAnchor = function (position) {
3454 var camera = this._flicking.camera;
3455 var anchors = camera.anchorPoints;
3456 if (anchors.length <= 0) return null;
3457 var camRange = camera.range;
3458 var minDist = Infinity;
3459 var minDistIndex = -1;
3460 for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
3461 var anchor = anchors[anchorIdx];
3462 var dist = Math.min(Math.abs(anchor.position - position), Math.abs(anchor.position - camRange.min + camRange.max - position), Math.abs(position - camRange.min + camRange.max - anchor.position));
3463 if (dist < minDist) {
3464 minDist = dist;
3465 minDistIndex = anchorIdx;
3466 }
3467 }
3468 // Return last anchor
3469 return anchors[minDistIndex];
3470 };
3471 __proto.findAnchorIncludePosition = function (position) {
3472 var camera = this._flicking.camera;
3473 var range = camera.range;
3474 var anchors = camera.anchorPoints;
3475 var rangeDiff = camera.rangeDiff;
3476 var anchorCount = anchors.length;
3477 var positionInRange = circulatePosition(position, range.min, range.max);
3478 var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
3479 if (anchorCount > 0 && (position === range.min || position === range.max)) {
3480 var possibleAnchors = [anchorInRange, new AnchorPoint({
3481 index: 0,
3482 position: anchors[0].position + rangeDiff,
3483 panel: anchors[0].panel
3484 }), new AnchorPoint({
3485 index: anchorCount - 1,
3486 position: anchors[anchorCount - 1].position - rangeDiff,
3487 panel: anchors[anchorCount - 1].panel
3488 })].filter(function (anchor) {
3489 return !!anchor;
3490 });
3491 anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
3492 if (!nearest) return anchor;
3493 return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3494 }, null);
3495 }
3496 if (!anchorInRange) return null;
3497 if (position < range.min) {
3498 var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
3499 return new AnchorPoint({
3500 index: anchorInRange.index,
3501 position: anchorInRange.position + rangeDiff * loopCount,
3502 panel: anchorInRange.panel
3503 });
3504 } else if (position > range.max) {
3505 var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
3506 return new AnchorPoint({
3507 index: anchorInRange.index,
3508 position: anchorInRange.position + rangeDiff * loopCount,
3509 panel: anchorInRange.panel
3510 });
3511 }
3512 return anchorInRange;
3513 };
3514 __proto.getCircularOffset = function () {
3515 var flicking = this._flicking;
3516 var camera = flicking.camera;
3517 if (!camera.circularEnabled) return 0;
3518 var toggled = flicking.panels.filter(function (panel) {
3519 return panel.toggled;
3520 });
3521 var toggledPrev = toggled.filter(function (panel) {
3522 return panel.toggleDirection === DIRECTION.PREV;
3523 });
3524 var toggledNext = toggled.filter(function (panel) {
3525 return panel.toggleDirection === DIRECTION.NEXT;
3526 });
3527 return this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
3528 };
3529 __proto.clampToReachablePosition = function (position) {
3530 // Basically all position is reachable for circular camera
3531 return position;
3532 };
3533 __proto.canReach = function (panel) {
3534 if (panel.removed) return false;
3535 // Always reachable on circular mode
3536 return true;
3537 };
3538 __proto.canSee = function (panel) {
3539 var camera = this._flicking.camera;
3540 var range = camera.range;
3541 var rangeDiff = camera.rangeDiff;
3542 var visibleRange = camera.visibleRange;
3543 var visibleInCurrentRange = _super.prototype.canSee.call(this, panel);
3544 // Check looped visible area for circular case
3545 if (visibleRange.min < range.min) {
3546 return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
3547 } else if (visibleRange.max > range.max) {
3548 return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
3549 }
3550 return visibleInCurrentRange;
3551 };
3552 __proto._calcPanelAreaSum = function (panels) {
3553 return panels.reduce(function (sum, panel) {
3554 return sum + panel.sizeIncludingMargin;
3555 }, 0);
3556 };
3557 return CircularCameraMode;
3558}(CameraMode);
3559
3560var BoundCameraMode = /*#__PURE__*/function (_super) {
3561 __extends(BoundCameraMode, _super);
3562 function BoundCameraMode() {
3563 return _super !== null && _super.apply(this, arguments) || this;
3564 }
3565 var __proto = BoundCameraMode.prototype;
3566 __proto.checkAvailability = function () {
3567 var flicking = this._flicking;
3568 var renderer = flicking.renderer;
3569 var firstPanel = renderer.getPanel(0);
3570 var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3571 if (!firstPanel || !lastPanel) {
3572 return false;
3573 }
3574 var viewportSize = flicking.camera.size;
3575 var firstPanelPrev = firstPanel.range.min;
3576 var lastPanelNext = lastPanel.range.max;
3577 var panelAreaSize = lastPanelNext - firstPanelPrev;
3578 var isBiggerThanViewport = viewportSize < panelAreaSize;
3579 return isBiggerThanViewport;
3580 };
3581 __proto.getRange = function () {
3582 var flicking = this._flicking;
3583 var renderer = flicking.renderer;
3584 var alignPos = flicking.camera.alignPosition;
3585 var firstPanel = renderer.getPanel(0);
3586 var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3587 if (!firstPanel || !lastPanel) {
3588 return {
3589 min: 0,
3590 max: 0
3591 };
3592 }
3593 var viewportSize = flicking.camera.size;
3594 var firstPanelPrev = firstPanel.range.min;
3595 var lastPanelNext = lastPanel.range.max;
3596 var panelAreaSize = lastPanelNext - firstPanelPrev;
3597 var isBiggerThanViewport = viewportSize < panelAreaSize;
3598 var firstPos = firstPanelPrev + alignPos;
3599 var lastPos = lastPanelNext - viewportSize + alignPos;
3600 if (isBiggerThanViewport) {
3601 return {
3602 min: firstPos,
3603 max: lastPos
3604 };
3605 } else {
3606 var align = flicking.camera.align;
3607 var alignVal = typeof align === "object" ? align.camera : align;
3608 var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
3609 return {
3610 min: pos,
3611 max: pos
3612 };
3613 }
3614 };
3615 __proto.getAnchors = function () {
3616 var flicking = this._flicking;
3617 var camera = flicking.camera;
3618 var panels = flicking.renderer.panels;
3619 if (panels.length <= 0) {
3620 return [];
3621 }
3622 var range = flicking.camera.range;
3623 var reachablePanels = panels.filter(function (panel) {
3624 return camera.canReach(panel);
3625 });
3626 if (reachablePanels.length > 0) {
3627 var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
3628 var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
3629 var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
3630 var newAnchors = reachablePanels.map(function (panel, idx) {
3631 return new AnchorPoint({
3632 index: idx + indexOffset_1,
3633 position: panel.position,
3634 panel: panel
3635 });
3636 });
3637 if (shouldPrependBoundAnchor) {
3638 newAnchors.splice(0, 0, new AnchorPoint({
3639 index: 0,
3640 position: range.min,
3641 panel: panels[reachablePanels[0].index - 1]
3642 }));
3643 }
3644 if (shouldAppendBoundAnchor) {
3645 newAnchors.push(new AnchorPoint({
3646 index: newAnchors.length,
3647 position: range.max,
3648 panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
3649 }));
3650 }
3651 return newAnchors;
3652 } else if (range.min !== range.max) {
3653 // There're more than 2 panels
3654 var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
3655 var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
3656 var panelAtMax = panelAtMin.next();
3657 return [new AnchorPoint({
3658 index: 0,
3659 position: range.min,
3660 panel: panelAtMin
3661 }), new AnchorPoint({
3662 index: 1,
3663 position: range.max,
3664 panel: panelAtMax
3665 })];
3666 } else {
3667 return [new AnchorPoint({
3668 index: 0,
3669 position: range.min,
3670 panel: this._findNearestPanel(range.min, panels)
3671 })];
3672 }
3673 };
3674 __proto.findAnchorIncludePosition = function (position) {
3675 var camera = this._flicking.camera;
3676 var range = camera.range;
3677 var anchors = camera.anchorPoints;
3678 if (anchors.length <= 0) return null;
3679 if (position <= range.min) {
3680 return anchors[0];
3681 } else if (position >= range.max) {
3682 return anchors[anchors.length - 1];
3683 } else {
3684 return _super.prototype.findAnchorIncludePosition.call(this, position);
3685 }
3686 };
3687 __proto._findNearestPanel = function (pos, panels) {
3688 var prevDist = Infinity;
3689 for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
3690 var panel = panels[panelIdx];
3691 var dist = Math.abs(panel.position - pos);
3692 if (dist > prevDist) {
3693 // Return previous anchor
3694 return panels[panelIdx - 1];
3695 }
3696 prevDist = dist;
3697 }
3698 // Return last anchor
3699 return panels[panels.length - 1];
3700 };
3701 return BoundCameraMode;
3702}(CameraMode);
3703
3704/**
3705 * A component that manages actual movement inside the viewport
3706 * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
3707 */
3708var Camera = /*#__PURE__*/function () {
3709 /** */
3710 function Camera(flicking, _a) {
3711 var _this = this;
3712 var _b = (_a === void 0 ? {} : _a).align,
3713 align = _b === void 0 ? ALIGN.CENTER : _b;
3714 this._checkTranslateSupport = function () {
3715 var e_1, _a;
3716 var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
3717 var supportedStyle = document.documentElement.style;
3718 var transformName = "";
3719 try {
3720 for (var transforms_1 = __values(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
3721 var prefixedTransform = transforms_1_1.value;
3722 if (prefixedTransform in supportedStyle) {
3723 transformName = prefixedTransform;
3724 }
3725 }
3726 } catch (e_1_1) {
3727 e_1 = {
3728 error: e_1_1
3729 };
3730 } finally {
3731 try {
3732 if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
3733 } finally {
3734 if (e_1) throw e_1.error;
3735 }
3736 }
3737 if (!transformName) {
3738 throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
3739 }
3740 _this._transform = transformName;
3741 };
3742 this._flicking = flicking;
3743 this._resetInternalValues();
3744 // Options
3745 this._align = align;
3746 }
3747 var __proto = Camera.prototype;
3748 Object.defineProperty(__proto, "element", {
3749 // Internal states getter
3750 /**
3751 * The camera element(`.flicking-camera`)
3752 * @ko 카메라 엘리먼트(`.flicking-camera`)
3753 * @type {HTMLElement}
3754 * @readonly
3755 */
3756 get: function () {
3757 return this._el;
3758 },
3759 enumerable: false,
3760 configurable: true
3761 });
3762 Object.defineProperty(__proto, "children", {
3763 /**
3764 * An array of the child elements of the camera element(`.flicking-camera`)
3765 * @ko 카메라 엘리먼트(`.flicking-camera`)의 자식 엘리먼트 배열
3766 * @type {HTMLElement[]}
3767 * @readonly
3768 */
3769 get: function () {
3770 return toArray(this._el.children);
3771 },
3772 enumerable: false,
3773 configurable: true
3774 });
3775 Object.defineProperty(__proto, "position", {
3776 /**
3777 * Current position of the camera
3778 * @ko Camera의 현재 좌표
3779 * @type {number}
3780 * @readonly
3781 */
3782 get: function () {
3783 return this._position;
3784 },
3785 enumerable: false,
3786 configurable: true
3787 });
3788 Object.defineProperty(__proto, "alignPosition", {
3789 /**
3790 * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
3791 * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
3792 * @type {number}
3793 * @readonly
3794 */
3795 get: function () {
3796 return this._alignPos;
3797 },
3798 enumerable: false,
3799 configurable: true
3800 });
3801 Object.defineProperty(__proto, "offset", {
3802 /**
3803 * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
3804 * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
3805 * @type {number}
3806 * @default 0
3807 * @readonly
3808 */
3809 get: function () {
3810 return this._offset - this._circularOffset;
3811 },
3812 enumerable: false,
3813 configurable: true
3814 });
3815 Object.defineProperty(__proto, "circularEnabled", {
3816 /**
3817 * Whether the `circular` option is enabled.
3818 * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
3819 * @ko {@link Flicking#circular circular} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
3820 * {@link Flicking#circular circular} 옵션은 패널의 크기의 합이 충분하지 않을 경우 비활성화됩니다.
3821 * @type {boolean}
3822 * @default false
3823 * @readonly
3824 */
3825 get: function () {
3826 return this._circularEnabled;
3827 },
3828 enumerable: false,
3829 configurable: true
3830 });
3831 Object.defineProperty(__proto, "mode", {
3832 /**
3833 * A current camera mode
3834 * @type {CameraMode}
3835 * @readonly
3836 */
3837 get: function () {
3838 return this._mode;
3839 },
3840 enumerable: false,
3841 configurable: true
3842 });
3843 Object.defineProperty(__proto, "range", {
3844 /**
3845 * A range that Camera's {@link Camera#position position} can reach
3846 * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
3847 * @type {object}
3848 * @property {number} min A minimum position<ko>최소 위치</ko>
3849 * @property {number} max A maximum position<ko>최대 위치</ko>
3850 * @readonly
3851 */
3852 get: function () {
3853 return this._range;
3854 },
3855 enumerable: false,
3856 configurable: true
3857 });
3858 Object.defineProperty(__proto, "rangeDiff", {
3859 /**
3860 * A difference between Camera's minimum and maximum position that can reach
3861 * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
3862 * @type {number}
3863 * @readonly
3864 */
3865 get: function () {
3866 return this._range.max - this._range.min;
3867 },
3868 enumerable: false,
3869 configurable: true
3870 });
3871 Object.defineProperty(__proto, "visiblePanels", {
3872 /**
3873 * An array of visible panels from the current position
3874 * @ko 현재 보이는 패널들의 배열
3875 * @type {Panel[]}
3876 * @readonly
3877 */
3878 get: function () {
3879 return this._visiblePanels;
3880 },
3881 enumerable: false,
3882 configurable: true
3883 });
3884 Object.defineProperty(__proto, "visibleRange", {
3885 /**
3886 * A range of the visible area from the current position
3887 * @ko 현재 위치에서 보이는 범위
3888 * @type {object}
3889 * @property {number} min A minimum position<ko>최소 위치</ko>
3890 * @property {number} min A maximum position<ko>최대 위치</ko>
3891 * @readonly
3892 */
3893 get: function () {
3894 return {
3895 min: this._position - this._alignPos,
3896 max: this._position - this._alignPos + this.size
3897 };
3898 },
3899 enumerable: false,
3900 configurable: true
3901 });
3902 Object.defineProperty(__proto, "anchorPoints", {
3903 /**
3904 * An array of {@link AnchorPoint}s that Camera can be stopped at
3905 * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
3906 * @type {AnchorPoint[]}
3907 * @readonly
3908 */
3909 get: function () {
3910 return this._anchors;
3911 },
3912 enumerable: false,
3913 configurable: true
3914 });
3915 Object.defineProperty(__proto, "controlParams", {
3916 /**
3917 * A current parameters of the Camera for updating {@link AxesController}
3918 * @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
3919 * @type {ControlParams}
3920 * @readonly
3921 */
3922 get: function () {
3923 return {
3924 range: this._range,
3925 position: this._position,
3926 circular: this._circularEnabled
3927 };
3928 },
3929 enumerable: false,
3930 configurable: true
3931 });
3932 Object.defineProperty(__proto, "atEdge", {
3933 /**
3934 * A Boolean value indicating whether Camera's over the minimum or maximum position reachable
3935 * @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
3936 * @type {boolean}
3937 * @readonly
3938 */
3939 get: function () {
3940 return this._position <= this._range.min || this._position >= this._range.max;
3941 },
3942 enumerable: false,
3943 configurable: true
3944 });
3945 Object.defineProperty(__proto, "size", {
3946 /**
3947 * Return the size of the viewport
3948 * @ko 뷰포트 크기를 반환합니다
3949 * @type {number}
3950 * @readonly
3951 */
3952 get: function () {
3953 var flicking = this._flicking;
3954 return flicking ? flicking.horizontal ? flicking.viewport.width : flicking.viewport.height : 0;
3955 },
3956 enumerable: false,
3957 configurable: true
3958 });
3959 Object.defineProperty(__proto, "progress", {
3960 /**
3961 * Return the camera's position progress from the first panel to last panel
3962 * Range is from 0 to last panel's index
3963 * @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
3964 * 범위는 0부터 마지막 패널의 인덱스까지입니다
3965 * @type {number}
3966 * @readonly
3967 */
3968 get: function () {
3969 var flicking = this._flicking;
3970 var position = this._position + this._offset;
3971 var nearestAnchor = this.findNearestAnchor(this._position);
3972 if (!flicking || !nearestAnchor) {
3973 return NaN;
3974 }
3975 var nearestPanel = nearestAnchor.panel;
3976 var panelPos = nearestPanel.position + nearestPanel.offset;
3977 var bounceSize = flicking.control.controller.bounce;
3978 var _a = this.range,
3979 prevRange = _a.min,
3980 nextRange = _a.max;
3981 var rangeDiff = this.rangeDiff;
3982 if (position === panelPos) {
3983 return nearestPanel.index;
3984 }
3985 if (position < panelPos) {
3986 var prevPanel = nearestPanel.prev();
3987 var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0];
3988 // Looped
3989 if (prevPosition > panelPos) {
3990 prevPosition -= rangeDiff;
3991 }
3992 return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
3993 } else {
3994 var nextPanel = nearestPanel.next();
3995 var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1];
3996 // Looped
3997 if (nextPosition < panelPos) {
3998 nextPosition += rangeDiff;
3999 }
4000 return nearestPanel.index + getProgress(position, panelPos, nextPosition);
4001 }
4002 },
4003 enumerable: false,
4004 configurable: true
4005 });
4006 Object.defineProperty(__proto, "panelOrder", {
4007 /**
4008 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element(`.flicking-camera`)
4009 * @ko 카메라 엘리먼트(`.flicking-camera`)에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성
4010 * @type {string}
4011 * @readonly
4012 */
4013 get: function () {
4014 return this._panelOrder;
4015 },
4016 enumerable: false,
4017 configurable: true
4018 });
4019 Object.defineProperty(__proto, "align", {
4020 // Options Getter
4021 /**
4022 * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
4023 * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
4024 * @type {ALIGN | string | number}
4025 */
4026 get: function () {
4027 return this._align;
4028 },
4029 // Options Setter
4030 set: function (val) {
4031 this._align = val;
4032 },
4033 enumerable: false,
4034 configurable: true
4035 });
4036 /**
4037 * Initialize Camera
4038 * @ko Camera를 초기화합니다
4039 * @throws {FlickingError}
4040 * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
4041 * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
4042 * @return {this}
4043 */
4044 __proto.init = function () {
4045 var viewportEl = this._flicking.viewport.element;
4046 checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
4047 this._el = viewportEl.firstElementChild;
4048 this._checkTranslateSupport();
4049 this._updateMode();
4050 this.updatePanelOrder();
4051 return this;
4052 };
4053 /**
4054 * Destroy Camera and return to initial state
4055 * @ko Camera를 초기 상태로 되돌립니다
4056 * @return {void}
4057 */
4058 __proto.destroy = function () {
4059 this._resetInternalValues();
4060 return this;
4061 };
4062 /**
4063 * Move to the given position and apply CSS transform
4064 * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
4065 * @param {number} pos A new position<ko>움직일 위치</ko>
4066 * @throws {FlickingError}
4067 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4068 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4069 * @return {this}
4070 */
4071 __proto.lookAt = function (pos) {
4072 var _this = this;
4073 var flicking = getFlickingAttached(this._flicking);
4074 var prevPos = this._position;
4075 this._position = pos;
4076 var toggled = this._togglePanels(prevPos, pos);
4077 this._refreshVisiblePanels();
4078 this._checkNeedPanel();
4079 this._checkReachEnd(prevPos, pos);
4080 if (toggled) {
4081 void flicking.renderer.render().then(function () {
4082 _this.updateOffset();
4083 });
4084 } else {
4085 this.applyTransform();
4086 }
4087 };
4088 /**
4089 * Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
4090 * If it does not exist, return `null` instead
4091 * @ko 주어진 {@link AnchorPoint}의 이전 {@link AnchorPoint}를 반환합니다
4092 * 존재하지 않을 경우 `null`을 반환합니다
4093 * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
4094 * @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
4095 */
4096 __proto.getPrevAnchor = function (anchor) {
4097 if (!this._circularEnabled || anchor.index !== 0) {
4098 return this._anchors[anchor.index - 1] || null;
4099 } else {
4100 var anchors = this._anchors;
4101 var rangeDiff = this.rangeDiff;
4102 var lastAnchor = anchors[anchors.length - 1];
4103 return new AnchorPoint({
4104 index: lastAnchor.index,
4105 position: lastAnchor.position - rangeDiff,
4106 panel: lastAnchor.panel
4107 });
4108 }
4109 };
4110 /**
4111 * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
4112 * If it does not exist, return `null` instead
4113 * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
4114 * 존재하지 않을 경우 `null`을 반환합니다
4115 * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
4116 * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
4117 */
4118 __proto.getNextAnchor = function (anchor) {
4119 var anchors = this._anchors;
4120 if (!this._circularEnabled || anchor.index !== anchors.length - 1) {
4121 return anchors[anchor.index + 1] || null;
4122 } else {
4123 var rangeDiff = this.rangeDiff;
4124 var firstAnchor = anchors[0];
4125 return new AnchorPoint({
4126 index: firstAnchor.index,
4127 position: firstAnchor.position + rangeDiff,
4128 panel: firstAnchor.panel
4129 });
4130 }
4131 };
4132 /**
4133 * Return the camera's position progress in the panel below
4134 * Value is from 0 to 1 when the camera's inside panel
4135 * Value can be lower than 0 or bigger than 1 when it's in the margin area
4136 * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
4137 * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
4138 * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
4139 */
4140 __proto.getProgressInPanel = function (panel) {
4141 var panelRange = panel.range;
4142 return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
4143 };
4144 /**
4145 * Return {@link AnchorPoint} that includes given position
4146 * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
4147 * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
4148 * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
4149 * @param {number} position A position to check<ko>확인할 좌표</ko>
4150 * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
4151 */
4152 __proto.findAnchorIncludePosition = function (position) {
4153 return this._mode.findAnchorIncludePosition(position);
4154 };
4155 /**
4156 * Return {@link AnchorPoint} nearest to given position
4157 * If there're no {@link AnchorPoint}s, return `null` instead
4158 * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
4159 * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
4160 * @param {number} position A position to check<ko>확인할 좌표</ko>
4161 * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
4162 */
4163 __proto.findNearestAnchor = function (position) {
4164 return this._mode.findNearestAnchor(position);
4165 };
4166 /**
4167 * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
4168 * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
4169 * @return {AnchorPoint | null}
4170 */
4171 __proto.findActiveAnchor = function () {
4172 var _a;
4173 var flicking = getFlickingAttached(this._flicking);
4174 var activePanel = flicking.control.activePanel;
4175 if (!activePanel) return null;
4176 return (_a = find(this._anchors, function (anchor) {
4177 return anchor.panel.index === activePanel.index;
4178 })) !== null && _a !== void 0 ? _a : this.findNearestAnchor(activePanel.position);
4179 };
4180 /**
4181 * Clamp the given position between camera's range
4182 * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
4183 * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
4184 * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
4185 */
4186 __proto.clampToReachablePosition = function (position) {
4187 return this._mode.clampToReachablePosition(position);
4188 };
4189 /**
4190 * Check whether the given panel is inside of the Camera's range
4191 * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
4192 * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4193 * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
4194 */
4195 __proto.canReach = function (panel) {
4196 return this._mode.canReach(panel);
4197 };
4198 /**
4199 * Check whether the given panel element is visible at the current position
4200 * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
4201 * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4202 * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
4203 */
4204 __proto.canSee = function (panel) {
4205 return this._mode.canSee(panel);
4206 };
4207 /**
4208 * Update {@link Camera#range range} of Camera
4209 * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4210 * @method
4211 * @abstract
4212 * @memberof Camera
4213 * @instance
4214 * @name updateRange
4215 * @chainable
4216 * @throws {FlickingError}
4217 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4218 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4219 * @return {this}
4220 */
4221 __proto.updateRange = function () {
4222 var flicking = getFlickingAttached(this._flicking);
4223 var renderer = flicking.renderer;
4224 var panels = renderer.panels;
4225 this._updateMode();
4226 this._range = this._mode.getRange();
4227 panels.forEach(function (panel) {
4228 return panel.updateCircularToggleDirection();
4229 });
4230 return this;
4231 };
4232 /**
4233 * Update Camera's {@link Camera#alignPosition alignPosition}
4234 * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
4235 * @chainable
4236 * @return {this}
4237 */
4238 __proto.updateAlignPos = function () {
4239 var align = this._align;
4240 var alignVal = typeof align === "object" ? align.camera : align;
4241 this._alignPos = parseAlign$1(alignVal, this.size);
4242 return this;
4243 };
4244 /**
4245 * Update Camera's {@link Camera#anchorPoints anchorPoints}
4246 * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
4247 * @throws {FlickingError}
4248 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4249 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4250 * @chainable
4251 * @return {this}
4252 */
4253 __proto.updateAnchors = function () {
4254 this._anchors = this._mode.getAnchors();
4255 return this;
4256 };
4257 /**
4258 * Update Viewport's height to active panel's height
4259 * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4260 * @throws {FlickingError}
4261 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4262 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4263 * @chainable
4264 * @return {this}
4265 */
4266 __proto.updateAdaptiveHeight = function () {
4267 var flicking = getFlickingAttached(this._flicking);
4268 var activePanel = flicking.control.activePanel;
4269 if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4270 flicking.viewport.setSize({
4271 height: activePanel.height
4272 });
4273 };
4274 /**
4275 * Update current offset of the camera
4276 * @ko 현재 카메라의 오프셋을 업데이트합니다
4277 * @chainable
4278 * @return {this}
4279 */
4280 __proto.updateOffset = function () {
4281 var flicking = getFlickingAttached(this._flicking);
4282 var position = this._position;
4283 var unRenderedPanels = flicking.panels.filter(function (panel) {
4284 return !panel.rendered;
4285 });
4286 this._offset = unRenderedPanels.filter(function (panel) {
4287 return panel.position + panel.offset < position;
4288 }).reduce(function (offset, panel) {
4289 return offset + panel.sizeIncludingMargin;
4290 }, 0);
4291 this._circularOffset = this._mode.getCircularOffset();
4292 this.applyTransform();
4293 return this;
4294 };
4295 /**
4296 * Update direction to match the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS property applied to the camera element
4297 * @ko 카메라 엘리먼트에 적용된 {@link https://developer.mozilla.org/en-US/docs/Web/CSS/direction direction} CSS 속성에 맞게 방향을 업데이트합니다
4298 * @return {this}
4299 */
4300 __proto.updatePanelOrder = function () {
4301 var flicking = getFlickingAttached(this._flicking);
4302 if (!flicking.horizontal) return this;
4303 var el = this._el;
4304 var direction = getStyle(el).direction;
4305 if (direction !== this._panelOrder) {
4306 this._panelOrder = direction === ORDER.RTL ? ORDER.RTL : ORDER.LTR;
4307 if (flicking.initialized) {
4308 flicking.control.controller.updateDirection();
4309 }
4310 }
4311 return this;
4312 };
4313 /**
4314 * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4315 * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
4316 * @chainable
4317 * @return {this}
4318 */
4319 __proto.resetNeedPanelHistory = function () {
4320 this._needPanelTriggered = {
4321 prev: false,
4322 next: false
4323 };
4324 return this;
4325 };
4326 /**
4327 * Apply "transform" style with the current position to camera element
4328 * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
4329 * @return {this}
4330 */
4331 __proto.applyTransform = function () {
4332 var el = this._el;
4333 var flicking = getFlickingAttached(this._flicking);
4334 var renderer = flicking.renderer;
4335 if (renderer.rendering || !flicking.initialized) return this;
4336 var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4337 el.style[this._transform] = flicking.horizontal ? "translate(" + (this._panelOrder === ORDER.RTL ? actualPosition : -actualPosition) + "px)" : "translate(0, " + -actualPosition + "px)";
4338 return this;
4339 };
4340 __proto._resetInternalValues = function () {
4341 this._position = 0;
4342 this._alignPos = 0;
4343 this._offset = 0;
4344 this._circularOffset = 0;
4345 this._circularEnabled = false;
4346 this._range = {
4347 min: 0,
4348 max: 0
4349 };
4350 this._visiblePanels = [];
4351 this._anchors = [];
4352 this._needPanelTriggered = {
4353 prev: false,
4354 next: false
4355 };
4356 };
4357 __proto._refreshVisiblePanels = function () {
4358 var _this = this;
4359 var flicking = getFlickingAttached(this._flicking);
4360 var panels = flicking.renderer.panels;
4361 var newVisiblePanels = panels.filter(function (panel) {
4362 return _this.canSee(panel);
4363 });
4364 var prevVisiblePanels = this._visiblePanels;
4365 this._visiblePanels = newVisiblePanels;
4366 var added = newVisiblePanels.filter(function (panel) {
4367 return !includes(prevVisiblePanels, panel);
4368 });
4369 var removed = prevVisiblePanels.filter(function (panel) {
4370 return !includes(newVisiblePanels, panel);
4371 });
4372 if (added.length > 0 || removed.length > 0) {
4373 void flicking.renderer.render().then(function () {
4374 flicking.trigger(new ComponentEvent(EVENTS.VISIBLE_CHANGE, {
4375 added: added,
4376 removed: removed,
4377 visiblePanels: newVisiblePanels
4378 }));
4379 });
4380 }
4381 };
4382 __proto._checkNeedPanel = function () {
4383 var needPanelTriggered = this._needPanelTriggered;
4384 if (needPanelTriggered.prev && needPanelTriggered.next) return;
4385 var flicking = getFlickingAttached(this._flicking);
4386 var panels = flicking.renderer.panels;
4387 if (panels.length <= 0) {
4388 if (!needPanelTriggered.prev) {
4389 flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4390 direction: DIRECTION.PREV
4391 }));
4392 needPanelTriggered.prev = true;
4393 }
4394 if (!needPanelTriggered.next) {
4395 flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4396 direction: DIRECTION.NEXT
4397 }));
4398 needPanelTriggered.next = true;
4399 }
4400 return;
4401 }
4402 var cameraPosition = this._position;
4403 var cameraSize = this.size;
4404 var cameraRange = this._range;
4405 var needPanelThreshold = flicking.needPanelThreshold;
4406 var cameraPrev = cameraPosition - this._alignPos;
4407 var cameraNext = cameraPrev + cameraSize;
4408 var firstPanel = panels[0];
4409 var lastPanel = panels[panels.length - 1];
4410 if (!needPanelTriggered.prev) {
4411 var firstPanelPrev = firstPanel.range.min;
4412 if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
4413 flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4414 direction: DIRECTION.PREV
4415 }));
4416 needPanelTriggered.prev = true;
4417 }
4418 }
4419 if (!needPanelTriggered.next) {
4420 var lastPanelNext = lastPanel.range.max;
4421 if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
4422 flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4423 direction: DIRECTION.NEXT
4424 }));
4425 needPanelTriggered.next = true;
4426 }
4427 }
4428 };
4429 __proto._checkReachEnd = function (prevPos, newPos) {
4430 var flicking = getFlickingAttached(this._flicking);
4431 var range = this._range;
4432 var wasBetweenRange = prevPos > range.min && prevPos < range.max;
4433 var isBetweenRange = newPos > range.min && newPos < range.max;
4434 if (!wasBetweenRange || isBetweenRange) return;
4435 var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
4436 flicking.trigger(new ComponentEvent(EVENTS.REACH_EDGE, {
4437 direction: direction
4438 }));
4439 };
4440 __proto._updateMode = function () {
4441 var flicking = getFlickingAttached(this._flicking);
4442 if (flicking.circular) {
4443 var circularMode = new CircularCameraMode(flicking);
4444 var canSetCircularMode = circularMode.checkAvailability();
4445 if (canSetCircularMode) {
4446 this._mode = circularMode;
4447 } else {
4448 var fallbackMode = flicking.circularFallback;
4449 this._mode = fallbackMode === CIRCULAR_FALLBACK.BOUND ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
4450 }
4451 this._circularEnabled = canSetCircularMode;
4452 } else {
4453 this._mode = flicking.bound ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
4454 this._circularEnabled = false;
4455 }
4456 };
4457 __proto._togglePanels = function (prevPos, pos) {
4458 if (pos === prevPos) return false;
4459 var flicking = getFlickingAttached(this._flicking);
4460 var panels = flicking.renderer.panels;
4461 var toggled = panels.map(function (panel) {
4462 return panel.toggle(prevPos, pos);
4463 });
4464 return toggled.some(function (isToggled) {
4465 return isToggled;
4466 });
4467 };
4468 return Camera;
4469}();
4470
4471/**
4472 * A component that manages {@link Panel} and its elements
4473 * @ko {@link Panel}과 그 엘리먼트들을 관리하는 컴포넌트
4474 */
4475var Renderer = /*#__PURE__*/function () {
4476 /**
4477 * @param {object} options An options object<ko>옵션 오브젝트</ko>
4478 * @param {Constants.ALIGN | string | number} [options.align="center"] An {@link Flicking#align align} value that will be applied to all panels<ko>전체 패널에 적용될 {@link Flicking#align align} 값</ko>
4479 * @param {object} [options.strategy] An instance of RenderingStrategy(internal module)<ko>RenderingStrategy의 인스턴스(내부 모듈)</ko>
4480 */
4481 function Renderer(_a) {
4482 var _b = _a.align,
4483 align = _b === void 0 ? ALIGN.CENTER : _b,
4484 strategy = _a.strategy;
4485 this._flicking = null;
4486 this._panels = [];
4487 this._rendering = false;
4488 // Bind options
4489 this._align = align;
4490 this._strategy = strategy;
4491 }
4492 var __proto = Renderer.prototype;
4493 Object.defineProperty(__proto, "panels", {
4494 // Internal states Getter
4495 /**
4496 * Array of panels
4497 * @ko 전체 패널들의 배열
4498 * @type {Panel[]}
4499 * @readonly
4500 * @see Panel
4501 */
4502 get: function () {
4503 return this._panels;
4504 },
4505 enumerable: false,
4506 configurable: true
4507 });
4508 Object.defineProperty(__proto, "rendering", {
4509 /**
4510 * A boolean value indicating whether rendering is in progress
4511 * @ko 현재 렌더링이 시작되어 끝나기 전까지의 상태인지의 여부
4512 * @type {boolean}
4513 * @readonly
4514 * @internal
4515 */
4516 get: function () {
4517 return this._rendering;
4518 },
4519 enumerable: false,
4520 configurable: true
4521 });
4522 Object.defineProperty(__proto, "panelCount", {
4523 /**
4524 * Count of panels
4525 * @ko 전체 패널의 개수
4526 * @type {number}
4527 * @readonly
4528 */
4529 get: function () {
4530 return this._panels.length;
4531 },
4532 enumerable: false,
4533 configurable: true
4534 });
4535 Object.defineProperty(__proto, "strategy", {
4536 /**
4537 * @internal
4538 */
4539 get: function () {
4540 return this._strategy;
4541 },
4542 enumerable: false,
4543 configurable: true
4544 });
4545 Object.defineProperty(__proto, "align", {
4546 // Options Getter
4547 /**
4548 * A {@link Panel}'s {@link Panel#align align} value that applied to all panels
4549 * @ko {@link Panel}에 공통적으로 적용할 {@link Panel#align align} 값
4550 * @type {Constants.ALIGN | string | number}
4551 */
4552 get: function () {
4553 return this._align;
4554 },
4555 // Options Setter
4556 set: function (val) {
4557 this._align = val;
4558 var panelAlign = parsePanelAlign(val);
4559 this._panels.forEach(function (panel) {
4560 panel.align = panelAlign;
4561 });
4562 },
4563 enumerable: false,
4564 configurable: true
4565 });
4566 /**
4567 * Initialize Renderer
4568 * @ko Renderer를 초기화합니다
4569 * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
4570 * @chainable
4571 * @return {this}
4572 */
4573 __proto.init = function (flicking) {
4574 this._flicking = flicking;
4575 this._collectPanels();
4576 return this;
4577 };
4578 /**
4579 * Destroy Renderer and return to initial state
4580 * @ko Renderer를 초기 상태로 되돌립니다
4581 * @return {void}
4582 */
4583 __proto.destroy = function () {
4584 this._flicking = null;
4585 this._panels = [];
4586 };
4587 /**
4588 * Return the {@link Panel} at the given index. `null` if it doesn't exists.
4589 * @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
4590 * @return {Panel | null} Panel at the given index<ko>주어진 인덱스에 해당하는 패널</ko>
4591 * @see Panel
4592 */
4593 __proto.getPanel = function (index) {
4594 return this._panels[index] || null;
4595 };
4596 __proto.forceRenderAllPanels = function () {
4597 this._panels.forEach(function (panel) {
4598 return panel.markForShow();
4599 });
4600 return Promise.resolve();
4601 };
4602 /**
4603 * Update all panel sizes
4604 * @ko 모든 패널의 크기를 업데이트합니다
4605 * @chainable
4606 * @return {this}
4607 */
4608 __proto.updatePanelSize = function () {
4609 var flicking = getFlickingAttached(this._flicking);
4610 var panels = this._panels;
4611 if (panels.length <= 0) return this;
4612 if (flicking.panelsPerView > 0) {
4613 var firstPanel = panels[0];
4614 firstPanel.resize();
4615 this._updatePanelSizeByGrid(firstPanel, panels);
4616 } else {
4617 flicking.panels.forEach(function (panel) {
4618 return panel.resize();
4619 });
4620 }
4621 return this;
4622 };
4623 /**
4624 * Insert new panels at given index
4625 * This will increase index of panels after by the number of panels added
4626 * @ko 주어진 인덱스에 새로운 패널들을 추가합니다
4627 * 해당 인덱스보다 같거나 큰 인덱스를 가진 기존 패널들은 추가한 패널의 개수만큼 인덱스가 증가합니다.
4628 * @param {Array<object>} items An array of items to insert<ko>추가할 아이템들의 배열</ko>
4629 * @param {number} [items.index] Index to insert new panels at<ko>새로 패널들을 추가할 인덱스</ko>
4630 * @param {any[]} [items.elements] An array of element or framework component with element in it<ko>엘리먼트의 배열 혹은 프레임워크에서 엘리먼트를 포함한 컴포넌트들의 배열</ko>
4631 * @param {boolean} [items.hasDOMInElements] Whether it contains actual DOM elements. If set to true, renderer will add them to the camera element<ko>내부에 실제 DOM 엘리먼트들을 포함하고 있는지 여부. true로 설정할 경우, 렌더러는 해당 엘리먼트들을 카메라 엘리먼트 내부에 추가합니다</ko>
4632 * @return {Panel[]} An array of prepended panels<ko>추가된 패널들의 배열</ko>
4633 */
4634 __proto.batchInsert = function () {
4635 var items = [];
4636 for (var _i = 0; _i < arguments.length; _i++) {
4637 items[_i] = arguments[_i];
4638 }
4639 var allPanelsInserted = this.batchInsertDefer.apply(this, __spread(items));
4640 if (allPanelsInserted.length <= 0) return [];
4641 this.updateAfterPanelChange(allPanelsInserted, []);
4642 return allPanelsInserted;
4643 };
4644 /**
4645 * Defers update
4646 * camera position & others will be updated after calling updateAfterPanelChange
4647 * @internal
4648 */
4649 __proto.batchInsertDefer = function () {
4650 var _this = this;
4651 var items = [];
4652 for (var _i = 0; _i < arguments.length; _i++) {
4653 items[_i] = arguments[_i];
4654 }
4655 var panels = this._panels;
4656 var flicking = getFlickingAttached(this._flicking);
4657 var prevFirstPanel = panels[0];
4658 var align = parsePanelAlign(this._align);
4659 var allPanelsInserted = items.reduce(function (addedPanels, item) {
4660 var _a;
4661 var insertingIdx = getMinusCompensatedIndex(item.index, panels.length);
4662 var panelsPushed = panels.slice(insertingIdx);
4663 var panelsInserted = item.elements.map(function (el, idx) {
4664 return _this._createPanel(el, {
4665 index: insertingIdx + idx,
4666 align: align,
4667 flicking: flicking
4668 });
4669 });
4670 panels.splice.apply(panels, __spread([insertingIdx, 0], panelsInserted));
4671 if (item.hasDOMInElements) {
4672 // Insert the actual elements as camera element's children
4673 _this._insertPanelElements(panelsInserted, (_a = panelsPushed[0]) !== null && _a !== void 0 ? _a : null);
4674 }
4675 // Resize the newly added panels
4676 if (flicking.panelsPerView > 0) {
4677 var firstPanel = prevFirstPanel || panelsInserted[0].resize();
4678 _this._updatePanelSizeByGrid(firstPanel, panelsInserted);
4679 } else {
4680 panelsInserted.forEach(function (panel) {
4681 return panel.resize();
4682 });
4683 }
4684 // Update panel indexes & positions
4685 panelsPushed.forEach(function (panel) {
4686 panel.increaseIndex(panelsInserted.length);
4687 panel.updatePosition();
4688 });
4689 return __spread(addedPanels, panelsInserted);
4690 }, []);
4691 return allPanelsInserted;
4692 };
4693 /**
4694 * Remove the panel at the given index
4695 * This will decrease index of panels after by the number of panels removed
4696 * @ko 주어진 인덱스의 패널을 제거합니다
4697 * 해당 인덱스보다 큰 인덱스를 가진 기존 패널들은 제거한 패널의 개수만큼 인덱스가 감소합니다
4698 * @param {Array<object>} items An array of items to remove<ko>제거할 아이템들의 배열</ko>
4699 * @param {number} [items.index] Index of panel to remove<ko>제거할 패널의 인덱스</ko>
4700 * @param {number} [items.deleteCount=1] Number of panels to remove from index<ko>`index` 이후로 제거할 패널의 개수</ko>
4701 * @param {boolean} [items.hasDOMInElements=1] Whether it contains actual DOM elements. If set to true, renderer will remove them from the camera element<ko>내부에 실제 DOM 엘리먼트들을 포함하고 있는지 여부. true로 설정할 경우, 렌더러는 해당 엘리먼트들을 카메라 엘리먼트 내부에서 제거합니다</ko>
4702 * @return An array of removed panels<ko>제거된 패널들의 배열</ko>
4703 */
4704 __proto.batchRemove = function () {
4705 var items = [];
4706 for (var _i = 0; _i < arguments.length; _i++) {
4707 items[_i] = arguments[_i];
4708 }
4709 var allPanelsRemoved = this.batchRemoveDefer.apply(this, __spread(items));
4710 if (allPanelsRemoved.length <= 0) return [];
4711 this.updateAfterPanelChange([], allPanelsRemoved);
4712 return allPanelsRemoved;
4713 };
4714 /**
4715 * Defers update
4716 * camera position & others will be updated after calling updateAfterPanelChange
4717 * @internal
4718 */
4719 __proto.batchRemoveDefer = function () {
4720 var _this = this;
4721 var items = [];
4722 for (var _i = 0; _i < arguments.length; _i++) {
4723 items[_i] = arguments[_i];
4724 }
4725 var panels = this._panels;
4726 var flicking = getFlickingAttached(this._flicking);
4727 var control = flicking.control;
4728 var activePanel = control.activePanel;
4729 var allPanelsRemoved = items.reduce(function (removed, item) {
4730 var index = item.index,
4731 deleteCount = item.deleteCount;
4732 var removingIdx = getMinusCompensatedIndex(index, panels.length);
4733 var panelsPulled = panels.slice(removingIdx + deleteCount);
4734 var panelsRemoved = panels.splice(removingIdx, deleteCount);
4735 if (panelsRemoved.length <= 0) return [];
4736 // Update panel indexes & positions
4737 panelsPulled.forEach(function (panel) {
4738 panel.decreaseIndex(panelsRemoved.length);
4739 panel.updatePosition();
4740 });
4741 if (item.hasDOMInElements) {
4742 _this._removePanelElements(panelsRemoved);
4743 }
4744 // Remove panel elements
4745 panelsRemoved.forEach(function (panel) {
4746 return panel.destroy();
4747 });
4748 if (includes(panelsRemoved, activePanel)) {
4749 control.resetActive();
4750 }
4751 return __spread(removed, panelsRemoved);
4752 }, []);
4753 return allPanelsRemoved;
4754 };
4755 /**
4756 * @internal
4757 */
4758 __proto.updateAfterPanelChange = function (panelsAdded, panelsRemoved) {
4759 var _a;
4760 var flicking = getFlickingAttached(this._flicking);
4761 var camera = flicking.camera,
4762 control = flicking.control;
4763 var panels = this._panels;
4764 var activePanel = control.activePanel;
4765 // Update camera & control
4766 this._updateCameraAndControl();
4767 void this.render();
4768 if (!flicking.animating) {
4769 if (!activePanel || activePanel.removed) {
4770 if (panels.length <= 0) {
4771 // All panels removed
4772 camera.lookAt(0);
4773 } else {
4774 var targetIndex = (_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.index) !== null && _a !== void 0 ? _a : 0;
4775 if (targetIndex > panels.length - 1) {
4776 targetIndex = panels.length - 1;
4777 }
4778 void control.moveToPanel(panels[targetIndex], {
4779 duration: 0
4780 }).catch(function () {
4781 return void 0;
4782 });
4783 }
4784 } else {
4785 void control.moveToPanel(activePanel, {
4786 duration: 0
4787 }).catch(function () {
4788 return void 0;
4789 });
4790 }
4791 }
4792 flicking.camera.updateOffset();
4793 if (panelsAdded.length > 0 || panelsRemoved.length > 0) {
4794 flicking.trigger(new ComponentEvent(EVENTS.PANEL_CHANGE, {
4795 added: panelsAdded,
4796 removed: panelsRemoved
4797 }));
4798 this.checkPanelContentsReady(__spread(panelsAdded, panelsRemoved));
4799 }
4800 };
4801 /**
4802 * @internal
4803 */
4804 __proto.checkPanelContentsReady = function (checkingPanels) {
4805 var _this = this;
4806 var flicking = getFlickingAttached(this._flicking);
4807 var resizeOnContentsReady = flicking.resizeOnContentsReady;
4808 var panels = this._panels;
4809 if (!resizeOnContentsReady || flicking.virtualEnabled) return;
4810 var hasContents = function (panel) {
4811 return panel.element && !!panel.element.querySelector("img, video");
4812 };
4813 checkingPanels = checkingPanels.filter(function (panel) {
4814 return hasContents(panel);
4815 });
4816 if (checkingPanels.length <= 0) return;
4817 var contentsReadyChecker = new ImReady();
4818 checkingPanels.forEach(function (panel) {
4819 panel.loading = true;
4820 });
4821 contentsReadyChecker.on("readyElement", function (e) {
4822 if (!_this._flicking) {
4823 // Renderer's destroy() is called before
4824 contentsReadyChecker.destroy();
4825 return;
4826 }
4827 var panel = checkingPanels[e.index];
4828 var camera = flicking.camera;
4829 var control = flicking.control;
4830 var prevProgressInPanel = control.activePanel ? camera.getProgressInPanel(control.activePanel) : 0;
4831 panel.loading = false;
4832 panel.resize();
4833 panels.slice(panel.index + 1).forEach(function (panelBehind) {
4834 return panelBehind.updatePosition();
4835 });
4836 if (!flicking.initialized) return;
4837 camera.updateRange();
4838 camera.updateOffset();
4839 camera.updateAnchors();
4840 if (control.animating) ; else {
4841 control.updatePosition(prevProgressInPanel);
4842 control.updateInput();
4843 }
4844 });
4845 contentsReadyChecker.on("preReady", function (e) {
4846 if (_this._flicking) {
4847 void _this.render();
4848 }
4849 if (e.readyCount === e.totalCount) {
4850 contentsReadyChecker.destroy();
4851 }
4852 });
4853 contentsReadyChecker.on("ready", function () {
4854 if (_this._flicking) {
4855 void _this.render();
4856 }
4857 contentsReadyChecker.destroy();
4858 });
4859 contentsReadyChecker.check(checkingPanels.map(function (panel) {
4860 return panel.element;
4861 }));
4862 };
4863 __proto._updateCameraAndControl = function () {
4864 var flicking = getFlickingAttached(this._flicking);
4865 var camera = flicking.camera,
4866 control = flicking.control;
4867 camera.updateRange();
4868 camera.updateOffset();
4869 camera.updateAnchors();
4870 camera.resetNeedPanelHistory();
4871 control.updateInput();
4872 };
4873 __proto._showOnlyVisiblePanels = function (flicking) {
4874 var panels = flicking.renderer.panels;
4875 var camera = flicking.camera;
4876 var visibleIndexes = camera.visiblePanels.reduce(function (visibles, panel) {
4877 visibles[panel.index] = true;
4878 return visibles;
4879 }, {});
4880 panels.forEach(function (panel) {
4881 if (panel.index in visibleIndexes || panel.loading) {
4882 panel.markForShow();
4883 } else if (!flicking.holding) {
4884 // During the input sequence,
4885 // Do not remove panel elements as it won't trigger touchend event.
4886 panel.markForHide();
4887 }
4888 });
4889 };
4890 __proto._updatePanelSizeByGrid = function (referencePanel, panels) {
4891 var flicking = getFlickingAttached(this._flicking);
4892 var panelsPerView = flicking.panelsPerView;
4893 if (panelsPerView <= 0) {
4894 throw new FlickingError(MESSAGE.WRONG_OPTION("panelsPerView", panelsPerView), CODE.WRONG_OPTION);
4895 }
4896 if (panels.length <= 0) return;
4897 var viewportSize = flicking.camera.size;
4898 var gap = referencePanel.margin.prev + referencePanel.margin.next;
4899 var panelSize = (viewportSize - gap * (panelsPerView - 1)) / panelsPerView;
4900 var panelSizeObj = flicking.horizontal ? {
4901 width: panelSize
4902 } : {
4903 height: panelSize
4904 };
4905 var firstPanelSizeObj = __assign({
4906 size: panelSize,
4907 margin: referencePanel.margin
4908 }, !flicking.horizontal && {
4909 height: referencePanel.height
4910 });
4911 if (!flicking.noPanelStyleOverride) {
4912 this._strategy.updatePanelSizes(flicking, panelSizeObj);
4913 }
4914 flicking.panels.forEach(function (panel) {
4915 return panel.resize(firstPanelSizeObj);
4916 });
4917 };
4918 __proto._removeAllChildsFromCamera = function () {
4919 var flicking = getFlickingAttached(this._flicking);
4920 var cameraElement = flicking.camera.element;
4921 // Remove other elements
4922 while (cameraElement.firstChild) {
4923 cameraElement.removeChild(cameraElement.firstChild);
4924 }
4925 };
4926 __proto._insertPanelElements = function (panels, nextSibling) {
4927 if (nextSibling === void 0) {
4928 nextSibling = null;
4929 }
4930 var flicking = getFlickingAttached(this._flicking);
4931 var camera = flicking.camera;
4932 var cameraElement = camera.element;
4933 var nextSiblingElement = (nextSibling === null || nextSibling === void 0 ? void 0 : nextSibling.element) || null;
4934 var fragment = document.createDocumentFragment();
4935 panels.forEach(function (panel) {
4936 return fragment.appendChild(panel.element);
4937 });
4938 cameraElement.insertBefore(fragment, nextSiblingElement);
4939 };
4940 __proto._removePanelElements = function (panels) {
4941 var flicking = getFlickingAttached(this._flicking);
4942 var cameraElement = flicking.camera.element;
4943 panels.forEach(function (panel) {
4944 cameraElement.removeChild(panel.element);
4945 });
4946 };
4947 __proto._afterRender = function () {
4948 var flicking = getFlickingAttached(this._flicking);
4949 flicking.camera.applyTransform();
4950 };
4951 return Renderer;
4952}();
4953
4954/**
4955 *
4956 */
4957var VanillaRenderer = /*#__PURE__*/function (_super) {
4958 __extends(VanillaRenderer, _super);
4959 function VanillaRenderer() {
4960 return _super !== null && _super.apply(this, arguments) || this;
4961 }
4962 // eslint-disable-next-line @typescript-eslint/require-await
4963 var __proto = VanillaRenderer.prototype;
4964 __proto.render = function () {
4965 return __awaiter(this, void 0, void 0, function () {
4966 var flicking, strategy;
4967 return __generator(this, function (_a) {
4968 flicking = getFlickingAttached(this._flicking);
4969 strategy = this._strategy;
4970 strategy.updateRenderingPanels(flicking);
4971 strategy.renderPanels(flicking);
4972 this._resetPanelElementOrder();
4973 this._afterRender();
4974 return [2 /*return*/];
4975 });
4976 });
4977 };
4978
4979 __proto._collectPanels = function () {
4980 var flicking = getFlickingAttached(this._flicking);
4981 var camera = flicking.camera;
4982 this._removeAllTextNodes();
4983 this._panels = this._strategy.collectPanels(flicking, camera.children);
4984 };
4985 __proto._createPanel = function (el, options) {
4986 return this._strategy.createPanel(el, options);
4987 };
4988 __proto._resetPanelElementOrder = function () {
4989 var flicking = getFlickingAttached(this._flicking);
4990 var cameraEl = flicking.camera.element;
4991 // We're using reversed panels here as last panel should be the last element of camera element
4992 var reversedElements = this._strategy.getRenderingElementsByOrder(flicking).reverse();
4993 reversedElements.forEach(function (el, idx) {
4994 var nextEl = reversedElements[idx - 1] ? reversedElements[idx - 1] : null;
4995 if (el.nextElementSibling !== nextEl) {
4996 cameraEl.insertBefore(el, nextEl);
4997 }
4998 });
4999 };
5000 __proto._removeAllTextNodes = function () {
5001 var flicking = getFlickingAttached(this._flicking);
5002 var cameraElement = flicking.camera.element;
5003 // Remove all text nodes in the camera element
5004 toArray(cameraElement.childNodes).forEach(function (node) {
5005 if (node.nodeType === Node.TEXT_NODE) {
5006 cameraElement.removeChild(node);
5007 }
5008 });
5009 };
5010 return VanillaRenderer;
5011}(Renderer);
5012
5013/**
5014 * @internal
5015 */
5016var ExternalRenderer = /*#__PURE__*/function (_super) {
5017 __extends(ExternalRenderer, _super);
5018 function ExternalRenderer() {
5019 return _super !== null && _super.apply(this, arguments) || this;
5020 }
5021 /* eslint-disable @typescript-eslint/no-unused-vars */
5022 var __proto = ExternalRenderer.prototype;
5023 __proto._removePanelElements = function (panels) {
5024 // DO NOTHING, overrided to prevent an unexpected error
5025 };
5026 __proto._removeAllChildsFromCamera = function () {
5027 // DO NOTHING, overrided to prevent an unexpected error
5028 };
5029 return ExternalRenderer;
5030}(Renderer);
5031
5032/**
5033 * A slide data component that holds information of a single HTMLElement
5034 * @ko 슬라이드 데이터 컴포넌트로, 단일 HTMLElement의 정보를 갖고 있습니다
5035 */
5036var Panel = /*#__PURE__*/function () {
5037 /**
5038 * @param {object} options An options object<ko>옵션 오브젝트</ko>
5039 * @param {number} [options.index] An initial index of the panel<ko>패널의 초기 인덱스</ko>
5040 * @param {Constants.ALIGN | string | number} [options.align] An initial {@link Flicking#align align} value of the panel<ko>패널의 초기 {@link Flicking#align align}값</ko>
5041 * @param {Flicking} [options.flicking] A Flicking instance panel's referencing<ko>패널이 참조하는 {@link Flicking} 인스턴스</ko>
5042 * @param {Flicking} [options.elementProvider] A provider instance that redirects elements<ko>실제 엘리먼트를 반환하는 엘리먼트 공급자의 인스턴스</ko>
5043 */
5044 function Panel(_a) {
5045 var index = _a.index,
5046 align = _a.align,
5047 flicking = _a.flicking,
5048 elementProvider = _a.elementProvider;
5049 this._index = index;
5050 this._flicking = flicking;
5051 this._elProvider = elementProvider;
5052 this._align = align;
5053 this._removed = false;
5054 this._rendered = true;
5055 this._loading = false;
5056 this._resetInternalStates();
5057 }
5058 var __proto = Panel.prototype;
5059 Object.defineProperty(__proto, "element", {
5060 // Internal States Getter
5061 /**
5062 * `HTMLElement` that panel's referencing
5063 * @ko 패널이 참조하고 있는 `HTMLElement`
5064 * @type {HTMLElement}
5065 * @readonly
5066 */
5067 get: function () {
5068 return this._elProvider.element;
5069 },
5070 enumerable: false,
5071 configurable: true
5072 });
5073 Object.defineProperty(__proto, "elementProvider", {
5074 /**
5075 * @internal
5076 * @readonly
5077 */
5078 get: function () {
5079 return this._elProvider;
5080 },
5081 enumerable: false,
5082 configurable: true
5083 });
5084 Object.defineProperty(__proto, "index", {
5085 /**
5086 * Index of the panel
5087 * @ko 패널의 인덱스
5088 * @type {number}
5089 * @readonly
5090 */
5091 get: function () {
5092 return this._index;
5093 },
5094 enumerable: false,
5095 configurable: true
5096 });
5097 Object.defineProperty(__proto, "position", {
5098 /**
5099 * Position of the panel, including {@link Panel#alignPosition alignPosition}
5100 * @ko 패널의 현재 좌표, {@link Panel#alignPosition alignPosition}을 포함하고 있습니다
5101 * @type {number}
5102 * @readonly
5103 */
5104 get: function () {
5105 return this._pos + this._alignPos;
5106 },
5107 enumerable: false,
5108 configurable: true
5109 });
5110 Object.defineProperty(__proto, "size", {
5111 /**
5112 * Cached size of the panel element
5113 * This is equal to {@link Panel#element element}'s `offsetWidth` if {@link Flicking#horizontal horizontal} is `true`, and `offsetHeight` else
5114 * @ko 패널 엘리먼트의 캐시된 크기
5115 * 이 값은 {@link Flicking#horizontal horizontal}이 `true`일 경우 {@link Panel#element element}의 `offsetWidth`와 동일하고, `false`일 경우 `offsetHeight`와 동일합니다
5116 * @type {number}
5117 * @readonly
5118 */
5119 get: function () {
5120 return this._size;
5121 },
5122 enumerable: false,
5123 configurable: true
5124 });
5125 Object.defineProperty(__proto, "sizeIncludingMargin", {
5126 /**
5127 * Panel's size including CSS `margin`
5128 * This value includes {@link Panel#element element}'s margin left/right if {@link Flicking#horizontal horizontal} is `true`, and margin top/bottom else
5129 * @ko CSS `margin`을 포함한 패널의 크기
5130 * 이 값은 {@link Flicking#horizontal horizontal}이 `true`일 경우 margin left/right을 포함하고, `false`일 경우 margin top/bottom을 포함합니다
5131 * @type {number}
5132 * @readonly
5133 */
5134 get: function () {
5135 return this._size + this._margin.prev + this._margin.next;
5136 },
5137 enumerable: false,
5138 configurable: true
5139 });
5140 Object.defineProperty(__proto, "height", {
5141 /**
5142 * Height of the panel element
5143 * @ko 패널 엘리먼트의 높이
5144 * @type {number}
5145 * @readonly
5146 */
5147 get: function () {
5148 return this._height;
5149 },
5150 enumerable: false,
5151 configurable: true
5152 });
5153 Object.defineProperty(__proto, "margin", {
5154 /**
5155 * Cached CSS `margin` value of the panel element
5156 * @ko 패널 엘리먼트의 CSS `margin` 값
5157 * @type {object}
5158 * @property {number} prev CSS `margin-left` when the {@link Flicking#horizontal horizontal} is `true`, and `margin-top` else
5159 * <ko>{@link Flicking#horizontal horizontal}이 `true`일 경우 `margin-left`, `false`일 경우 `margin-top`에 해당하는 값</ko>
5160 * @property {number} next CSS `margin-right` when the {@link Flicking#horizontal horizontal} is `true`, and `margin-bottom` else
5161 * <ko>{@link Flicking#horizontal horizontal}이 `true`일 경우 `margin-right`, `false`일 경우 `margin-bottom`에 해당하는 값</ko>
5162 * @readonly
5163 */
5164 get: function () {
5165 return this._margin;
5166 },
5167 enumerable: false,
5168 configurable: true
5169 });
5170 Object.defineProperty(__proto, "alignPosition", {
5171 /**
5172 * Align position inside the panel where {@link Camera}'s {@link Camera#alignPosition alignPosition} inside viewport should be located at
5173 * @ko 패널의 정렬 기준 위치. {@link Camera}의 뷰포트 내에서의 {@link Camera#alignPosition alignPosition}이 위치해야 하는 곳입니다
5174 * @type {number}
5175 * @readonly
5176 */
5177 get: function () {
5178 return this._alignPos;
5179 },
5180 enumerable: false,
5181 configurable: true
5182 });
5183 Object.defineProperty(__proto, "removed", {
5184 /**
5185 * A value indicating whether the panel's {@link Flicking#remove remove}d
5186 * @ko 패널이 {@link Flicking#remove remove}되었는지 여부를 나타내는 값
5187 * @type {boolean}
5188 * @readonly
5189 */
5190 get: function () {
5191 return this._removed;
5192 },
5193 enumerable: false,
5194 configurable: true
5195 });
5196 Object.defineProperty(__proto, "rendered", {
5197 /**
5198 * A value indicating whether the panel's element is being rendered on the screen
5199 * @ko 패널의 엘리먼트가 화면상에 렌더링되고있는지 여부를 나타내는 값
5200 * @type {boolean}
5201 * @readonly
5202 */
5203 get: function () {
5204 return this._rendered;
5205 },
5206 enumerable: false,
5207 configurable: true
5208 });
5209 Object.defineProperty(__proto, "loading", {
5210 /**
5211 * A value indicating whether the panel's image/video is not loaded and waiting for resize
5212 * @ko 패널 내부의 이미지/비디오가 아직 로드되지 않아 {@link Panel#resize resize}될 것인지를 나타내는 값
5213 * @type {boolean}
5214 * @readonly
5215 */
5216 get: function () {
5217 return this._loading;
5218 },
5219 set: function (val) {
5220 this._loading = val;
5221 },
5222 enumerable: false,
5223 configurable: true
5224 });
5225 Object.defineProperty(__proto, "range", {
5226 /**
5227 * Panel element's range of the bounding box
5228 * @ko 패널 엘리먼트의 Bounding box 범위
5229 * @type {object}
5230 * @property {number} [min] Bounding box's left({@link Flicking#horizontal horizontal}: true) / top({@link Flicking#horizontal horizontal}: false)
5231 * @property {number} [max] Bounding box's right({@link Flicking#horizontal horizontal}: true) / bottom({@link Flicking#horizontal horizontal}: false)
5232 * @readonly
5233 */
5234 get: function () {
5235 return {
5236 min: this._pos,
5237 max: this._pos + this._size
5238 };
5239 },
5240 enumerable: false,
5241 configurable: true
5242 });
5243 Object.defineProperty(__proto, "toggled", {
5244 /**
5245 * A value indicating whether the panel's position is toggled by circular behavior
5246 * @ko 패널의 위치가 circular 동작에 의해 토글되었는지 여부를 나타내는 값
5247 * @type {boolean}
5248 * @readonly
5249 */
5250 get: function () {
5251 return this._toggled;
5252 },
5253 enumerable: false,
5254 configurable: true
5255 });
5256 Object.defineProperty(__proto, "toggleDirection", {
5257 /**
5258 * A direction where the panel's position is toggled
5259 * @ko 패널의 위치가 circular 동작에 의해 토글되는 방향
5260 * @type {DIRECTION}
5261 * @readonly
5262 */
5263 get: function () {
5264 return this._toggleDirection;
5265 },
5266 enumerable: false,
5267 configurable: true
5268 });
5269 Object.defineProperty(__proto, "offset", {
5270 /**
5271 * Actual position offset determined by {@link Panel#order}
5272 * @ko {@link Panel#order}에 의한 실제 위치 변경값
5273 * @type {number}
5274 * @readonly
5275 */
5276 get: function () {
5277 var toggleDirection = this._toggleDirection;
5278 var cameraRangeDiff = this._flicking.camera.rangeDiff;
5279 return toggleDirection === DIRECTION.NONE || !this._toggled ? 0 : toggleDirection === DIRECTION.PREV ? -cameraRangeDiff : cameraRangeDiff;
5280 },
5281 enumerable: false,
5282 configurable: true
5283 });
5284 Object.defineProperty(__proto, "progress", {
5285 /**
5286 * Progress of movement between previous or next panel relative to current panel
5287 * @ko 이 패널로부터 이전/다음 패널으로의 이동 진행률
5288 * @type {number}
5289 * @readonly
5290 */
5291 get: function () {
5292 var flicking = this._flicking;
5293 return this.index - flicking.camera.progress;
5294 },
5295 enumerable: false,
5296 configurable: true
5297 });
5298 Object.defineProperty(__proto, "outsetProgress", {
5299 /**
5300 * Progress of movement between points that panel is completely invisible outside of viewport(prev direction: -1, selected point: 0, next direction: 1)
5301 * @ko 현재 패널이 뷰포트 영역 밖으로 완전히 사라지는 지점을 기준으로 하는 진행도(prev방향: -1, 선택 지점: 0, next방향: 1)
5302 * @type {number}
5303 * @readonly
5304 */
5305 get: function () {
5306 var position = this.position + this.offset;
5307 var alignPosition = this._alignPos;
5308 var camera = this._flicking.camera;
5309 var camPos = camera.position;
5310 if (camPos === position) {
5311 return 0;
5312 }
5313 if (camPos < position) {
5314 var disappearPosNext = position + (camera.size - camera.alignPosition) + alignPosition;
5315 return -getProgress(camPos, position, disappearPosNext);
5316 } else {
5317 var disappearPosPrev = position - (camera.alignPosition + this._size - alignPosition);
5318 return 1 - getProgress(camPos, disappearPosPrev, position);
5319 }
5320 },
5321 enumerable: false,
5322 configurable: true
5323 });
5324 Object.defineProperty(__proto, "visibleRatio", {
5325 /**
5326 * Percentage of area where panel is visible in the viewport
5327 * @ko 뷰포트 안에서 패널이 보이는 영역의 비율
5328 * @type {number}
5329 * @readonly
5330 */
5331 get: function () {
5332 var range = this.range;
5333 var size = this._size;
5334 var offset = this.offset;
5335 var visibleRange = this._flicking.camera.visibleRange;
5336 var checkingRange = {
5337 min: range.min + offset,
5338 max: range.max + offset
5339 };
5340 if (checkingRange.max <= visibleRange.min || checkingRange.min >= visibleRange.max) {
5341 return 0;
5342 }
5343 var visibleSize = size;
5344 if (visibleRange.min > checkingRange.min) {
5345 visibleSize -= visibleRange.min - checkingRange.min;
5346 }
5347 if (visibleRange.max < checkingRange.max) {
5348 visibleSize -= checkingRange.max - visibleRange.max;
5349 }
5350 return visibleSize / size;
5351 },
5352 enumerable: false,
5353 configurable: true
5354 });
5355 Object.defineProperty(__proto, "align", {
5356 // Options Getter
5357 /**
5358 * A value indicating where the {@link Panel#alignPosition alignPosition} should be located at inside the panel element
5359 * @ko {@link Panel#alignPosition alignPosition}이 패널 내의 어디에 위치해야 하는지를 나타내는 값
5360 * @type {Constants.ALIGN | string | number}
5361 */
5362 get: function () {
5363 return this._align;
5364 },
5365 // Options Setter
5366 set: function (val) {
5367 this._align = val;
5368 this._updateAlignPos();
5369 },
5370 enumerable: false,
5371 configurable: true
5372 });
5373 /**
5374 * Mark panel element to be appended on the camera element
5375 * @internal
5376 */
5377 __proto.markForShow = function () {
5378 this._rendered = true;
5379 this._elProvider.show(this._flicking);
5380 };
5381 /**
5382 * Mark panel element to be removed from the camera element
5383 * @internal
5384 */
5385 __proto.markForHide = function () {
5386 this._rendered = false;
5387 this._elProvider.hide(this._flicking);
5388 };
5389 /**
5390 * Update size of the panel
5391 * @ko 패널의 크기를 갱신합니다
5392 * @param {object} cached Predefined cached size of the panel<ko>사전에 캐시된 패널의 크기 정보</ko>
5393 * @chainable
5394 * @return {this}
5395 */
5396 __proto.resize = function (cached) {
5397 var _a;
5398 var el = this.element;
5399 var flicking = this._flicking;
5400 var horizontal = flicking.horizontal,
5401 useFractionalSize = flicking.useFractionalSize;
5402 if (cached) {
5403 this._size = cached.size;
5404 this._margin = __assign({}, cached.margin);
5405 this._height = (_a = cached.height) !== null && _a !== void 0 ? _a : getElementSize({
5406 el: el,
5407 horizontal: false,
5408 useFractionalSize: useFractionalSize,
5409 useOffset: true,
5410 style: getStyle(el)
5411 });
5412 } else {
5413 var elStyle = getStyle(el);
5414 this._size = getElementSize({
5415 el: el,
5416 horizontal: horizontal,
5417 useFractionalSize: useFractionalSize,
5418 useOffset: true,
5419 style: elStyle
5420 });
5421 this._margin = horizontal ? {
5422 prev: parseFloat(elStyle.marginLeft || "0"),
5423 next: parseFloat(elStyle.marginRight || "0")
5424 } : {
5425 prev: parseFloat(elStyle.marginTop || "0"),
5426 next: parseFloat(elStyle.marginBottom || "0")
5427 };
5428 this._height = horizontal ? getElementSize({
5429 el: el,
5430 horizontal: false,
5431 useFractionalSize: useFractionalSize,
5432 useOffset: true,
5433 style: elStyle
5434 }) : this._size;
5435 }
5436 this.updatePosition();
5437 this._updateAlignPos();
5438 return this;
5439 };
5440 /**
5441 * Change panel's size. This will change the actual size of the panel element by changing its CSS width/height property
5442 * @ko 패널 크기를 변경합니다. 패널 엘리먼트에 해당 크기의 CSS width/height를 적용합니다
5443 * @param {object} [size] New panel size<ko>새 패널 크기</ko>
5444 * @param {number|string} [size.width] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
5445 * @param {number|string} [size.height] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
5446 * @chainable
5447 * @return {this}
5448 */
5449 __proto.setSize = function (size) {
5450 setSize(this.element, size);
5451 return this;
5452 };
5453 /**
5454 * Check whether the given element is inside of this panel's {@link Panel#element element}
5455 * @ko 해당 엘리먼트가 이 패널의 {@link Panel#element element} 내에 포함되어 있는지를 반환합니다
5456 * @param {HTMLElement} element The HTMLElement to check<ko>확인하고자 하는 HTMLElement</ko>
5457 * @return {boolean} A Boolean value indicating the element is inside of this panel {@link Panel#element element}<ko>패널의 {@link Panel#element element}내에 해당 엘리먼트 포함 여부</ko>
5458 */
5459 __proto.contains = function (element) {
5460 var _a;
5461 return !!((_a = this.element) === null || _a === void 0 ? void 0 : _a.contains(element));
5462 };
5463 /**
5464 * Reset internal state and set {@link Panel#removed removed} to `true`
5465 * @ko 내부 상태를 초기화하고 {@link Panel#removed removed}를 `true`로 설정합니다.
5466 * @return {void}
5467 */
5468 __proto.destroy = function () {
5469 this._resetInternalStates();
5470 this._removed = true;
5471 };
5472 /**
5473 * Check whether the given position is inside of this panel's {@link Panel#range range}
5474 * @ko 주어진 좌표가 현재 패널의 {@link Panel#range range}내에 속해있는지를 반환합니다.
5475 * @param {number} pos A position to check<ko>확인하고자 하는 좌표</ko>
5476 * @param {boolean} [includeMargin=false] Include {@link Panel#margin margin} to the range<ko>패널 영역에 {@link Panel#margin margin}값을 포함시킵니다</ko>
5477 * @return {boolean} A Boolean value indicating whether the given position is included in the panel range<ko>해당 좌표가 패널 영역 내에 속해있는지 여부</ko>
5478 */
5479 __proto.includePosition = function (pos, includeMargin) {
5480 if (includeMargin === void 0) {
5481 includeMargin = false;
5482 }
5483 return this.includeRange(pos, pos, includeMargin);
5484 };
5485 /**
5486 * Check whether the given range is fully included in this panel's area (inclusive)
5487 * @ko 주어진 범위가 이 패널 내부에 완전히 포함되는지를 반환합니다
5488 * @param {number} min Minimum value of the range to check<ko>확인하고자 하는 최소 범위</ko>
5489 * @param {number} max Maximum value of the range to check<ko>확인하고자 하는 최대 범위</ko>
5490 * @param {boolean} [includeMargin=false] Include {@link Panel#margin margin} to the range<ko>패널 영역에 {@link Panel#margin margin}값을 포함시킵니다</ko>
5491 * @returns {boolean} A Boolean value indicating whether the given range is fully included in the panel range<ko>해당 범위가 패널 영역 내에 완전히 속해있는지 여부</ko>
5492 */
5493 __proto.includeRange = function (min, max, includeMargin) {
5494 if (includeMargin === void 0) {
5495 includeMargin = false;
5496 }
5497 var margin = this._margin;
5498 var panelRange = this.range;
5499 if (includeMargin) {
5500 panelRange.min -= margin.prev;
5501 panelRange.max += margin.next;
5502 }
5503 return max >= panelRange.min && min <= panelRange.max;
5504 };
5505 /**
5506 * Check whether the panel is visble in the given range (exclusive)
5507 * @ko 주어진 범위 내에서 이 패널의 일부가 보여지는지를 반환합니다
5508 * @param {number} min Minimum value of the range to check<ko>확인하고자 하는 최소 범위</ko>
5509 * @param {number} max Maximum value of the range to check<ko>확인하고자 하는 최대 범위</ko>
5510 * @returns {boolean} A Boolean value indicating whether the panel is visible<ko>해당 범위 내에서 패널을 볼 수 있는지 여부</ko>
5511 */
5512 __proto.isVisibleOnRange = function (min, max) {
5513 var panelRange = this.range;
5514 return max > panelRange.min && min < panelRange.max;
5515 };
5516 /**
5517 * Move {@link Camera} to this panel
5518 * @ko {@link Camera}를 이 패널로 이동합니다
5519 * @param {number} [duration] Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
5520 * @returns {Promise<void>} A Promise which will be resolved after reaching the panel<ko>패널 도달시에 resolve되는 Promise</ko>
5521 */
5522 __proto.focus = function (duration) {
5523 return this._flicking.moveTo(this._index, duration);
5524 };
5525 /**
5526 * Get previous(`index - 1`) panel. When the previous panel does not exist, this will return `null` instead
5527 * If the {@link Flicking#circularEnabled circular} is enabled, this will return the last panel if called from the first panel
5528 * @ko 이전(`index - 1`) 패널을 반환합니다. 이전 패널이 없을 경우 `null`을 반환합니다
5529 * {@link Flicking#circularEnabled circular} 모드가 활성화되었을 때 첫번째 패널에서 이 메소드를 호출할 경우 마지막 패널을 반환합니다
5530 * @returns {Panel | null} The previous panel<ko>이전 패널</ko>
5531 */
5532 __proto.prev = function () {
5533 var index = this._index;
5534 var flicking = this._flicking;
5535 var renderer = flicking.renderer;
5536 var panelCount = renderer.panelCount;
5537 if (panelCount === 1) return null;
5538 return flicking.circularEnabled ? renderer.getPanel(index === 0 ? panelCount - 1 : index - 1) : renderer.getPanel(index - 1);
5539 };
5540 /**
5541 * Get next(`index + 1`) panel. When the next panel does not exist, this will return `null` instead
5542 * If the {@link Flicking#circularEnabled circular} is enabled, this will return the first panel if called from the last panel
5543 * @ko 다음(`index + 1`) 패널을 반환합니다. 다음 패널이 없을 경우 `null`을 반환합니다
5544 * {@link Flicking#circularEnabled circular} 모드가 활성화되었을 때 마지막 패널에서 이 메소드를 호출할 경우 첫번째 패널을 반환합니다
5545 * @returns {Panel | null} The previous panel<ko>다음 패널</ko>
5546 */
5547 __proto.next = function () {
5548 var index = this._index;
5549 var flicking = this._flicking;
5550 var renderer = flicking.renderer;
5551 var panelCount = renderer.panelCount;
5552 if (panelCount === 1) return null;
5553 return flicking.circularEnabled ? renderer.getPanel(index === panelCount - 1 ? 0 : index + 1) : renderer.getPanel(index + 1);
5554 };
5555 /**
5556 * Increase panel's index by the given value
5557 * @ko 패널의 인덱스를 주어진 값만큼 증가시킵니다
5558 * @internal
5559 * @chainable
5560 * @param val An integer greater than or equal to 0<ko>0보다 같거나 큰 정수</ko>
5561 * @returns {this}
5562 */
5563 __proto.increaseIndex = function (val) {
5564 this._index += Math.max(val, 0);
5565 return this;
5566 };
5567 /**
5568 * Decrease panel's index by the given value
5569 * @ko 패널의 인덱스를 주어진 값만큼 감소시킵니다
5570 * @internal
5571 * @chainable
5572 * @param val An integer greater than or equal to 0<ko>0보다 같거나 큰 정수</ko>
5573 * @returns {this}
5574 */
5575 __proto.decreaseIndex = function (val) {
5576 this._index -= Math.max(val, 0);
5577 return this;
5578 };
5579 /**
5580 * @internal
5581 */
5582 __proto.updatePosition = function () {
5583 var prevPanel = this._flicking.renderer.panels[this._index - 1];
5584 this._pos = prevPanel ? prevPanel.range.max + prevPanel.margin.next + this._margin.prev : this._margin.prev;
5585 return this;
5586 };
5587 /**
5588 * @internal
5589 * @return {boolean} toggled
5590 */
5591 __proto.toggle = function (prevPos, newPos) {
5592 var toggleDirection = this._toggleDirection;
5593 var togglePosition = this._togglePosition;
5594 if (toggleDirection === DIRECTION.NONE || newPos === prevPos) return false;
5595 var prevToggled = this._toggled;
5596 if (newPos > prevPos) {
5597 if (togglePosition >= prevPos && togglePosition <= newPos) {
5598 this._toggled = toggleDirection === DIRECTION.NEXT;
5599 }
5600 } else {
5601 if (togglePosition <= prevPos && togglePosition >= newPos) {
5602 this._toggled = toggleDirection !== DIRECTION.NEXT;
5603 }
5604 }
5605 return prevToggled !== this._toggled;
5606 };
5607 /**
5608 * @internal
5609 */
5610 __proto.updateCircularToggleDirection = function () {
5611 var flicking = this._flicking;
5612 if (!flicking.circularEnabled) {
5613 this._toggleDirection = DIRECTION.NONE;
5614 this._togglePosition = 0;
5615 this._toggled = false;
5616 return this;
5617 }
5618 var camera = flicking.camera;
5619 var camRange = camera.range;
5620 var camAlignPosition = camera.alignPosition;
5621 var camVisibleRange = camera.visibleRange;
5622 var camVisibleSize = camVisibleRange.max - camVisibleRange.min;
5623 var minimumVisible = camRange.min - camAlignPosition;
5624 var maximumVisible = camRange.max - camAlignPosition + camVisibleSize;
5625 var shouldBeVisibleAtMin = this.includeRange(maximumVisible - camVisibleSize, maximumVisible, false);
5626 var shouldBeVisibleAtMax = this.includeRange(minimumVisible, minimumVisible + camVisibleSize, false);
5627 this._toggled = false;
5628 if (shouldBeVisibleAtMin) {
5629 this._toggleDirection = DIRECTION.PREV;
5630 this._togglePosition = this.range.max + camRange.min - camRange.max + camAlignPosition;
5631 this.toggle(Infinity, camera.position);
5632 } else if (shouldBeVisibleAtMax) {
5633 this._toggleDirection = DIRECTION.NEXT;
5634 this._togglePosition = this.range.min + camRange.max - camVisibleSize + camAlignPosition;
5635 this.toggle(-Infinity, camera.position);
5636 } else {
5637 this._toggleDirection = DIRECTION.NONE;
5638 this._togglePosition = 0;
5639 }
5640 return this;
5641 };
5642 __proto._updateAlignPos = function () {
5643 this._alignPos = parseAlign$1(this._align, this._size);
5644 };
5645 __proto._resetInternalStates = function () {
5646 this._size = 0;
5647 this._pos = 0;
5648 this._margin = {
5649 prev: 0,
5650 next: 0
5651 };
5652 this._height = 0;
5653 this._alignPos = 0;
5654 this._toggled = false;
5655 this._togglePosition = 0;
5656 this._toggleDirection = DIRECTION.NONE;
5657 };
5658 return Panel;
5659}();
5660
5661var NormalRenderingStrategy = /*#__PURE__*/function () {
5662 function NormalRenderingStrategy(_a) {
5663 var providerCtor = _a.providerCtor;
5664 this._providerCtor = providerCtor;
5665 }
5666 var __proto = NormalRenderingStrategy.prototype;
5667 __proto.renderPanels = function () {
5668 // DO_NOTHING
5669 };
5670 __proto.getRenderingIndexesByOrder = function (flicking) {
5671 var renderedPanels = flicking.renderer.panels.filter(function (panel) {
5672 return panel.rendered;
5673 });
5674 var toggledPrev = renderedPanels.filter(function (panel) {
5675 return panel.toggled && panel.toggleDirection === DIRECTION.PREV;
5676 });
5677 var toggledNext = renderedPanels.filter(function (panel) {
5678 return panel.toggled && panel.toggleDirection === DIRECTION.NEXT;
5679 });
5680 var notToggled = renderedPanels.filter(function (panel) {
5681 return !panel.toggled;
5682 });
5683 return __spread(toggledPrev, notToggled, toggledNext).map(function (panel) {
5684 return panel.index;
5685 });
5686 };
5687 __proto.getRenderingElementsByOrder = function (flicking) {
5688 var panels = flicking.panels;
5689 return this.getRenderingIndexesByOrder(flicking).map(function (index) {
5690 return panels[index].element;
5691 });
5692 };
5693 __proto.updateRenderingPanels = function (flicking) {
5694 if (flicking.renderOnlyVisible) {
5695 this._showOnlyVisiblePanels(flicking);
5696 } else {
5697 flicking.panels.forEach(function (panel) {
5698 return panel.markForShow();
5699 });
5700 }
5701 };
5702 __proto.collectPanels = function (flicking, elements) {
5703 var _this = this;
5704 var align = parsePanelAlign(flicking.renderer.align);
5705 return elements.map(function (el, index) {
5706 return new Panel({
5707 index: index,
5708 elementProvider: new _this._providerCtor(el),
5709 align: align,
5710 flicking: flicking
5711 });
5712 });
5713 };
5714 __proto.createPanel = function (element, options) {
5715 return new Panel(__assign(__assign({}, options), {
5716 elementProvider: new this._providerCtor(element)
5717 }));
5718 };
5719 __proto.updatePanelSizes = function (flicking, size) {
5720 flicking.panels.forEach(function (panel) {
5721 return panel.setSize(size);
5722 });
5723 };
5724 __proto._showOnlyVisiblePanels = function (flicking) {
5725 var panels = flicking.renderer.panels;
5726 var camera = flicking.camera;
5727 var visibleIndexes = camera.visiblePanels.reduce(function (visibles, panel) {
5728 visibles[panel.index] = true;
5729 return visibles;
5730 }, {});
5731 panels.forEach(function (panel) {
5732 if (panel.index in visibleIndexes || panel.loading) {
5733 panel.markForShow();
5734 } else if (!flicking.holding) {
5735 // During the input sequence,
5736 // Do not remove panel elements as it won't trigger touchend event.
5737 panel.markForHide();
5738 }
5739 });
5740 camera.updateOffset();
5741 };
5742 return NormalRenderingStrategy;
5743}();
5744
5745/**
5746 * An slide data component that holds information of a single HTMLElement
5747 * @ko 슬라이드 데이터 컴포넌트로, 단일 HTMLElement의 정보를 갖고 있습니다
5748 */
5749var VirtualPanel = /*#__PURE__*/function (_super) {
5750 __extends(VirtualPanel, _super);
5751 /**
5752 * @param {object} options An options object<ko>옵션 오브젝트</ko>
5753 * @param {number} [options.index] An initial index of the panel<ko>패널의 초기 인덱스</ko>
5754 * @param {Constants.ALIGN | string | number} [options.align] An initial {@link Flicking#align align} value of the panel<ko>패널의 초기 {@link Flicking#align align}값</ko>
5755 * @param {Flicking} [options.flicking] A Flicking instance panel's referencing<ko>패널이 참조하는 {@link Flicking} 인스턴스</ko>
5756 */
5757 function VirtualPanel(options) {
5758 var _this = _super.call(this, options) || this;
5759 options.elementProvider.init(_this);
5760 _this._elProvider = options.elementProvider;
5761 _this._cachedInnerHTML = null;
5762 return _this;
5763 }
5764 var __proto = VirtualPanel.prototype;
5765 Object.defineProperty(__proto, "element", {
5766 /**
5767 * `HTMLElement` that panel's referencing
5768 * @ko 패널이 참조하고 있는 `HTMLElement`
5769 * @type {HTMLElement}
5770 * @readonly
5771 */
5772 get: function () {
5773 return this._elProvider.element;
5774 },
5775 enumerable: false,
5776 configurable: true
5777 });
5778 Object.defineProperty(__proto, "cachedInnerHTML", {
5779 /**
5780 * Cached innerHTML by the previous render function
5781 * @ko 이전 렌더링에서 캐시된 innerHTML 정보
5782 * @type {string|null}
5783 * @readonly
5784 */
5785 get: function () {
5786 return this._cachedInnerHTML;
5787 },
5788 enumerable: false,
5789 configurable: true
5790 });
5791 Object.defineProperty(__proto, "elementIndex", {
5792 /**
5793 * An number for indexing which element it will be rendered on
5794 * @ko 몇 번째 엘리먼트에 렌더링될 것인지를 나타내는 숫자
5795 * @type {number}
5796 * @readonly
5797 */
5798 get: function () {
5799 var flicking = this._flicking;
5800 var virtualElCount = flicking.panelsPerView + 1;
5801 var panelCount = flicking.panelCount;
5802 var index = this._index;
5803 if (this._toggled) {
5804 // To prevent element duplication
5805 index = this._toggleDirection === DIRECTION.NEXT ? index + panelCount : index - panelCount;
5806 }
5807 return circulateIndex(index, virtualElCount);
5808 },
5809 enumerable: false,
5810 configurable: true
5811 });
5812 __proto.cacheRenderResult = function (result) {
5813 this._cachedInnerHTML = result;
5814 };
5815 __proto.uncacheRenderResult = function () {
5816 this._cachedInnerHTML = null;
5817 };
5818 __proto.render = function () {
5819 var flicking = this._flicking;
5820 var _a = flicking.virtual,
5821 renderPanel = _a.renderPanel,
5822 cache = _a.cache;
5823 var element = this._elProvider.element;
5824 var newInnerHTML = this._cachedInnerHTML || renderPanel(this, this._index);
5825 if (newInnerHTML === element.innerHTML) return;
5826 element.innerHTML = newInnerHTML;
5827 if (cache) {
5828 this.cacheRenderResult(newInnerHTML);
5829 }
5830 };
5831 __proto.increaseIndex = function (val) {
5832 this.uncacheRenderResult();
5833 return _super.prototype.increaseIndex.call(this, val);
5834 };
5835 __proto.decreaseIndex = function (val) {
5836 this.uncacheRenderResult();
5837 return _super.prototype.decreaseIndex.call(this, val);
5838 };
5839 return VirtualPanel;
5840}(Panel);
5841
5842var VirtualRenderingStrategy = /*#__PURE__*/function () {
5843 function VirtualRenderingStrategy() {}
5844 var __proto = VirtualRenderingStrategy.prototype;
5845 __proto.renderPanels = function (flicking) {
5846 var virtualManager = flicking.virtual;
5847 var visiblePanels = flicking.visiblePanels;
5848 var invisibleIndexes = range(flicking.panelsPerView + 1);
5849 visiblePanels.forEach(function (panel) {
5850 var elementIndex = panel.elementIndex;
5851 panel.render();
5852 virtualManager.show(elementIndex);
5853 invisibleIndexes[elementIndex] = -1;
5854 });
5855 invisibleIndexes.filter(function (val) {
5856 return val >= 0;
5857 }).forEach(function (idx) {
5858 virtualManager.hide(idx);
5859 });
5860 };
5861 __proto.getRenderingIndexesByOrder = function (flicking) {
5862 var virtualManager = flicking.virtual;
5863 var visiblePanels = __spread(flicking.visiblePanels).filter(function (panel) {
5864 return panel.rendered;
5865 }).sort(function (panel1, panel2) {
5866 return panel1.position + panel1.offset - (panel2.position + panel2.offset);
5867 });
5868 if (visiblePanels.length <= 0) return virtualManager.elements.map(function (_, idx) {
5869 return idx;
5870 });
5871 var visibleIndexes = visiblePanels.map(function (panel) {
5872 return panel.elementIndex;
5873 });
5874 var invisibleIndexes = virtualManager.elements.map(function (el, idx) {
5875 return __assign(__assign({}, el), {
5876 idx: idx
5877 });
5878 }).filter(function (el) {
5879 return !el.visible;
5880 }).map(function (el) {
5881 return el.idx;
5882 });
5883 return __spread(visibleIndexes, invisibleIndexes);
5884 };
5885 __proto.getRenderingElementsByOrder = function (flicking) {
5886 var virtualManager = flicking.virtual;
5887 var elements = virtualManager.elements;
5888 return this.getRenderingIndexesByOrder(flicking).map(function (index) {
5889 return elements[index].nativeElement;
5890 });
5891 };
5892 __proto.updateRenderingPanels = function (flicking) {
5893 var panels = flicking.renderer.panels;
5894 var camera = flicking.camera;
5895 var visibleIndexes = camera.visiblePanels.reduce(function (visibles, panel) {
5896 visibles[panel.index] = true;
5897 return visibles;
5898 }, {});
5899 panels.forEach(function (panel) {
5900 if (panel.index in visibleIndexes || panel.loading) {
5901 panel.markForShow();
5902 } else {
5903 panel.markForHide();
5904 }
5905 });
5906 camera.updateOffset();
5907 };
5908 __proto.collectPanels = function (flicking) {
5909 var align = parsePanelAlign(flicking.renderer.align);
5910 return range(flicking.virtual.initialPanelCount).map(function (index) {
5911 return new VirtualPanel({
5912 index: index,
5913 elementProvider: new VirtualElementProvider(flicking),
5914 align: align,
5915 flicking: flicking
5916 });
5917 });
5918 };
5919 __proto.createPanel = function (_el, options) {
5920 return new VirtualPanel(__assign(__assign({}, options), {
5921 elementProvider: new VirtualElementProvider(options.flicking)
5922 }));
5923 };
5924 __proto.updatePanelSizes = function (flicking, size) {
5925 flicking.virtual.elements.forEach(function (el) {
5926 setSize(el.nativeElement, size);
5927 });
5928 flicking.panels.forEach(function (panel) {
5929 return panel.setSize(size);
5930 });
5931 };
5932 return VirtualRenderingStrategy;
5933}();
5934
5935/**
5936 * @extends Component
5937 * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
5938 * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
5939 * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
5940 */
5941var Flicking = /*#__PURE__*/function (_super) {
5942 __extends(Flicking, _super);
5943 /**
5944 * @param root A root HTMLElement to initialize Flicking on it. When it's a typeof `string`, it should be a css selector string
5945 * <ko>Flicking을 초기화할 HTMLElement로, `string` 타입으로 지정시 css 선택자 문자열을 지정해야 합니다.</ko>
5946 * @param {object} [options={}] An options object for Flicking.<ko>Flicking에 적용할 옵션 오브젝트</ko>
5947 * @throws {FlickingError}
5948 * |code|condition|
5949 * |---|---|
5950 * |{@link ERROR_CODE WRONG_TYPE}|When the root is not either string or HTMLElement|
5951 * |{@link ERROR_CODE ELEMENT_NOT_FOUND}|When the element with given CSS selector does not exist|
5952 * <ko>
5953 *
5954 * |code|조건|
5955 * |---|---|
5956 * |{@link ERROR_CODE WRONG_TYPE}|루트 엘리먼트가 string이나 HTMLElement가 아닐 경우|
5957 * |{@link ERROR_CODE ELEMENT_NOT_FOUND}|주어진 CSS selector로 엘리먼트를 찾지 못했을 경우|
5958 *
5959 * </ko>
5960 * @example
5961 * ```ts
5962 * import Flicking from "@egjs/flicking";
5963 *
5964 * // Creating new instance of Flicking with HTMLElement
5965 * const flicking = new Flicking(document.querySelector(".flicking-viewport"), { circular: true });
5966 *
5967 * // Creating new instance of Flicking with CSS selector
5968 * const flicking2 = new Flicking(".flicking-viewport", { circular: true });
5969 * ```
5970 */
5971 function Flicking(root, _a) {
5972 var _b = _a === void 0 ? {} : _a,
5973 _c = _b.align,
5974 align = _c === void 0 ? ALIGN.CENTER : _c,
5975 _d = _b.defaultIndex,
5976 defaultIndex = _d === void 0 ? 0 : _d,
5977 _e = _b.horizontal,
5978 horizontal = _e === void 0 ? true : _e,
5979 _f = _b.circular,
5980 circular = _f === void 0 ? false : _f,
5981 _g = _b.circularFallback,
5982 circularFallback = _g === void 0 ? CIRCULAR_FALLBACK.LINEAR : _g,
5983 _h = _b.bound,
5984 bound = _h === void 0 ? false : _h,
5985 _j = _b.adaptive,
5986 adaptive = _j === void 0 ? false : _j,
5987 _k = _b.panelsPerView,
5988 panelsPerView = _k === void 0 ? -1 : _k,
5989 _l = _b.noPanelStyleOverride,
5990 noPanelStyleOverride = _l === void 0 ? false : _l,
5991 _m = _b.resizeOnContentsReady,
5992 resizeOnContentsReady = _m === void 0 ? false : _m,
5993 _o = _b.nested,
5994 nested = _o === void 0 ? false : _o,
5995 _p = _b.needPanelThreshold,
5996 needPanelThreshold = _p === void 0 ? 0 : _p,
5997 _q = _b.preventEventsBeforeInit,
5998 preventEventsBeforeInit = _q === void 0 ? true : _q,
5999 _r = _b.deceleration,
6000 deceleration = _r === void 0 ? 0.0075 : _r,
6001 _s = _b.duration,
6002 duration = _s === void 0 ? 500 : _s,
6003 _t = _b.easing,
6004 easing = _t === void 0 ? function (x) {
6005 return 1 - Math.pow(1 - x, 3);
6006 } : _t,
6007 _u = _b.inputType,
6008 inputType = _u === void 0 ? ["mouse", "touch"] : _u,
6009 _v = _b.moveType,
6010 moveType = _v === void 0 ? "snap" : _v,
6011 _w = _b.threshold,
6012 threshold = _w === void 0 ? 40 : _w,
6013 _x = _b.interruptable,
6014 interruptable = _x === void 0 ? true : _x,
6015 _y = _b.bounce,
6016 bounce = _y === void 0 ? "20%" : _y,
6017 _z = _b.iOSEdgeSwipeThreshold,
6018 iOSEdgeSwipeThreshold = _z === void 0 ? 30 : _z,
6019 _0 = _b.preventClickOnDrag,
6020 preventClickOnDrag = _0 === void 0 ? true : _0,
6021 _1 = _b.preventDefaultOnDrag,
6022 preventDefaultOnDrag = _1 === void 0 ? false : _1,
6023 _2 = _b.disableOnInit,
6024 disableOnInit = _2 === void 0 ? false : _2,
6025 _3 = _b.changeOnHold,
6026 changeOnHold = _3 === void 0 ? false : _3,
6027 _4 = _b.renderOnlyVisible,
6028 renderOnlyVisible = _4 === void 0 ? false : _4,
6029 _5 = _b.virtual,
6030 virtual = _5 === void 0 ? null : _5,
6031 _6 = _b.autoInit,
6032 autoInit = _6 === void 0 ? true : _6,
6033 _7 = _b.autoResize,
6034 autoResize = _7 === void 0 ? true : _7,
6035 _8 = _b.useResizeObserver,
6036 useResizeObserver = _8 === void 0 ? true : _8,
6037 _9 = _b.resizeDebounce,
6038 resizeDebounce = _9 === void 0 ? 0 : _9,
6039 _10 = _b.maxResizeDebounce,
6040 maxResizeDebounce = _10 === void 0 ? 100 : _10,
6041 _11 = _b.useFractionalSize,
6042 useFractionalSize = _11 === void 0 ? false : _11,
6043 _12 = _b.externalRenderer,
6044 externalRenderer = _12 === void 0 ? null : _12,
6045 _13 = _b.renderExternal,
6046 renderExternal = _13 === void 0 ? null : _13;
6047 var _this = _super.call(this) || this;
6048 // Internal states
6049 _this._initialized = false;
6050 _this._plugins = [];
6051 // Bind options
6052 _this._align = align;
6053 _this._defaultIndex = defaultIndex;
6054 _this._horizontal = horizontal;
6055 _this._circular = circular;
6056 _this._circularFallback = circularFallback;
6057 _this._bound = bound;
6058 _this._adaptive = adaptive;
6059 _this._panelsPerView = panelsPerView;
6060 _this._noPanelStyleOverride = noPanelStyleOverride;
6061 _this._resizeOnContentsReady = resizeOnContentsReady;
6062 _this._nested = nested;
6063 _this._virtual = virtual;
6064 _this._needPanelThreshold = needPanelThreshold;
6065 _this._preventEventsBeforeInit = preventEventsBeforeInit;
6066 _this._deceleration = deceleration;
6067 _this._duration = duration;
6068 _this._easing = easing;
6069 _this._inputType = inputType;
6070 _this._moveType = moveType;
6071 _this._threshold = threshold;
6072 _this._interruptable = interruptable;
6073 _this._bounce = bounce;
6074 _this._iOSEdgeSwipeThreshold = iOSEdgeSwipeThreshold;
6075 _this._preventClickOnDrag = preventClickOnDrag;
6076 _this._preventDefaultOnDrag = preventDefaultOnDrag;
6077 _this._disableOnInit = disableOnInit;
6078 _this._changeOnHold = changeOnHold;
6079 _this._renderOnlyVisible = renderOnlyVisible;
6080 _this._autoInit = autoInit;
6081 _this._autoResize = autoResize;
6082 _this._useResizeObserver = useResizeObserver;
6083 _this._resizeDebounce = resizeDebounce;
6084 _this._maxResizeDebounce = maxResizeDebounce;
6085 _this._useFractionalSize = useFractionalSize;
6086 _this._externalRenderer = externalRenderer;
6087 _this._renderExternal = renderExternal;
6088 // Create core components
6089 _this._viewport = new Viewport(_this, getElement(root));
6090 _this._autoResizer = new AutoResizer(_this);
6091 _this._renderer = _this._createRenderer();
6092 _this._camera = _this._createCamera();
6093 _this._control = _this._createControl();
6094 _this._virtualManager = new VirtualManager(_this, virtual);
6095 if (_this._autoInit) {
6096 void _this.init();
6097 }
6098 return _this;
6099 }
6100 var __proto = Flicking.prototype;
6101 Object.defineProperty(__proto, "control", {
6102 // Components
6103 /**
6104 * {@link Control} instance of the Flicking
6105 * @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
6106 * @type {Control}
6107 * @default SnapControl
6108 * @readonly
6109 * @see Control
6110 * @see SnapControl
6111 * @see FreeControl
6112 */
6113 get: function () {
6114 return this._control;
6115 },
6116 enumerable: false,
6117 configurable: true
6118 });
6119 Object.defineProperty(__proto, "camera", {
6120 /**
6121 * {@link Camera} instance of the Flicking
6122 * @ko 현재 Flicking에 활성화된 {@link Camera} 인스턴스
6123 * @type {Camera}
6124 * @default LinearCamera
6125 * @readonly
6126 * @see Camera
6127 * @see LinearCamera
6128 * @see BoundCamera
6129 * @see CircularCamera
6130 */
6131 get: function () {
6132 return this._camera;
6133 },
6134 enumerable: false,
6135 configurable: true
6136 });
6137 Object.defineProperty(__proto, "renderer", {
6138 /**
6139 * {@link Renderer} instance of the Flicking
6140 * @ko 현재 Flicking에 활성화된 {@link Renderer} 인스턴스
6141 * @type {Renderer}
6142 * @default VanillaRenderer
6143 * @readonly
6144 * @see Renderer
6145 * @see VanillaRenderer
6146 * @see ExternalRenderer
6147 */
6148 get: function () {
6149 return this._renderer;
6150 },
6151 enumerable: false,
6152 configurable: true
6153 });
6154 Object.defineProperty(__proto, "viewport", {
6155 /**
6156 * A component that manages viewport size
6157 * @ko 뷰포트 크기 정보를 담당하는 컴포넌트
6158 * @type {Viewport}
6159 * @readonly
6160 * @see Viewport
6161 */
6162 get: function () {
6163 return this._viewport;
6164 },
6165 enumerable: false,
6166 configurable: true
6167 });
6168 Object.defineProperty(__proto, "initialized", {
6169 // Internal States
6170 /**
6171 * Whether Flicking's {@link Flicking#init init()} is called.
6172 * This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
6173 * @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
6174 * 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
6175 * @type {boolean}
6176 * @default false
6177 * @readonly
6178 */
6179 get: function () {
6180 return this._initialized;
6181 },
6182 enumerable: false,
6183 configurable: true
6184 });
6185 Object.defineProperty(__proto, "circularEnabled", {
6186 /**
6187 * Whether the `circular` option is enabled.
6188 * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
6189 * @ko {@link Flicking#circular circular} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
6190 * {@link Flicking#circular circular} 옵션은 패널의 크기의 합이 충분하지 않을 경우 비활성화됩니다.
6191 * @type {boolean}
6192 * @default false
6193 * @readonly
6194 */
6195 get: function () {
6196 return this._camera.circularEnabled;
6197 },
6198 enumerable: false,
6199 configurable: true
6200 });
6201 Object.defineProperty(__proto, "virtualEnabled", {
6202 /**
6203 * Whether the `virtual` option is enabled.
6204 * The {@link Flicking#virtual virtual} option can't be enabled when {@link Flicking#panelsPerView panelsPerView} is less or equal than zero.
6205 * @ko {@link Flicking#virtual virtual} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
6206 * {@link Flicking#virtual virtual} 옵션은 {@link Flicking#panelsPerView panelsPerView} 옵션의 값이 0보다 같거나 작으면 비활성화됩니다.
6207 * @type {boolean}
6208 * @default false
6209 * @readonly
6210 */
6211 get: function () {
6212 return this._panelsPerView > 0 && this._virtual != null;
6213 },
6214 enumerable: false,
6215 configurable: true
6216 });
6217 Object.defineProperty(__proto, "index", {
6218 /**
6219 * Index number of the {@link Flicking#currentPanel currentPanel}
6220 * @ko {@link Flicking#currentPanel currentPanel}의 인덱스 번호
6221 * @type {number}
6222 * @default 0
6223 * @readonly
6224 */
6225 get: function () {
6226 return this._control.activeIndex;
6227 },
6228 enumerable: false,
6229 configurable: true
6230 });
6231 Object.defineProperty(__proto, "element", {
6232 /**
6233 * The root(`.flicking-viewport`) element
6234 * @ko root(`.flicking-viewport`) 엘리먼트
6235 * @type {HTMLElement}
6236 * @readonly
6237 */
6238 get: function () {
6239 return this._viewport.element;
6240 },
6241 enumerable: false,
6242 configurable: true
6243 });
6244 Object.defineProperty(__proto, "currentPanel", {
6245 /**
6246 * Currently active panel
6247 * @ko 현재 선택된 패널
6248 * @type {Panel}
6249 * @readonly
6250 * @see Panel
6251 */
6252 get: function () {
6253 return this._control.activePanel;
6254 },
6255 enumerable: false,
6256 configurable: true
6257 });
6258 Object.defineProperty(__proto, "panels", {
6259 /**
6260 * Array of panels
6261 * @ko 전체 패널들의 배열
6262 * @type {Panel[]}
6263 * @readonly
6264 * @see Panel
6265 */
6266 get: function () {
6267 return this._renderer.panels;
6268 },
6269 enumerable: false,
6270 configurable: true
6271 });
6272 Object.defineProperty(__proto, "panelCount", {
6273 /**
6274 * Count of panels
6275 * @ko 전체 패널의 개수
6276 * @type {number}
6277 * @readonly
6278 */
6279 get: function () {
6280 return this._renderer.panelCount;
6281 },
6282 enumerable: false,
6283 configurable: true
6284 });
6285 Object.defineProperty(__proto, "visiblePanels", {
6286 /**
6287 * Array of panels that is visible at the current position
6288 * @ko 현재 보이는 패널의 배열
6289 * @type {Panel[]}
6290 * @readonly
6291 * @see Panel
6292 */
6293 get: function () {
6294 return this._camera.visiblePanels;
6295 },
6296 enumerable: false,
6297 configurable: true
6298 });
6299 Object.defineProperty(__proto, "animating", {
6300 /**
6301 * Whether Flicking's animating
6302 * @ko 현재 애니메이션 동작 여부
6303 * @type {boolean}
6304 * @readonly
6305 */
6306 get: function () {
6307 return this._control.animating;
6308 },
6309 enumerable: false,
6310 configurable: true
6311 });
6312 Object.defineProperty(__proto, "holding", {
6313 /**
6314 * Whether user is clicking or touching
6315 * @ko 현재 사용자가 클릭/터치중인지 여부
6316 * @type {boolean}
6317 * @readonly
6318 */
6319 get: function () {
6320 return this._control.holding;
6321 },
6322 enumerable: false,
6323 configurable: true
6324 });
6325 Object.defineProperty(__proto, "activePlugins", {
6326 /**
6327 * A current list of activated plugins
6328 * @ko 현재 활성화된 플러그인 목록
6329 * @type {Plugin[]}
6330 * @readonly
6331 */
6332 get: function () {
6333 return this._plugins;
6334 },
6335 enumerable: false,
6336 configurable: true
6337 });
6338 Object.defineProperty(__proto, "align", {
6339 // Options Getter
6340 // UI / LAYOUT
6341 /**
6342 * Align position of the panels within viewport. You can set different values each for the panel and camera
6343 * @ko 뷰포트 내에서 패널 정렬방식을 설정하는 옵션. 카메라와 패널 개별로 옵션을 설정할 수도 있습니다
6344 * @type {ALIGN | string | number | { panel: string | number, camera: string | number }}
6345 * @property {ALIGN | string | number} panel The align value for each {@link Panel}s<ko>개개의 {@link Panel}에 적용할 값</ko>
6346 * @property {ALIGN | string | number} camera The align value for {@link Camera}<ko>{@link Camera}에 적용할 값</ko>
6347 * @default "center"
6348 * @see {@link https://naver.github.io/egjs-flicking/Options#align align ( Options )}
6349 * @example
6350 * ```ts
6351 * const possibleOptions = [
6352 * // Literal strings
6353 * "prev", "center", "next",
6354 * // % values, applied to both panel & camera
6355 * "0%", "25%", "42%",
6356 * // px values, arithmetic calculation with (+/-) is also allowed.
6357 * "0px", "100px", "50% - 25px",
6358 * // numbers, same to number + px ("0px", "100px")
6359 * 0, 100, 1000,
6360 * // Setting a different value for panel & camera
6361 * { panel: "10%", camera: "25%" }
6362 * ];
6363 *
6364 * possibleOptions.forEach(align => {
6365 * new Flicking("#el", { align });
6366 * });
6367 * ```
6368 */
6369 get: function () {
6370 return this._align;
6371 },
6372 // Options Setter
6373 // UI / LAYOUT
6374 set: function (val) {
6375 this._align = val;
6376 this._renderer.align = val;
6377 this._camera.align = val;
6378 void this.resize();
6379 },
6380 enumerable: false,
6381 configurable: true
6382 });
6383 Object.defineProperty(__proto, "defaultIndex", {
6384 /**
6385 * Index of the panel to move when Flicking's {@link Flicking#init init()} is called. A zero-based integer
6386 * @ko Flicking의 {@link Flicking#init init()}이 호출될 때 이동할 디폴트 패널의 인덱스로, 0부터 시작하는 정수입니다
6387 * @type {number}
6388 * @default 0
6389 * @see {@link https://naver.github.io/egjs-flicking/Options#defaultindex defaultIndex ( Options )}
6390 */
6391 get: function () {
6392 return this._defaultIndex;
6393 },
6394 set: function (val) {
6395 this._defaultIndex = val;
6396 },
6397 enumerable: false,
6398 configurable: true
6399 });
6400 Object.defineProperty(__proto, "horizontal", {
6401 /**
6402 * Direction of panel movement (true: horizontal, false: vertical)
6403 * @ko 패널 이동 방향 (true: 가로방향, false: 세로방향)
6404 * @type {boolean}
6405 * @default true
6406 * @see {@link https://naver.github.io/egjs-flicking/Options#horizontal horizontal ( Options )}
6407 */
6408 get: function () {
6409 return this._horizontal;
6410 },
6411 set: function (val) {
6412 this._horizontal = val;
6413 this._control.controller.updateDirection();
6414 void this.resize();
6415 },
6416 enumerable: false,
6417 configurable: true
6418 });
6419 Object.defineProperty(__proto, "circular", {
6420 /**
6421 * Enables circular(continuous loop) mode, which connects first/last panel for continuous scrolling.
6422 * @ko 순환 모드를 활성화합니다. 순환 모드에서는 양 끝의 패널이 서로 연결되어 끊김없는 스크롤이 가능합니다.
6423 * @type {boolean}
6424 * @default false
6425 * @see {@link https://naver.github.io/egjs-flicking/Options#circular circular ( Options )}
6426 */
6427 get: function () {
6428 return this._circular;
6429 },
6430 set: function (val) {
6431 this._circular = val;
6432 void this.resize();
6433 },
6434 enumerable: false,
6435 configurable: true
6436 });
6437 Object.defineProperty(__proto, "circularFallback", {
6438 /**
6439 * Set panel control mode for the case when circular cannot be enabled.
6440 * "linear" will set the view's range from the top of the first panel to the top of the last panel.
6441 * "bound" will prevent the view from going out of the first/last panel, so it won't show empty spaces before/after the first/last panel.
6442 * @ko 순환 모드 사용 불가능시 사용할 패널 조작 범위 설정 방식을 변경합니다.
6443 * "linear" 사용시 시점이 첫번째 엘리먼트 위에서부터 마지막 엘리먼트 위까지 움직일 수 있도록 설정합니다.
6444 * "bound" 사용시 시점이 첫번째 엘리먼트와 마지막 엘리먼트의 끝과 끝 사이에서 움직일 수 있도록 설정합니다.
6445 * @see CIRCULAR_FALLBACK
6446 * @type {string}
6447 * @default "linear"
6448 * @see {@link https://naver.github.io/egjs-flicking/Options#circularfallback circularFallback ( Options )}
6449 */
6450 get: function () {
6451 return this._circularFallback;
6452 },
6453 enumerable: false,
6454 configurable: true
6455 });
6456 Object.defineProperty(__proto, "bound", {
6457 /**
6458 * Prevent the view(camera element) from going out of the first/last panel, so it won't show empty spaces before/after the first/last panel
6459 * Only can be enabled when `circular=false`
6460 * @ko 뷰(카메라 엘리먼트)가 첫번째와 마지막 패널 밖으로 넘어가지 못하게 하여, 첫번째/마지막 패널 전/후의 빈 공간을 보이지 않도록 하는 옵션입니다
6461 * `circular=false`인 경우에만 사용할 수 있습니다
6462 * @type {boolean}
6463 * @default false
6464 * @see {@link https://naver.github.io/egjs-flicking/Options#bound bound ( Options )}
6465 */
6466 get: function () {
6467 return this._bound;
6468 },
6469 set: function (val) {
6470 this._bound = val;
6471 void this.resize();
6472 },
6473 enumerable: false,
6474 configurable: true
6475 });
6476 Object.defineProperty(__proto, "adaptive", {
6477 /**
6478 * Update height of the viewport element after movement same to the height of the panel below. This can be only enabled when `horizontal=true`
6479 * @ko 이동한 후 뷰포트 엘리먼트의 크기를 현재 패널의 높이와 동일하게 설정합니다. `horizontal=true`인 경우에만 사용할 수 있습니다.
6480 * @type {boolean}
6481 * @default false
6482 * @see {@link https://naver.github.io/egjs-flicking/Options#adaptive adaptive ( Options )}
6483 */
6484 get: function () {
6485 return this._adaptive;
6486 },
6487 set: function (val) {
6488 this._adaptive = val;
6489 void this.resize();
6490 },
6491 enumerable: false,
6492 configurable: true
6493 });
6494 Object.defineProperty(__proto, "panelsPerView", {
6495 /**
6496 * A visible number of panels on viewport. Enabling this option will automatically resize panel size
6497 * @ko 한 화면에 보이는 패널의 개수. 이 옵션을 활성화할 경우 패널의 크기를 강제로 재조정합니다
6498 * @type {number}
6499 * @default -1
6500 * @see {@link https://naver.github.io/egjs-flicking/Options#panelsperview panelsPerView ( Options )}
6501 */
6502 get: function () {
6503 return this._panelsPerView;
6504 },
6505 set: function (val) {
6506 this._panelsPerView = val;
6507 void this.resize();
6508 },
6509 enumerable: false,
6510 configurable: true
6511 });
6512 Object.defineProperty(__proto, "noPanelStyleOverride", {
6513 /**
6514 * Enabling this option will not change `width/height` style of the panels if {@link Flicking#panelsPerView} is enabled.
6515 * This behavior can be useful in terms of performance when you're manually managing all panel sizes
6516 * @ko 이 옵션을 활성화할 경우, {@link Flicking#panelsPerView} 옵션이 활성화되었을 때 패널의 `width/height` 스타일을 변경하지 않도록 설정합니다.
6517 * 모든 패널들의 크기를 직접 관리하고 있을 경우, 이 옵션을 활성화하면 성능면에서 유리할 수 있습니다
6518 * @type {boolean}
6519 * @default false
6520 */
6521 get: function () {
6522 return this._noPanelStyleOverride;
6523 },
6524 set: function (val) {
6525 this._noPanelStyleOverride = val;
6526 void this.resize();
6527 },
6528 enumerable: false,
6529 configurable: true
6530 });
6531 Object.defineProperty(__proto, "resizeOnContentsReady", {
6532 /**
6533 * Enabling this option will automatically call {@link Flicking#resize} when all image/video inside panels are loaded.
6534 * This can be useful when you have contents inside Flicking that changes its size when it's loaded
6535 * @ko 이 옵션을 활성화할 경우, Flicking 패널 내부의 이미지/비디오들이 로드되었을 때 자동으로 {@link Flicking#resize}를 호출합니다.
6536 * 이 동작은 Flicking 내부에 로드 전/후로 크기가 변하는 콘텐츠를 포함하고 있을 때 유용하게 사용하실 수 있습니다.
6537 * @type {boolean}
6538 * @default false
6539 * @see {@link https://naver.github.io/egjs-flicking/Options#resizeOnContentsReady resizeOnContentsReady ( Options )}
6540 */
6541 get: function () {
6542 return this._resizeOnContentsReady;
6543 },
6544 set: function (val) {
6545 this._resizeOnContentsReady = val;
6546 if (val) {
6547 this._renderer.checkPanelContentsReady(this._renderer.panels);
6548 }
6549 },
6550 enumerable: false,
6551 configurable: true
6552 });
6553 Object.defineProperty(__proto, "nested", {
6554 /**
6555 * If you enable this option on child Flicking when the Flicking is placed inside the Flicking, the parent Flicking will move in the same direction after the child Flicking reaches the first/last panel.
6556 * If the parent Flicking and child Flicking have different horizontal option, you do not need to set this option.
6557 * @ko Flicking 내부에 Flicking이 배치될 때 하위 Flicking에서 이 옵션을 활성화하면 하위 Flicking이 첫/마지막 패널에 도달한 뒤부터 같은 방향으로 상위 Flicking이 움직입니다.
6558 * 만약 상위 Flicking과 하위 Flicking이 서로 다른 horizontal 옵션을 가지고 있다면 이 옵션을 설정할 필요가 없습니다.
6559 * @type {boolean}
6560 * @default false
6561 * @see {@link https://naver.github.io/egjs-flicking/Options#nested nested ( Options )}
6562 */
6563 get: function () {
6564 return this._nested;
6565 },
6566 set: function (val) {
6567 this._nested = val;
6568 var axes = this._control.controller.axes;
6569 if (axes) {
6570 axes.options.nested = val;
6571 }
6572 },
6573 enumerable: false,
6574 configurable: true
6575 });
6576 Object.defineProperty(__proto, "needPanelThreshold", {
6577 // EVENTS
6578 /**
6579 * A Threshold from viewport edge before triggering `needPanel` event
6580 * @ko `needPanel`이벤트가 발생하기 위한 뷰포트 끝으로부터의 최대 거리
6581 * @type {number}
6582 * @default 0
6583 * @see {@link https://naver.github.io/egjs-flicking/Options#needpanelthreshold needPanelThreshold ( Options )}
6584 */
6585 get: function () {
6586 return this._needPanelThreshold;
6587 },
6588 // EVENTS
6589 set: function (val) {
6590 this._needPanelThreshold = val;
6591 },
6592 enumerable: false,
6593 configurable: true
6594 });
6595 Object.defineProperty(__proto, "preventEventsBeforeInit", {
6596 /**
6597 * When enabled, events are not triggered before `ready` when initializing
6598 * @ko 활성화할 경우 초기화시 `ready` 이벤트 이전의 이벤트가 발생하지 않습니다.
6599 * @type {boolean}
6600 * @default true
6601 * @see {@link https://naver.github.io/egjs-flicking/Options#preventeventsbeforeinit preventEventsBeforeInit ( Options )}
6602 */
6603 get: function () {
6604 return this._preventEventsBeforeInit;
6605 },
6606 set: function (val) {
6607 this._preventEventsBeforeInit = val;
6608 },
6609 enumerable: false,
6610 configurable: true
6611 });
6612 Object.defineProperty(__proto, "deceleration", {
6613 // ANIMATION
6614 /**
6615 * Deceleration value for panel movement animation which is triggered by user input. A higher value means a shorter animation time
6616 * @ko 사용자의 동작으로 가속도가 적용된 패널 이동 애니메이션의 감속도. 값이 높을수록 애니메이션 실행 시간이 짧아집니다
6617 * @type {number}
6618 * @default 0.0075
6619 * @see {@link https://naver.github.io/egjs-flicking/Options#deceleration deceleration ( Options )}
6620 */
6621 get: function () {
6622 return this._deceleration;
6623 },
6624 // ANIMATION
6625 set: function (val) {
6626 this._deceleration = val;
6627 var axes = this._control.controller.axes;
6628 if (axes) {
6629 axes.options.deceleration = val;
6630 }
6631 },
6632 enumerable: false,
6633 configurable: true
6634 });
6635 Object.defineProperty(__proto, "easing", {
6636 /**
6637 * An easing function applied to the panel movement animation. Default value is `easeOutCubic`
6638 * @ko 패널 이동 애니메이션에 적용할 easing 함수. 기본값은 `easeOutCubic`이다
6639 * @type {function}
6640 * @default x => 1 - Math.pow(1 - x, 3)
6641 * @see Easing Functions Cheat Sheet {@link http://easings.net/} <ko>이징 함수 Cheat Sheet {@link http://easings.net/}</ko>
6642 * @see {@link https://naver.github.io/egjs-flicking/Options#easing Easing ( Options )}
6643 */
6644 get: function () {
6645 return this._easing;
6646 },
6647 set: function (val) {
6648 this._easing = val;
6649 var axes = this._control.controller.axes;
6650 if (axes) {
6651 axes.options.easing = val;
6652 }
6653 },
6654 enumerable: false,
6655 configurable: true
6656 });
6657 Object.defineProperty(__proto, "duration", {
6658 /**
6659 * Default duration of the animation (ms)
6660 * @ko 디폴트 애니메이션 재생 시간 (ms)
6661 * @type {number}
6662 * @default 500
6663 * @see {@link https://naver.github.io/egjs-flicking/Options#duration duration ( Options )}
6664 */
6665 get: function () {
6666 return this._duration;
6667 },
6668 set: function (val) {
6669 this._duration = val;
6670 },
6671 enumerable: false,
6672 configurable: true
6673 });
6674 Object.defineProperty(__proto, "inputType", {
6675 // INPUT
6676 /**
6677 * Types of input devices to enable
6678 * @ko 활성화할 입력 장치 종류
6679 * @type {string[]}
6680 * @default ["touch", "mouse"]
6681 * @see {@link https://naver.github.io/egjs-axes/Options#paninput-options Possible values (PanInputOption#inputType)}
6682 * <ko>{@link https://naver.github.io/egjs-axes/Options#paninput-options 가능한 값들 (PanInputOption#inputType)}</ko>
6683 * @see {@link https://naver.github.io/egjs-flicking/Options#inputtype inputType ( Options )}
6684 */
6685 get: function () {
6686 return this._inputType;
6687 },
6688 // INPUT
6689 set: function (val) {
6690 this._inputType = val;
6691 var panInput = this._control.controller.panInput;
6692 if (panInput) {
6693 panInput.options.inputType = val;
6694 }
6695 },
6696 enumerable: false,
6697 configurable: true
6698 });
6699 Object.defineProperty(__proto, "moveType", {
6700 /**
6701 * Movement style by user input. This will change instance type of {@link Flicking#control}
6702 * You can use the values of the constant {@link MOVE_TYPE}
6703 * @ko 사용자 입력에 의한 이동 방식. 이 값에 따라 {@link Flicking#control}의 인스턴스 타입이 결정됩니다
6704 * 상수 {@link MOVE_TYPE}에 정의된 값들을 이용할 수 있습니다
6705 * @type {MOVE_TYPE | Pair<string, object>}
6706 * @default "snap"
6707 * @see {@link https://naver.github.io/egjs-flicking/Options#movetype moveType ( Options )}
6708 * @example
6709 * |moveType|control|options|
6710 * |:---:|:---:|:---:|
6711 * |"snap"|{@link SnapControl}||
6712 * |"freeScroll"|{@link FreeControl}|{@link FreeControlOptions}|
6713 *
6714 * ```ts
6715 * import Flicking, { MOVE_TYPE } from "@egjs/flicking";
6716 *
6717 * const flicking = new Flicking({
6718 * moveType: MOVE_TYPE.SNAP
6719 * });
6720 * ```
6721 *
6722 * ```ts
6723 * const flicking = new Flicking({
6724 * // If you want more specific settings for the moveType
6725 * // [moveType, options for that moveType]
6726 * // In this case, it's ["freeScroll", FreeControlOptions]
6727 * moveType: [MOVE_TYPE.FREE_SCROLL, { stopAtEdge: true }]
6728 * });
6729 * ```
6730 */
6731 get: function () {
6732 return this._moveType;
6733 },
6734 set: function (val) {
6735 this._moveType = val;
6736 var prevControl = this._control;
6737 var newControl = this._createControl();
6738 var activePanel = prevControl.activePanel;
6739 newControl.copy(prevControl);
6740 var prevProgressInPanel = activePanel ? this._camera.getProgressInPanel(activePanel) : 0;
6741 this._control = newControl;
6742 this._control.updatePosition(prevProgressInPanel);
6743 this._control.updateInput();
6744 },
6745 enumerable: false,
6746 configurable: true
6747 });
6748 Object.defineProperty(__proto, "threshold", {
6749 /**
6750 * Movement threshold to change panel (unit: px). It should be dragged above the threshold to change the current panel.
6751 * @ko 패널 변경을 위한 이동 임계값 (단위: px). 주어진 값 이상으로 스크롤해야만 패널 변경이 가능하다.
6752 * @type {number}
6753 * @default 40
6754 * @see {@link https://naver.github.io/egjs-flicking/Options#threshold Threshold ( Options )}
6755 */
6756 get: function () {
6757 return this._threshold;
6758 },
6759 set: function (val) {
6760 this._threshold = val;
6761 },
6762 enumerable: false,
6763 configurable: true
6764 });
6765 Object.defineProperty(__proto, "interruptable", {
6766 /**
6767 * Set animation to be interruptable by click/touch.
6768 * @ko 사용자의 클릭/터치로 인해 애니메이션을 도중에 멈출 수 있도록 설정합니다.
6769 * @type {boolean}
6770 * @default true
6771 * @see {@link https://naver.github.io/egjs-flicking/Options#interruptable Interruptable ( Options )}
6772 */
6773 get: function () {
6774 return this._interruptable;
6775 },
6776 set: function (val) {
6777 this._interruptable = val;
6778 var axes = this._control.controller.axes;
6779 if (axes) {
6780 axes.options.interruptable = val;
6781 }
6782 },
6783 enumerable: false,
6784 configurable: true
6785 });
6786 Object.defineProperty(__proto, "bounce", {
6787 /**
6788 * The size value of the bounce area. Only can be enabled when `circular=false`.
6789 * You can set different bounce value for prev/next direction by using array.
6790 * `number` for px value, and `string` for px, and % value relative to viewport size.
6791 * You have to call {@link Control#updateInput} after changing this to take effect.
6792 * @ko Flicking이 최대 영역을 넘어서 갈 수 있는 최대 크기. `circular=false`인 경우에만 사용할 수 있습니다.
6793 * 배열을 통해 prev/next 방향에 대해 서로 다른 바운스 값을 지정할 수 있습니다.
6794 * `number`를 통해 px값을, `stirng`을 통해 px 혹은 뷰포트 크기 대비 %값을 사용할 수 있습니다.
6795 * 이 값을 변경시 {@link Control#updateInput}를 호출해야 합니다.
6796 * @type {string | number | Array<string | number>}
6797 * @default "20%"
6798 * @see {@link https://naver.github.io/egjs-flicking/Options#bounce bounce ( Options )}
6799 * @example
6800 * ```ts
6801 * const possibleOptions = [
6802 * // % values, relative to viewport element(".flicking-viewport")'s size
6803 * "0%", "25%", "42%",
6804 * // px values, arithmetic calculation with (+/-) is also allowed.
6805 * "0px", "100px", "50% - 25px",
6806 * // numbers, same to number + px ("0px", "100px")
6807 * 0, 100, 1000
6808 * ];
6809 * ```
6810 *
6811 * @example
6812 * ```ts
6813 * const flicking = new Flicking("#el", { bounce: "20%" });
6814 *
6815 * flicking.bounce = "100%";
6816 * flicking.control.updateInput(); // Call this to update!
6817 * ```
6818 */
6819 get: function () {
6820 return this._bounce;
6821 },
6822 set: function (val) {
6823 this._bounce = val;
6824 this._control.updateInput();
6825 },
6826 enumerable: false,
6827 configurable: true
6828 });
6829 Object.defineProperty(__proto, "iOSEdgeSwipeThreshold", {
6830 /**
6831 * Size of the area from the right edge in iOS safari (in px) which enables swipe-back or swipe-forward
6832 * @ko iOS Safari에서 swipe를 통한 뒤로가기/앞으로가기를 활성화하는 오른쪽 끝으로부터의 영역의 크기 (px)
6833 * @type {number}
6834 * @default 30
6835 * @see {@link https://naver.github.io/egjs-flicking/Options#iosedgeswipethreshold iOSEdgeSwipeThreshold ( Options )}
6836 */
6837 get: function () {
6838 return this._iOSEdgeSwipeThreshold;
6839 },
6840 set: function (val) {
6841 this._iOSEdgeSwipeThreshold = val;
6842 var panInput = this._control.controller.panInput;
6843 if (panInput) {
6844 panInput.options.iOSEdgeSwipeThreshold = val;
6845 }
6846 },
6847 enumerable: false,
6848 configurable: true
6849 });
6850 Object.defineProperty(__proto, "preventClickOnDrag", {
6851 /**
6852 * Automatically prevent `click` event if the user has dragged at least a single pixel on the viewport element
6853 * @ko 사용자가 뷰포트 영역을 1픽셀이라도 드래그했을 경우 자동으로 {@link https://developer.mozilla.org/ko/docs/Web/API/Element/click_event click} 이벤트를 취소합니다
6854 * @type {boolean}
6855 * @default true
6856 * @see {@link https://naver.github.io/egjs-flicking/Options#preventclickondrag preventClickOnDrag ( Options )}
6857 */
6858 get: function () {
6859 return this._preventClickOnDrag;
6860 },
6861 set: function (val) {
6862 var prevVal = this._preventClickOnDrag;
6863 if (val === prevVal) return;
6864 var controller = this._control.controller;
6865 if (val) {
6866 controller.addPreventClickHandler();
6867 } else {
6868 controller.removePreventClickHandler();
6869 }
6870 this._preventClickOnDrag = val;
6871 },
6872 enumerable: false,
6873 configurable: true
6874 });
6875 Object.defineProperty(__proto, "preventDefaultOnDrag", {
6876 /**
6877 * Whether to use the {@link https://developer.mozilla.org/ko/docs/Web/API/Event/preventDefault preventDefault} when the user starts dragging
6878 * @ko 사용자가 드래그를 시작할 때 {@link https://developer.mozilla.org/ko/docs/Web/API/Event/preventDefault preventDefault} 실행 여부
6879 * @type {boolean}
6880 * @default false
6881 * @see {@link https://naver.github.io/egjs-flicking/Options#preventDefaultOnDrag preventDefaultOnDrag ( Options )}
6882 */
6883 get: function () {
6884 return this._preventDefaultOnDrag;
6885 },
6886 set: function (val) {
6887 this._preventDefaultOnDrag = val;
6888 var panInput = this._control.controller.panInput;
6889 if (panInput) {
6890 panInput.options.preventDefaultOnDrag = val;
6891 }
6892 },
6893 enumerable: false,
6894 configurable: true
6895 });
6896 Object.defineProperty(__proto, "disableOnInit", {
6897 /**
6898 * Automatically call {@link Flicking#disableInput disableInput()} on initialization
6899 * @ko Flicking init시에 {@link Flicking#disableInput disableInput()}을 바로 호출합니다
6900 * @type {boolean}
6901 * @default false
6902 * @see {@link https://naver.github.io/egjs-flicking/Options#disableoninit disableOnInit ( Options )}
6903 */
6904 get: function () {
6905 return this._disableOnInit;
6906 },
6907 set: function (val) {
6908 this._disableOnInit = val;
6909 },
6910 enumerable: false,
6911 configurable: true
6912 });
6913 Object.defineProperty(__proto, "changeOnHold", {
6914 /**
6915 * Change active panel index on mouse/touch hold while animating.
6916 * `index` of the `willChange`/`willRestore` event will be used as new index.
6917 * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
6918 * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
6919 * @type {boolean}
6920 * @default false
6921 * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
6922 */
6923 get: function () {
6924 return this._changeOnHold;
6925 },
6926 set: function (val) {
6927 this._changeOnHold = val;
6928 },
6929 enumerable: false,
6930 configurable: true
6931 });
6932 Object.defineProperty(__proto, "renderOnlyVisible", {
6933 // PERFORMANCE
6934 /**
6935 * Whether to render visible panels only. This can dramatically increase performance when there're many panels
6936 * @ko 보이는 패널만 렌더링할지 여부를 설정합니다. 패널이 많을 경우에 퍼포먼스를 크게 향상시킬 수 있습니다
6937 * @type {boolean}
6938 * @default false
6939 * @see {@link https://naver.github.io/egjs-flicking/Options#renderonlyvisible renderOnlyVisible ( Options )}
6940 */
6941 get: function () {
6942 return this._renderOnlyVisible;
6943 },
6944 // PERFORMANCE
6945 set: function (val) {
6946 this._renderOnlyVisible = val;
6947 void this._renderer.render();
6948 },
6949 enumerable: false,
6950 configurable: true
6951 });
6952 Object.defineProperty(__proto, "virtual", {
6953 /**
6954 * By enabling this option, it will reduce memory consumption by restricting the number of DOM elements to `panelsPerView + 1`
6955 * Must be used with `panelsPerview`.
6956 * After Flicking's initialized, this property can be used to add/remove the panel count.
6957 * @ko 이 옵션을 활성화할 경우 패널 엘리먼트의 개수를 `panelsPerView + 1` 개로 고정함으로써, 메모리 사용량을 줄일 수 있습니다.
6958 * `panelsPerView` 옵션과 함께 사용되어야만 합니다.
6959 * Flicking 초기화 이후에, 이 프로퍼티는 렌더링하는 패널의 개수를 추가/제거하기 위해 사용될 수 있습니다.
6960 * @type {VirtualManager}
6961 * @property {function} renderPanel A rendering function for the panel element's innerHTML<ko>패널 엘리먼트의 innerHTML을 렌더링하는 함수</ko>
6962 * @property {number} initialPanelCount Initial panel count to render<ko>최초로 렌더링할 패널의 개수</ko>
6963 * @property {boolean} [cache=false] Whether to cache rendered panel's innerHTML<ko>렌더링된 패널의 innerHTML 정보를 캐시할지 여부</ko>
6964 * @property {string} [panelClass="flicking-panel"] The class name that will be applied to rendered panel elements<ko>렌더링되는 패널 엘리먼트에 적용될 클래스 이름</ko>
6965 * @see {@link https://naver.github.io/egjs-flicking/Options#virtual virtual ( Options )}
6966 * @example
6967 * ```ts
6968 * import Flicking, { VirtualPanel } from "@egjs/flicking";
6969 *
6970 * const flicking = new Flicking("#some_el", {
6971 * panelsPerView: 3,
6972 * virtual: {
6973 * renderPanel: (panel: VirtualPanel, index: number) => `Panel ${index}`,
6974 * initialPanelCount: 100
6975 * }
6976 * });
6977 *
6978 * // Add 100 virtual panels (at the end)
6979 * flicking.virtual.append(100);
6980 *
6981 * // Remove 100 virtual panels from 0 to 100
6982 * flicking.virtual.remove(0, 100);
6983 * ```
6984 */
6985 get: function () {
6986 return this._virtualManager;
6987 },
6988 enumerable: false,
6989 configurable: true
6990 });
6991 Object.defineProperty(__proto, "autoInit", {
6992 // OTHERS
6993 /**
6994 * Call {@link Flicking#init init()} automatically when creating Flicking's instance
6995 * @ko Flicking 인스턴스를 생성할 때 자동으로 {@link Flicking#init init()}를 호출합니다
6996 * @type {boolean}
6997 * @default true
6998 * @see {@link https://naver.github.io/egjs-flicking/Options#autoinit autoInit ( Options )}
6999 * @readonly
7000 */
7001 get: function () {
7002 return this._autoInit;
7003 },
7004 enumerable: false,
7005 configurable: true
7006 });
7007 Object.defineProperty(__proto, "autoResize", {
7008 /**
7009 * Whether to automatically call {@link Flicking#resize resize()} when the viewport element(.flicking-viewport)'s size is changed
7010 * @ko 뷰포트 엘리먼트(.flicking-viewport)의 크기 변경시 {@link Flicking#resize resize()} 메소드를 자동으로 호출할지 여부를 설정합니다
7011 * @type {boolean}
7012 * @default true
7013 */
7014 get: function () {
7015 return this._autoResize;
7016 },
7017 // OTHERS
7018 set: function (val) {
7019 this._autoResize = val;
7020 if (val) {
7021 this._autoResizer.enable();
7022 } else {
7023 this._autoResizer.disable();
7024 }
7025 },
7026 enumerable: false,
7027 configurable: true
7028 });
7029 Object.defineProperty(__proto, "useResizeObserver", {
7030 /**
7031 * Whether to listen {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}'s event instead of Window's {@link https://developer.mozilla.org/ko/docs/Web/API/Window/resize_event resize} event when using the `autoResize` option
7032 * @ko autoResize 옵션 사용시 {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}의 이벤트를 Window객체의 {@link https://developer.mozilla.org/ko/docs/Web/API/Window/resize_event resize} 이벤트 대신 수신할지 여부를 설정합니다
7033 * @type {boolean}
7034 * @default true
7035 * @see {@link https://naver.github.io/egjs-flicking/Options#useresizeobserver useResizeObserver ( Options )}
7036 */
7037 get: function () {
7038 return this._useResizeObserver;
7039 },
7040 set: function (val) {
7041 this._useResizeObserver = val;
7042 if (this._autoResize) {
7043 this._autoResizer.enable();
7044 }
7045 },
7046 enumerable: false,
7047 configurable: true
7048 });
7049 Object.defineProperty(__proto, "resizeDebounce", {
7050 /**
7051 * Delays size recalculation from `autoResize` by the given time in milisecond.
7052 * If the size is changed again while being delayed, it cancels the previous one and delays from the beginning again.
7053 * This can increase performance by preventing `resize` being called too often.
7054 * @ko `autoResize` 설정시에 호출되는 크기 재계산을 주어진 시간(단위: ms)만큼 지연시킵니다.
7055 * 지연시키는 도중 크기가 다시 변경되었을 경우, 이전 것을 취소하고 주어진 시간만큼 다시 지연시킵니다.
7056 * 이를 통해 `resize`가 너무 많이 호출되는 것을 방지하여 성능을 향상시킬 수 있습니다.
7057 * @type {number}
7058 * @default 0
7059 * @see {@link https://naver.github.io/egjs-flicking/Options#resizedebounce resizeDebounce ( Options )}
7060 */
7061 get: function () {
7062 return this._resizeDebounce;
7063 },
7064 enumerable: false,
7065 configurable: true
7066 });
7067 Object.defineProperty(__proto, "maxResizeDebounce", {
7068 /**
7069 * The maximum time for size recalculation delay when using `resizeDebounce`, in milisecond.
7070 * This guarantees that size recalculation is performed at least once every (n)ms.
7071 * @ko `resizeDebounce` 사용시에 크기 재계산이 지연되는 최대 시간을 지정합니다. (단위: ms)
7072 * 이를 통해, 적어도 (n)ms에 한번은 크기 재계산을 수행하는 것을 보장할 수 있습니다.
7073 * @type {number}
7074 * @default 100
7075 * @see {@link https://naver.github.io/egjs-flicking/Options#maxresizedebounce maxResizeDebounce ( Options )}
7076 */
7077 get: function () {
7078 return this._maxResizeDebounce;
7079 },
7080 enumerable: false,
7081 configurable: true
7082 });
7083 Object.defineProperty(__proto, "useFractionalSize", {
7084 /**
7085 * By enabling this, Flicking will calculate all internal size with CSS width computed with getComputedStyle.
7086 * This can prevent 1px offset issue in some cases where panel size has the fractional part.
7087 * All sizes will have the original size before CSS {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform} is applied on the element.
7088 * @ko 이 옵션을 활성화할 경우, Flicking은 내부의 모든 크기를 {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect getBoundingClientRect}를 이용하여 계산합니다.
7089 * 이를 통해, 패널 크기에 소수점을 포함할 경우에 발생할 수 있는 일부 1px 오프셋 이슈를 해결 가능합니다.
7090 * 모든 크기는 CSS {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform}이 엘리먼트에 적용되기 이전의 크기를 사용할 것입니다.
7091 * @type {boolean}
7092 * @default false
7093 * @see {@link https://naver.github.io/egjs-flicking/Options#usefractionalsize useFractionalSize ( Options )}
7094 */
7095 get: function () {
7096 return this._useFractionalSize;
7097 },
7098 enumerable: false,
7099 configurable: true
7100 });
7101 Object.defineProperty(__proto, "externalRenderer", {
7102 /**
7103 * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
7104 * @ko 프레임워크(React, Vue, Angular, ...)에서만 사용하는 옵션으로, 자동으로 설정되므로 따로 사용하실 필요 없습니다!
7105 * @default null
7106 * @internal
7107 * @readonly
7108 */
7109 get: function () {
7110 return this._externalRenderer;
7111 },
7112 enumerable: false,
7113 configurable: true
7114 });
7115 Object.defineProperty(__proto, "renderExternal", {
7116 /**
7117 * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
7118 * @ko 프레임워크(React, Vue, Angular, ...)에서만 사용하는 옵션으로, 자동으로 설정되므로 따로 사용하실 필요 없습니다!
7119 * @default null
7120 * @internal
7121 * @readonly
7122 * @deprecated
7123 */
7124 get: function () {
7125 return this._renderExternal;
7126 },
7127 enumerable: false,
7128 configurable: true
7129 });
7130 /**
7131 * Initialize Flicking and move to the default index
7132 * This is automatically called on Flicking's constructor when `autoInit` is true(default)
7133 * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
7134 * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
7135 * @fires Flicking#ready
7136 * @return {Promise<void>}
7137 */
7138 __proto.init = function () {
7139 var _this = this;
7140 if (this._initialized) return Promise.resolve();
7141 var camera = this._camera;
7142 var renderer = this._renderer;
7143 var control = this._control;
7144 var virtualManager = this._virtualManager;
7145 var originalTrigger = this.trigger;
7146 var preventEventsBeforeInit = this._preventEventsBeforeInit;
7147 camera.init();
7148 virtualManager.init();
7149 renderer.init(this);
7150 control.init(this);
7151 if (preventEventsBeforeInit) {
7152 this.trigger = function () {
7153 return _this;
7154 };
7155 }
7156 this._initialResize();
7157 // Look at initial panel
7158 this._moveToInitialPanel();
7159 if (this._autoResize) {
7160 this._autoResizer.enable();
7161 }
7162 if (this._preventClickOnDrag) {
7163 control.controller.addPreventClickHandler();
7164 }
7165 if (this._disableOnInit) {
7166 this.disableInput();
7167 }
7168 renderer.checkPanelContentsReady(renderer.panels);
7169 this._initialized = true;
7170 return renderer.render().then(function () {
7171 // Done initializing & emit ready event
7172 _this._plugins.forEach(function (plugin) {
7173 return plugin.init(_this);
7174 });
7175 if (preventEventsBeforeInit) {
7176 _this.trigger = originalTrigger;
7177 }
7178 _this.trigger(new ComponentEvent(EVENTS.READY));
7179 });
7180 };
7181 /**
7182 * Destroy Flicking and remove all event handlers
7183 * @ko Flicking과 하위 컴포넌트들을 초기 상태로 되돌리고, 부착된 모든 이벤트 핸들러를 제거합니다
7184 * @return {void}
7185 */
7186 __proto.destroy = function () {
7187 this.off();
7188 this._autoResizer.disable();
7189 this._control.destroy();
7190 this._camera.destroy();
7191 this._renderer.destroy();
7192 this._plugins.forEach(function (plugin) {
7193 return plugin.destroy();
7194 });
7195 this._initialized = false;
7196 };
7197 /**
7198 * Move to the previous panel (current index - 1)
7199 * @ko 이전 패널로 이동합니다 (현재 인덱스 - 1)
7200 * @param {number} [duration={@link Flicking#duration options.duration}] Duration of the panel movement animation (unit: ms)<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
7201 * @async
7202 * @fires Flicking#moveStart
7203 * @fires Flicking#move
7204 * @fires Flicking#moveEnd
7205 * @fires Flicking#willChange
7206 * @fires Flicking#changed
7207 * @fires Flicking#willRestore
7208 * @fires Flicking#restored
7209 * @fires Flicking#needPanel
7210 * @fires Flicking#visibleChange
7211 * @fires Flicking#reachEdge
7212 * @throws {FlickingError}
7213 * |code|condition|
7214 * |---|---|
7215 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|When the previous panel does not exist|
7216 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|When the animation is already playing|
7217 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
7218 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the any of the event's `stop()` is called|
7219 * <ko>
7220 *
7221 * |code|condition|
7222 * |---|---|
7223 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|이전 패널이 존재하지 않을 경우|
7224 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|애니메이션이 이미 진행중인 경우|
7225 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
7226 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
7227 * </ko>
7228 * @return {Promise<void>} A Promise which will be resolved after reaching the previous panel<ko>이전 패널 도달시에 resolve되는 Promise</ko>
7229 */
7230 __proto.prev = function (duration) {
7231 var _a, _b, _c;
7232 if (duration === void 0) {
7233 duration = this._duration;
7234 }
7235 return this.moveTo((_c = (_b = (_a = this._control.activePanel) === null || _a === void 0 ? void 0 : _a.prev()) === null || _b === void 0 ? void 0 : _b.index) !== null && _c !== void 0 ? _c : -1, duration, DIRECTION.PREV);
7236 };
7237 /**
7238 * Move to the next panel (current index + 1)
7239 * @ko 다음 패널로 이동합니다 (현재 인덱스 + 1)
7240 * @param {number} [duration={@link Flicking#duration options.duration}] Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
7241 * @async
7242 * @fires Flicking#moveStart
7243 * @fires Flicking#move
7244 * @fires Flicking#moveEnd
7245 * @fires Flicking#willChange
7246 * @fires Flicking#changed
7247 * @fires Flicking#willRestore
7248 * @fires Flicking#restored
7249 * @fires Flicking#needPanel
7250 * @fires Flicking#visibleChange
7251 * @fires Flicking#reachEdge
7252 * @throws {FlickingError}
7253 * |code|condition|
7254 * |---|---|
7255 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|When the next panel does not exist|
7256 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|When the animation is already playing|
7257 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
7258 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the any of the event's `stop()` is called|
7259 * <ko>
7260 *
7261 * |code|condition|
7262 * |---|---|
7263 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|다음 패널이 존재하지 않을 경우|
7264 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|애니메이션이 이미 진행중인 경우|
7265 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
7266 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
7267 *
7268 * </ko>
7269 * @return {Promise<void>} A Promise which will be resolved after reaching the next panel<ko>다음 패널 도달시에 resolve되는 Promise</ko>
7270 */
7271 __proto.next = function (duration) {
7272 var _a, _b, _c;
7273 if (duration === void 0) {
7274 duration = this._duration;
7275 }
7276 return this.moveTo((_c = (_b = (_a = this._control.activePanel) === null || _a === void 0 ? void 0 : _a.next()) === null || _b === void 0 ? void 0 : _b.index) !== null && _c !== void 0 ? _c : this._renderer.panelCount, duration, DIRECTION.NEXT);
7277 };
7278 /**
7279 * Move to the panel with given index
7280 * @ko 주어진 인덱스에 해당하는 패널로 이동합니다
7281 * @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
7282 * @param {number} [duration={@link Flicking#duration options.duration}] Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
7283 * @param {DIRECTION} [direction=DIRECTION.NONE] Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
7284 * @async
7285 * @fires Flicking#moveStart
7286 * @fires Flicking#move
7287 * @fires Flicking#moveEnd
7288 * @fires Flicking#willChange
7289 * @fires Flicking#changed
7290 * @fires Flicking#willRestore
7291 * @fires Flicking#restored
7292 * @fires Flicking#needPanel
7293 * @fires Flicking#visibleChange
7294 * @fires Flicking#reachEdge
7295 * @throws {FlickingError}
7296 * |code|condition|
7297 * |---|---|
7298 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|When the root is not either string or HTMLElement|
7299 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|When the animation is already playing|
7300 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
7301 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the any of the event's `stop()` is called|
7302 * <ko>
7303 *
7304 * |code|condition|
7305 * |---|---|
7306 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|해당 인덱스를 가진 패널이 존재하지 않을 경우|
7307 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|애니메이션이 이미 진행중인 경우|
7308 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
7309 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
7310 *
7311 * </ko>
7312 * @return {Promise<void>} A Promise which will be resolved after reaching the target panel<ko>해당 패널 도달시에 resolve되는 Promise</ko>
7313 */
7314 __proto.moveTo = function (index, duration, direction) {
7315 if (duration === void 0) {
7316 duration = this._duration;
7317 }
7318 if (direction === void 0) {
7319 direction = DIRECTION.NONE;
7320 }
7321 var renderer = this._renderer;
7322 var panelCount = renderer.panelCount;
7323 var panel = renderer.getPanel(index);
7324 if (!panel) {
7325 return Promise.reject(new FlickingError(MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), CODE.INDEX_OUT_OF_RANGE));
7326 }
7327 if (this._control.animating) {
7328 return Promise.reject(new FlickingError(MESSAGE.ANIMATION_ALREADY_PLAYING, CODE.ANIMATION_ALREADY_PLAYING));
7329 }
7330 if (this._control.holding) {
7331 this._control.controller.release();
7332 }
7333 return this._control.moveToPanel(panel, {
7334 duration: duration,
7335 direction: direction
7336 });
7337 };
7338 /**
7339 * Change the destination and duration of the animation currently playing
7340 * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
7341 * @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
7342 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
7343 * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
7344 * @throws {FlickingError}
7345 * {@link ERROR_CODE INDEX_OUT_OF_RANGE} When the root is not either string or HTMLElement
7346 * <ko>{@link ERROR_CODE INDEX_OUT_OF_RANGE} 해당 인덱스를 가진 패널이 존재하지 않을 경우</ko>
7347 * @return {void}
7348 */
7349 __proto.updateAnimation = function (index, duration, direction) {
7350 if (!this._control.animating) {
7351 return;
7352 }
7353 var renderer = this._renderer;
7354 var panelCount = renderer.panelCount;
7355 var panel = renderer.getPanel(index);
7356 if (!panel) {
7357 throw new FlickingError(MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), CODE.INDEX_OUT_OF_RANGE);
7358 }
7359 this._control.updateAnimation(panel, duration, direction);
7360 };
7361 /**
7362 * Stops the animation currently playing
7363 * @ko 재생 중인 애니메이션을 중단시킵니다
7364 * @fires Flicking#moveEnd
7365 * @return {void}
7366 */
7367 __proto.stopAnimation = function () {
7368 if (!this._control.animating) {
7369 return;
7370 }
7371 this._control.stopAnimation();
7372 };
7373 /**
7374 * Return the {@link Panel} at the given index. `null` if it doesn't exists.
7375 * @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
7376 * @return {Panel | null} Panel at the given index<ko>주어진 인덱스에 해당하는 패널</ko>
7377 * @see Panel
7378 * @example
7379 * ```ts
7380 * const panel = flicking.getPanel(0);
7381 * // Which is a shorthand to...
7382 * const samePanel = flicking.panels[0];
7383 * ```
7384 */
7385 __proto.getPanel = function (index) {
7386 return this._renderer.getPanel(index);
7387 };
7388 /**
7389 * Enable input from the user (mouse/touch)
7390 * @ko 사용자의 입력(마우스/터치)를 활성화합니다
7391 * @return {this}
7392 */
7393 __proto.enableInput = function () {
7394 this._control.enable();
7395 return this;
7396 };
7397 /**
7398 * Disable input from the user (mouse/touch)
7399 * @ko 사용자의 입력(마우스/터치)를 막습니다
7400 * @return {this}
7401 */
7402 __proto.disableInput = function () {
7403 this._control.disable();
7404 return this;
7405 };
7406 /**
7407 * Get current flicking status. You can restore current state by giving returned value to {@link Flicking#setStatus setStatus()}
7408 * @ko 현재 상태를 반환합니다. 반환받은 값을 {@link Flicking#setStatus setStatus()} 메소드의 인자로 지정하면 현재 상태를 복원할 수 있습니다
7409 * @param {object} options Status retrieving options<ko>Status 반환 옵션</ko>
7410 * @param {boolean} [options.index=true] Include current panel index to the returning status. Camera will automatically move to the given index when the {@link Flicking#setStatus setStatus} is called<ko>현재 패널 인덱스를 반환값에 포함시킵니다. {@link Flicking#setStatus setStatus} 호출시 자동으로 해당 인덱스로 카메라를 움직입니다</ko>
7411 * @param {boolean} [options.position=true] Include camera position to the returning status. This works only when the {@link Flicking#moveType moveType} is `freeScroll`<ko>카메라의 현재 위치를 반환값에 포함시킵니다. 이 옵션은 {@link Flicking#moveType moveType}이 `freeScroll`일 경우에만 동작합니다</ko>
7412 * @param {boolean} [options.includePanelHTML=false] Include panel's `outerHTML` to the returning status<ko>패널의 `outerHTML`을 반환값에 포함시킵니다</ko>
7413 * @param {boolean} [options.visiblePanelsOnly=false] Include only {@link Flicking#visiblePanel visiblePanel}'s HTML. This option is available only when the `includePanelHTML` is true
7414 * <ko>현재 보이는 패널({@link Flicking#visiblePanel visiblePanel})의 HTML만 반환합니다. `includePanelHTML`이 `true`일 경우에만 동작합니다.</ko>
7415 * @return {Status} An object with current status value information<ko>현재 상태값 정보를 가진 객체.</ko>
7416 */
7417 __proto.getStatus = function (_a) {
7418 var _b, _c;
7419 var _d = _a === void 0 ? {} : _a,
7420 _e = _d.index,
7421 index = _e === void 0 ? true : _e,
7422 _f = _d.position,
7423 position = _f === void 0 ? true : _f,
7424 _g = _d.includePanelHTML,
7425 includePanelHTML = _g === void 0 ? false : _g,
7426 _h = _d.visiblePanelsOnly,
7427 visiblePanelsOnly = _h === void 0 ? false : _h;
7428 var camera = this._camera;
7429 var panels = visiblePanelsOnly ? this.visiblePanels : this.panels;
7430 var status = {
7431 panels: panels.map(function (panel) {
7432 var panelInfo = {
7433 index: panel.index
7434 };
7435 if (includePanelHTML) {
7436 panelInfo.html = panel.element.outerHTML;
7437 }
7438 return panelInfo;
7439 })
7440 };
7441 if (index) {
7442 status.index = this.index;
7443 }
7444 if (position) {
7445 var nearestAnchor = camera.findNearestAnchor(camera.position);
7446 if (nearestAnchor) {
7447 status.position = {
7448 panel: nearestAnchor.panel.index,
7449 progressInPanel: camera.getProgressInPanel(nearestAnchor.panel)
7450 };
7451 }
7452 }
7453 if (visiblePanelsOnly) {
7454 var visiblePanels = this.visiblePanels;
7455 status.visibleOffset = (_c = (_b = visiblePanels[0]) === null || _b === void 0 ? void 0 : _b.index) !== null && _c !== void 0 ? _c : 0;
7456 }
7457 return status;
7458 };
7459 /**
7460 * Restore to the state of the given {@link Status}
7461 * @ko 주어진 {@link Status}의 상태로 복원합니다
7462 * @param {Partial<Status>} status Status value to be restored. You should use the return value of the {@link Flicking#getStatus getStatus()} method<ko>복원할 상태 값. {@link Flicking#getStatus getStatus()} 메서드의 반환값을 지정하면 됩니다</ko>
7463 * @return {void}
7464 */
7465 __proto.setStatus = function (status) {
7466 var _a;
7467 if (!this._initialized) {
7468 throw new FlickingError(MESSAGE.NOT_INITIALIZED, CODE.NOT_INITIALIZED);
7469 }
7470 var index = status.index,
7471 position = status.position,
7472 visibleOffset = status.visibleOffset,
7473 panels = status.panels;
7474 var renderer = this._renderer;
7475 var control = this._control;
7476 // Can't add/remove panels on external rendering
7477 if (((_a = panels[0]) === null || _a === void 0 ? void 0 : _a.html) && !this._renderExternal) {
7478 renderer.batchRemove({
7479 index: 0,
7480 deleteCount: this.panels.length,
7481 hasDOMInElements: true
7482 });
7483 renderer.batchInsert({
7484 index: 0,
7485 elements: parseElement(panels.map(function (panel) {
7486 return panel.html;
7487 })),
7488 hasDOMInElements: true
7489 });
7490 }
7491 if (index != null) {
7492 var panelIndex = visibleOffset ? index - visibleOffset : index;
7493 void this.moveTo(panelIndex, 0).catch(function () {
7494 return void 0;
7495 });
7496 }
7497 if (position && this._moveType === MOVE_TYPE.FREE_SCROLL) {
7498 var panel = position.panel,
7499 progressInPanel = position.progressInPanel;
7500 var panelIndex = visibleOffset ? panel - visibleOffset : panel;
7501 var panelRange = renderer.panels[panelIndex].range;
7502 var newCameraPos = panelRange.min + (panelRange.max - panelRange.min) * progressInPanel;
7503 void control.moveToPosition(newCameraPos, 0).catch(function () {
7504 return void 0;
7505 });
7506 }
7507 };
7508 /**
7509 * Add plugins that can have different effects on Flicking
7510 * @ko 플리킹에 다양한 효과를 부여할 수 있는 플러그인을 추가합니다
7511 * @param {...Plugin} plugins The plugin(s) to add<ko>추가할 플러그인(들)</ko>
7512 * @return {this}
7513 * @see https://github.com/naver/egjs-flicking-plugins
7514 */
7515 __proto.addPlugins = function () {
7516 var _a;
7517 var _this = this;
7518 var plugins = [];
7519 for (var _i = 0; _i < arguments.length; _i++) {
7520 plugins[_i] = arguments[_i];
7521 }
7522 if (this._initialized) {
7523 plugins.forEach(function (item) {
7524 return item.init(_this);
7525 });
7526 }
7527 (_a = this._plugins).push.apply(_a, __spread(plugins));
7528 return this;
7529 };
7530 /**
7531 * Remove plugins from Flicking.
7532 * @ko 플리킹으로부터 플러그인들을 제거합니다.
7533 * @param {...Plugin} plugin The plugin(s) to remove.<ko>제거 플러그인(들).</ko>
7534 * @return {this}
7535 * @see https://github.com/naver/egjs-flicking-plugins
7536 */
7537 __proto.removePlugins = function () {
7538 var _this = this;
7539 var plugins = [];
7540 for (var _i = 0; _i < arguments.length; _i++) {
7541 plugins[_i] = arguments[_i];
7542 }
7543 plugins.forEach(function (item) {
7544 var foundIndex = findIndex(_this._plugins, function (val) {
7545 return val === item;
7546 });
7547 if (foundIndex >= 0) {
7548 item.destroy();
7549 _this._plugins.splice(foundIndex, 1);
7550 }
7551 });
7552 return this;
7553 };
7554 /**
7555 * Update viewport/panel sizes
7556 * @ko 패널 및 뷰포트의 크기를 갱신합니다
7557 * @method
7558 * @fires Flicking#beforeResize
7559 * @fires Flicking#afterResize
7560 * @return {this}
7561 */
7562 __proto.resize = function () {
7563 return __awaiter(this, void 0, void 0, function () {
7564 var viewport, renderer, camera, control, activePanel, prevWidth, prevHeight, prevProgressInPanel, newWidth, newHeight, sizeChanged;
7565 return __generator(this, function (_a) {
7566 switch (_a.label) {
7567 case 0:
7568 viewport = this._viewport;
7569 renderer = this._renderer;
7570 camera = this._camera;
7571 control = this._control;
7572 activePanel = control.activePanel;
7573 prevWidth = viewport.width;
7574 prevHeight = viewport.height;
7575 prevProgressInPanel = activePanel ? camera.getProgressInPanel(activePanel) : 0;
7576 this.trigger(new ComponentEvent(EVENTS.BEFORE_RESIZE, {
7577 width: prevWidth,
7578 height: prevHeight,
7579 element: viewport.element
7580 }));
7581 viewport.resize();
7582 return [4 /*yield*/, renderer.forceRenderAllPanels()];
7583 case 1:
7584 _a.sent(); // Render all panel elements, to update sizes
7585 if (!this._initialized) {
7586 return [2 /*return*/];
7587 }
7588
7589 renderer.updatePanelSize();
7590 camera.updateAlignPos();
7591 camera.updateRange();
7592 camera.updateAnchors();
7593 camera.updateAdaptiveHeight();
7594 camera.updatePanelOrder();
7595 camera.updateOffset();
7596 return [4 /*yield*/, renderer.render()];
7597 case 2:
7598 _a.sent();
7599 if (!this._initialized) {
7600 return [2 /*return*/];
7601 }
7602
7603 if (control.animating) ; else {
7604 control.updatePosition(prevProgressInPanel);
7605 control.updateInput();
7606 }
7607 newWidth = viewport.width;
7608 newHeight = viewport.height;
7609 sizeChanged = newWidth !== prevWidth || newHeight !== prevHeight;
7610 this.trigger(new ComponentEvent(EVENTS.AFTER_RESIZE, {
7611 width: viewport.width,
7612 height: viewport.height,
7613 prev: {
7614 width: prevWidth,
7615 height: prevHeight
7616 },
7617 sizeChanged: sizeChanged,
7618 element: viewport.element
7619 }));
7620 return [2 /*return*/];
7621 }
7622 });
7623 });
7624 };
7625 /**
7626 * Add new panels after the last panel
7627 * @ko 패널 목록의 제일 끝에 새로운 패널들을 추가합니다
7628 * @param {ElementLike | ElementLike[]} element A new HTMLElement, a outerHTML of element, or an array of both
7629 * <ko>새로운 HTMLElement, 혹은 엘리먼트의 outerHTML, 혹은 그것들의 배열</ko>
7630 * @return {Panel[]} An array of appended panels<ko>추가된 패널들의 배열</ko>
7631 * @see Panel
7632 * @see ElementLike
7633 * @throws {FlickingError} {@link ERROR_CODE ERROR_CODE.NOT_ALLOWED_IN_FRAMEWORK} if called on frameworks (React, Angular, Vue...)
7634 * @example
7635 * ```ts
7636 * const flicking = new Flicking("#flick");
7637 * // These are possible parameters
7638 * flicking.append(document.createElement("div"));
7639 * flicking.append("\<div\>Panel\</div\>");
7640 * flicking.append(["\<div\>Panel\</div\>", document.createElement("div")]);
7641 * // Even this is possible
7642 * flicking.append("\<div\>Panel 1\</div\>\<div\>Panel 2\</div\>");
7643 * ```
7644 */
7645 __proto.append = function (element) {
7646 return this.insert(this._renderer.panelCount, element);
7647 };
7648 /**
7649 * Add new panels before the first panel
7650 * This will increase index of panels after by the number of panels added
7651 * @ko 패널 목록의 제일 앞(index 0)에 새로운 패널들을 추가합니다
7652 * 추가한 패널의 개수만큼 기존 패널들의 인덱스가 증가합니다.
7653 * @param {ElementLike | ElementLike[]} element A new HTMLElement, a outerHTML of element, or an array of both
7654 * <ko>새로운 HTMLElement, 혹은 엘리먼트의 outerHTML, 혹은 그것들의 배열</ko>
7655 * @return {Panel[]} An array of prepended panels<ko>추가된 패널들의 배열</ko>
7656 * @see Panel
7657 * @see ElementLike
7658 * @throws {FlickingError} {@link ERROR_CODE ERROR_CODE.NOT_ALLOWED_IN_FRAMEWORK} if called on frameworks (React, Angular, Vue...)
7659 * @example
7660 * ```ts
7661 * const flicking = new eg.Flicking("#flick");
7662 * flicking.prepend(document.createElement("div"));
7663 * flicking.prepend("\<div\>Panel\</div\>");
7664 * flicking.prepend(["\<div\>Panel\</div\>", document.createElement("div")]);
7665 * // Even this is possible
7666 * flicking.prepend("\<div\>Panel 1\</div\>\<div\>Panel 2\</div\>");
7667 * ```
7668 */
7669 __proto.prepend = function (element) {
7670 return this.insert(0, element);
7671 };
7672 /**
7673 * Insert new panels at given index
7674 * This will increase index of panels after by the number of panels added
7675 * @ko 주어진 인덱스에 새로운 패널들을 추가합니다
7676 * 해당 인덱스보다 같거나 큰 인덱스를 가진 기존 패널들은 추가한 패널의 개수만큼 인덱스가 증가합니다.
7677 * @param {number} index Index to insert new panels at<ko>새로 패널들을 추가할 인덱스</ko>
7678 * @param {ElementLike | ElementLike[]} element A new HTMLElement, a outerHTML of element, or an array of both
7679 * <ko>새로운 HTMLElement, 혹은 엘리먼트의 outerHTML, 혹은 그것들의 배열</ko>
7680 * @return {Panel[]} An array of prepended panels<ko>추가된 패널들의 배열</ko>
7681 * @throws {FlickingError} {@link ERROR_CODE ERROR_CODE.NOT_ALLOWED_IN_FRAMEWORK} if called on frameworks (React, Angular, Vue...)
7682 * @example
7683 * ```ts
7684 * const flicking = new eg.Flicking("#flick");
7685 * flicking.insert(0, document.createElement("div"));
7686 * flicking.insert(2, "\<div\>Panel\</div\>");
7687 * flicking.insert(1, ["\<div\>Panel\</div\>", document.createElement("div")]);
7688 * // Even this is possible
7689 * flicking.insert(3, "\<div\>Panel 1\</div\>\<div\>Panel 2\</div\>");
7690 * ```
7691 */
7692 __proto.insert = function (index, element) {
7693 if (this._renderExternal) {
7694 throw new FlickingError(MESSAGE.NOT_ALLOWED_IN_FRAMEWORK, CODE.NOT_ALLOWED_IN_FRAMEWORK);
7695 }
7696 return this._renderer.batchInsert({
7697 index: index,
7698 elements: parseElement(element),
7699 hasDOMInElements: true
7700 });
7701 };
7702 /**
7703 * Remove the panel at the given index
7704 * This will decrease index of panels after by the number of panels removed
7705 * @ko 주어진 인덱스의 패널을 제거합니다
7706 * 해당 인덱스보다 큰 인덱스를 가진 기존 패널들은 제거한 패널의 개수만큼 인덱스가 감소합니다
7707 * @param {number} index Index of panel to remove<ko>제거할 패널의 인덱스</ko>
7708 * @param {number} [deleteCount=1] Number of panels to remove from index<ko>`index` 이후로 제거할 패널의 개수</ko>
7709 * @return {Panel[]} An array of removed panels<ko>제거된 패널들의 배열</ko>
7710 */
7711 __proto.remove = function (index, deleteCount) {
7712 if (deleteCount === void 0) {
7713 deleteCount = 1;
7714 }
7715 if (this._renderExternal) {
7716 throw new FlickingError(MESSAGE.NOT_ALLOWED_IN_FRAMEWORK, CODE.NOT_ALLOWED_IN_FRAMEWORK);
7717 }
7718 return this._renderer.batchRemove({
7719 index: index,
7720 deleteCount: deleteCount,
7721 hasDOMInElements: true
7722 });
7723 };
7724 __proto._createControl = function () {
7725 var _a;
7726 var moveType = this._moveType;
7727 var moveTypes = Object.keys(MOVE_TYPE).map(function (key) {
7728 return MOVE_TYPE[key];
7729 });
7730 var moveTypeStr = Array.isArray(moveType) ? moveType[0] : moveType;
7731 var moveTypeOptions = Array.isArray(moveType) ? (_a = moveType[1]) !== null && _a !== void 0 ? _a : {} : {};
7732 if (!includes(moveTypes, moveTypeStr)) {
7733 throw new FlickingError(MESSAGE.WRONG_OPTION("moveType", JSON.stringify(moveType)), CODE.WRONG_OPTION);
7734 }
7735 switch (moveTypeStr) {
7736 case MOVE_TYPE.SNAP:
7737 return new SnapControl(moveTypeOptions);
7738 case MOVE_TYPE.FREE_SCROLL:
7739 return new FreeControl(moveTypeOptions);
7740 case MOVE_TYPE.STRICT:
7741 return new StrictControl(moveTypeOptions);
7742 }
7743 };
7744 __proto._createCamera = function () {
7745 if (this._circular && this._bound) {
7746 // eslint-disable-next-line no-console
7747 console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
7748 }
7749 return new Camera(this, {
7750 align: this._align
7751 });
7752 };
7753 __proto._createRenderer = function () {
7754 var externalRenderer = this._externalRenderer;
7755 if (this._virtual && this._panelsPerView <= 0) {
7756 // eslint-disable-next-line no-console
7757 console.warn("\"virtual\" and \"panelsPerView\" option should be used together, ignoring virtual.");
7758 }
7759 return externalRenderer ? externalRenderer : this._renderExternal ? this._createExternalRenderer() : this._createVanillaRenderer();
7760 };
7761 __proto._createExternalRenderer = function () {
7762 var _a = this._renderExternal,
7763 renderer = _a.renderer,
7764 rendererOptions = _a.rendererOptions;
7765 return new renderer(__assign({
7766 align: this._align
7767 }, rendererOptions));
7768 };
7769 __proto._createVanillaRenderer = function () {
7770 var virtual = this.virtualEnabled;
7771 return new VanillaRenderer({
7772 align: this._align,
7773 strategy: virtual ? new VirtualRenderingStrategy() : new NormalRenderingStrategy({
7774 providerCtor: VanillaElementProvider
7775 })
7776 });
7777 };
7778 __proto._moveToInitialPanel = function () {
7779 var renderer = this._renderer;
7780 var control = this._control;
7781 var camera = this._camera;
7782 var defaultPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
7783 if (!defaultPanel) return;
7784 var nearestAnchor = camera.findNearestAnchor(defaultPanel.position);
7785 var initialPanel = nearestAnchor && defaultPanel.index !== nearestAnchor.panel.index ? nearestAnchor.panel : defaultPanel;
7786 control.setActive(initialPanel, null, false);
7787 if (!nearestAnchor) {
7788 throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(initialPanel.position), CODE.POSITION_NOT_REACHABLE);
7789 }
7790 var position = initialPanel.position;
7791 if (!camera.canReach(initialPanel)) {
7792 position = nearestAnchor.position;
7793 }
7794 camera.lookAt(position);
7795 control.updateInput();
7796 camera.updateOffset();
7797 };
7798 __proto._initialResize = function () {
7799 var viewport = this._viewport;
7800 var renderer = this._renderer;
7801 var camera = this._camera;
7802 var control = this._control;
7803 this.trigger(new ComponentEvent(EVENTS.BEFORE_RESIZE, {
7804 width: 0,
7805 height: 0,
7806 element: viewport.element
7807 }));
7808 viewport.resize();
7809 renderer.updatePanelSize();
7810 camera.updateAlignPos();
7811 camera.updateRange();
7812 camera.updateAnchors();
7813 camera.updateOffset();
7814 control.updateInput();
7815 var newWidth = viewport.width;
7816 var newHeight = viewport.height;
7817 var sizeChanged = newWidth !== 0 || newHeight !== 0;
7818 this.trigger(new ComponentEvent(EVENTS.AFTER_RESIZE, {
7819 width: viewport.width,
7820 height: viewport.height,
7821 prev: {
7822 width: 0,
7823 height: 0
7824 },
7825 sizeChanged: sizeChanged,
7826 element: viewport.element
7827 }));
7828 };
7829 /**
7830 * Version info string
7831 * @ko 버전정보 문자열
7832 * @type {string}
7833 * @readonly
7834 * @example
7835 * ```ts
7836 * Flicking.VERSION; // ex) 4.0.0
7837 * ```
7838 */
7839 Flicking.VERSION = "4.11.3";
7840 return Flicking;
7841}(Component);
7842
7843/**
7844 * Decorator that makes the method of flicking available in the framework.
7845 * @ko 프레임워크에서 플리킹의 메소드를 사용할 수 있게 하는 데코레이터.
7846 * @memberof eg.Flicking
7847 * @private
7848 * @example
7849 * ```js
7850 * import Flicking, { withFlickingMethods } from "@egjs/flicking";
7851 *
7852 * class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>> {
7853 * &#64;withFlickingMethods
7854 * private flicking: Flicking;
7855 * }
7856 * ```
7857 */
7858var withFlickingMethods = function (prototype, flickingName) {
7859 [Component.prototype, Flicking.prototype].forEach(function (proto) {
7860 Object.getOwnPropertyNames(proto).filter(function (name) {
7861 return !prototype[name] && name.indexOf("_") !== 0 && name !== "constructor";
7862 }).forEach(function (name) {
7863 var descriptor = Object.getOwnPropertyDescriptor(proto, name);
7864 if (descriptor.value) {
7865 // Public Function
7866 Object.defineProperty(prototype, name, {
7867 value: function () {
7868 var _a;
7869 var args = [];
7870 for (var _i = 0; _i < arguments.length; _i++) {
7871 args[_i] = arguments[_i];
7872 }
7873 return (_a = descriptor.value).call.apply(_a, __spread([this[flickingName]], args));
7874 }
7875 });
7876 } else {
7877 var getterDescriptor = {};
7878 if (descriptor.get) {
7879 getterDescriptor.get = function () {
7880 var _a;
7881 var flicking = this[flickingName];
7882 return flicking && ((_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(flicking));
7883 };
7884 }
7885 if (descriptor.set) {
7886 getterDescriptor.set = function () {
7887 var _a;
7888 var args = [];
7889 for (var _i = 0; _i < arguments.length; _i++) {
7890 args[_i] = arguments[_i];
7891 }
7892 return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spread([this[flickingName]], args));
7893 };
7894 }
7895 Object.defineProperty(prototype, name, getterDescriptor);
7896 }
7897 });
7898 });
7899};
7900
7901var sync = (function (flicking, diffResult, rendered) {
7902 var renderer = flicking.renderer;
7903 var panels = renderer.panels;
7904 var prevList = __spread(diffResult.prevList);
7905 var added = [];
7906 var removed = [];
7907 if (diffResult.removed.length > 0) {
7908 var endIdx_1 = -1;
7909 var prevIdx_1 = -1;
7910 diffResult.removed.forEach(function (removedIdx) {
7911 if (endIdx_1 < 0) {
7912 endIdx_1 = removedIdx;
7913 }
7914 if (prevIdx_1 >= 0 && removedIdx !== prevIdx_1 - 1) {
7915 removed.push.apply(removed, __spread(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
7916 endIdx_1 = removedIdx;
7917 prevIdx_1 = removedIdx;
7918 } else {
7919 prevIdx_1 = removedIdx;
7920 }
7921 prevList.splice(removedIdx, 1);
7922 });
7923 removed.push.apply(removed, __spread(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
7924 }
7925 diffResult.ordered.forEach(function (_a) {
7926 var _b = __read(_a, 2),
7927 from = _b[0],
7928 to = _b[1];
7929 var prevPanel = panels.splice(from, 1)[0];
7930 panels.splice(to, 0, prevPanel);
7931 });
7932 if (diffResult.ordered.length > 0) {
7933 panels.forEach(function (panel, idx) {
7934 var indexDiff = idx - panel.index;
7935 if (indexDiff > 0) {
7936 panel.increaseIndex(indexDiff);
7937 } else {
7938 panel.decreaseIndex(-indexDiff);
7939 }
7940 });
7941 panels.sort(function (panel1, panel2) {
7942 return panel1.index - panel2.index;
7943 });
7944 panels.forEach(function (panel) {
7945 panel.updatePosition();
7946 });
7947 }
7948 if (diffResult.added.length > 0) {
7949 var startIdx_1 = -1;
7950 var prevIdx_2 = -1;
7951 var addedElements_1 = rendered.slice(prevList.length);
7952 diffResult.added.forEach(function (addedIdx, idx) {
7953 if (startIdx_1 < 0) {
7954 startIdx_1 = idx;
7955 }
7956 if (prevIdx_2 >= 0 && addedIdx !== prevIdx_2 + 1) {
7957 added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1)));
7958 startIdx_1 = -1;
7959 prevIdx_2 = -1;
7960 } else {
7961 prevIdx_2 = addedIdx;
7962 }
7963 });
7964 if (startIdx_1 >= 0) {
7965 added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1, startIdx_1)));
7966 }
7967 }
7968 if (diffResult.added.length > 0 || diffResult.removed.length > 0) {
7969 renderer.updateAfterPanelChange(added, removed);
7970 }
7971});
7972var batchInsert = function (renderer, diffResult, addedElements, startIdx, endIdx) {
7973 return renderer.batchInsertDefer.apply(renderer, __spread(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
7974 return {
7975 index: index,
7976 elements: [addedElements[elIdx]],
7977 hasDOMInElements: false
7978 };
7979 })));
7980};
7981var batchRemove = function (renderer, startIdx, endIdx) {
7982 var removed = renderer.panels.slice(startIdx, endIdx);
7983 return renderer.batchRemoveDefer({
7984 index: startIdx,
7985 deleteCount: removed.length,
7986 hasDOMInElements: false
7987 });
7988};
7989
7990var getRenderingPanels = (function (flicking, diffResult) {
7991 var removedPanels = diffResult.removed.reduce(function (map, idx) {
7992 map[idx] = true;
7993 return map;
7994 }, {});
7995 var maintainedMap = diffResult.maintained.reduce(function (map, _a) {
7996 var _b = __read(_a, 2),
7997 prev = _b[0],
7998 current = _b[1];
7999 map[prev] = current;
8000 return map;
8001 }, {});
8002 return __spread(flicking.panels.filter(function (panel) {
8003 return !removedPanels[panel.index];
8004 })
8005 // Sort panels by position
8006 .sort(function (panel1, panel2) {
8007 return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8008 }).map(function (panel) {
8009 return diffResult.list[maintainedMap[panel.index]];
8010 }), diffResult.added.map(function (idx) {
8011 return diffResult.list[idx];
8012 }));
8013});
8014
8015var getDefaultCameraTransform = (function (align, horizontal, firstPanelSize) {
8016 if (align === void 0) {
8017 align = ALIGN.CENTER;
8018 }
8019 if (horizontal === void 0) {
8020 horizontal = true;
8021 }
8022 var cameraAlign = getCameraAlign(align);
8023 var panelAlign = getPanelAlign(align);
8024 if (panelAlign == null) return "";
8025 var camPosition = "calc(" + cameraAlign + " - (" + (firstPanelSize || "0px") + " * " + panelAlign.percentage + ") - " + panelAlign.absolute + "px)";
8026 return horizontal ? "translate(" + camPosition + ")" : "translate(0, " + camPosition + ")";
8027});
8028var getCameraAlign = function (align) {
8029 var alignVal = typeof align === "object" ? align.camera : align;
8030 return parseAlign(alignVal);
8031};
8032var getPanelAlign = function (align) {
8033 var alignVal = typeof align === "object" ? align.panel : align;
8034 return parseArithmeticExpression(parseAlign(alignVal));
8035};
8036var parseAlign = function (alignVal) {
8037 if (typeof alignVal === "number") {
8038 return alignVal + "px";
8039 }
8040 switch (alignVal) {
8041 case ALIGN.CENTER:
8042 return "50%";
8043 case ALIGN.NEXT:
8044 return "100%";
8045 case ALIGN.PREV:
8046 return "0%";
8047 default:
8048 return alignVal;
8049 }
8050};
8051
8052/*
8053 * Copyright (c) 2015 NAVER Corp.
8054 * egjs projects are licensed under the MIT license
8055 */
8056
8057export { ALIGN, AnchorPoint, AnimatingState, AxesController, BoundCameraMode, CIRCULAR_FALLBACK, CLASS, Camera, CircularCameraMode, Control, DIRECTION, DisabledState, DraggingState, CODE as ERROR_CODE, EVENTS, ExternalRenderer, FlickingError, FreeControl, HoldingState, IdleState, LinearCameraMode, MOVE_TYPE, NormalRenderingStrategy, ORDER, Panel, Renderer, SnapControl, State, StateMachine, StrictControl, VanillaElementProvider, VanillaRenderer, Viewport, VirtualElementProvider, VirtualManager, VirtualPanel, VirtualRenderingStrategy, checkExistence, circulateIndex, circulatePosition, clamp, Flicking as default, find, findIndex, findRight, getDefaultCameraTransform, getDirection, getElement, getElementSize, getFlickingAttached, getMinusCompensatedIndex, getProgress, getRenderingPanels, getStyle, includes, isBetween, isString, merge, parseAlign$1 as parseAlign, parseArithmeticExpression, parseArithmeticSize, parseBounce, parseCSSSizeValue, parseElement, parsePanelAlign, range, setPrototypeOf, setSize, sync, toArray, withFlickingMethods };
8058//# sourceMappingURL=flicking.esm.js.map