UNPKG

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