UNPKG

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