UNPKG

500 kBJavaScriptView Raw
1/*
2Copyright (c) 2015-present NAVER Corp.
3name: @egjs/flicking
4license: MIT
5author: NAVER Corp.
6repository: https://github.com/naver/egjs-flicking
7version: 4.10.0
8*/
9(function (global, factory) {
10 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
11 typeof define === 'function' && define.amd ? define(factory) :
12 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Flicking = factory());
13})(this, (function () { '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$2 = function (d, b) {
32 extendStatics$2 = 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$2(d, b);
41 };
42
43 function __extends$2(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$2(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$2 = function () {
54 __assign$2 = 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$2.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$1(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$1(o, n) {
222 var m = typeof Symbol === "function" && o[Symbol.iterator];
223 if (!m) return o;
224 var i = m.call(o),
225 r,
226 ar = [],
227 e;
228
229 try {
230 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
231 } catch (error) {
232 e = {
233 error: error
234 };
235 } finally {
236 try {
237 if (r && !r.done && (m = i["return"])) m.call(i);
238 } finally {
239 if (e) throw e.error;
240 }
241 }
242
243 return ar;
244 }
245 /** @deprecated */
246
247 function __spread$1() {
248 for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read$1(arguments[i]));
249
250 return ar;
251 }
252
253 /*
254 Copyright (c) NAVER Corp.
255 name: @egjs/component
256 license: MIT
257 author: NAVER Corp.
258 repository: https://github.com/naver/egjs-component
259 version: 3.0.2
260 */
261 /*! *****************************************************************************
262 Copyright (c) Microsoft Corporation.
263
264 Permission to use, copy, modify, and/or distribute this software for any
265 purpose with or without fee is hereby granted.
266
267 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
268 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
269 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
270 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
271 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
272 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
273 PERFORMANCE OF THIS SOFTWARE.
274 ***************************************************************************** */
275 function __values(o) {
276 var s = typeof Symbol === "function" && Symbol.iterator,
277 m = s && o[s],
278 i = 0;
279 if (m) return m.call(o);
280 if (o && typeof o.length === "number") return {
281 next: function () {
282 if (o && i >= o.length) o = void 0;
283 return {
284 value: o && o[i++],
285 done: !o
286 };
287 }
288 };
289 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
290 }
291 function __read(o, n) {
292 var m = typeof Symbol === "function" && o[Symbol.iterator];
293 if (!m) return o;
294 var i = m.call(o),
295 r,
296 ar = [],
297 e;
298
299 try {
300 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
301 } catch (error) {
302 e = {
303 error: error
304 };
305 } finally {
306 try {
307 if (r && !r.done && (m = i["return"])) m.call(i);
308 } finally {
309 if (e) throw e.error;
310 }
311 }
312
313 return ar;
314 }
315 function __spread() {
316 for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
317
318 return ar;
319 }
320
321 /*
322 * Copyright (c) 2015 NAVER Corp.
323 * egjs projects are licensed under the MIT license
324 */
325 var isUndefined = function (value) {
326 return typeof value === "undefined";
327 };
328
329 /**
330 * Event class to provide additional properties
331 * @ko Component에서 추가적인 프로퍼티를 제공하는 이벤트 클래스
332 */
333
334 var ComponentEvent =
335 /*#__PURE__*/
336 function () {
337 /**
338 * Create a new instance of ComponentEvent.
339 * @ko ComponentEvent의 새로운 인스턴스를 생성한다.
340 * @param eventType The name of the event.<ko>이벤트 이름.</ko>
341 * @param props An object that contains additional event properties.<ko>추가적인 이벤트 프로퍼티 오브젝트.</ko>
342 */
343 function ComponentEvent(eventType, props) {
344 var e_1, _a;
345
346 this._canceled = false;
347
348 if (props) {
349 try {
350 for (var _b = __values(Object.keys(props)), _c = _b.next(); !_c.done; _c = _b.next()) {
351 var key = _c.value; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
352
353 this[key] = props[key];
354 }
355 } catch (e_1_1) {
356 e_1 = {
357 error: e_1_1
358 };
359 } finally {
360 try {
361 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
362 } finally {
363 if (e_1) throw e_1.error;
364 }
365 }
366 }
367
368 this.eventType = eventType;
369 }
370 /**
371 * Stop the event. {@link ComponentEvent#isCanceled} will return `true` after.
372 * @ko 이벤트를 중단한다. 이후 {@link ComponentEvent#isCanceled}가 `true`를 반환한다.
373 */
374
375
376 var __proto = ComponentEvent.prototype;
377
378 __proto.stop = function () {
379 this._canceled = true;
380 };
381 /**
382 * Returns a boolean value that indicates whether {@link ComponentEvent#stop} is called before.
383 * @ko {@link ComponentEvent#stop}이 호출되었는지 여부를 반환한다.
384 * @return {boolean} A boolean value that indicates whether {@link ComponentEvent#stop} is called before.<ko>이전에 {@link ComponentEvent#stop}이 불려졌는지 여부를 반환한다.</ko>
385 */
386
387
388 __proto.isCanceled = function () {
389 return this._canceled;
390 };
391
392 return ComponentEvent;
393 }();
394
395 /**
396 * A class used to manage events in a component
397 * @ko 컴포넌트의 이벤트을 관리할 수 있게 하는 클래스
398 */
399
400 var Component =
401 /*#__PURE__*/
402 function () {
403 /**
404 * @support {"ie": "7+", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "2.1+ (except 3.x)"}
405 */
406 function Component() {
407 this._eventHandler = {};
408 }
409 /**
410 * Trigger a custom event.
411 * @ko 커스텀 이벤트를 발생시킨다
412 * @param {string | ComponentEvent} event The name of the custom event to be triggered or an instance of the ComponentEvent<ko>발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스</ko>
413 * @param {any[]} params Event data to be sent when triggering a custom event <ko>커스텀 이벤트가 발생할 때 전달할 데이터</ko>
414 * @return An instance of the component itself<ko>컴포넌트 자신의 인스턴스</ko>
415 * @example
416 * ```ts
417 * import Component, { ComponentEvent } from "@egjs/component";
418 *
419 * class Some extends Component<{
420 * beforeHi: ComponentEvent<{ foo: number; bar: string }>;
421 * hi: { foo: { a: number; b: boolean } };
422 * someEvent: (foo: number, bar: string) => void;
423 * someOtherEvent: void; // When there's no event argument
424 * }> {
425 * some(){
426 * if(this.trigger("beforeHi")){ // When event call to stop return false.
427 * this.trigger("hi");// fire hi event.
428 * }
429 * }
430 * }
431 *
432 * const some = new Some();
433 * some.on("beforeHi", e => {
434 * if(condition){
435 * e.stop(); // When event call to stop, `hi` event not call.
436 * }
437 * // `currentTarget` is component instance.
438 * console.log(some === e.currentTarget); // true
439 *
440 * typeof e.foo; // number
441 * typeof e.bar; // string
442 * });
443 * some.on("hi", e => {
444 * typeof e.foo.b; // boolean
445 * });
446 * // If you want to more know event design. You can see article.
447 * // https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F
448 * ```
449 */
450
451
452 var __proto = Component.prototype;
453
454 __proto.trigger = function (event) {
455 var params = [];
456
457 for (var _i = 1; _i < arguments.length; _i++) {
458 params[_i - 1] = arguments[_i];
459 }
460
461 var eventName = event instanceof ComponentEvent ? event.eventType : event;
462
463 var handlers = __spread(this._eventHandler[eventName] || []);
464
465 if (handlers.length <= 0) {
466 return this;
467 }
468
469 if (event instanceof ComponentEvent) {
470 event.currentTarget = this;
471 handlers.forEach(function (handler) {
472 handler(event);
473 });
474 } else {
475 handlers.forEach(function (handler) {
476 // eslint-disable-next-line @typescript-eslint/no-unsafe-call
477 handler.apply(void 0, __spread(params));
478 });
479 }
480
481 return this;
482 };
483 /**
484 * Executed event just one time.
485 * @ko 이벤트가 한번만 실행된다.
486 * @param {string} eventName The name of the event to be attached or an event name - event handler mapped object.<ko>등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트</ko>
487 * @param {function} handlerToAttach The handler function of the event to be attached <ko>등록할 이벤트의 핸들러 함수</ko>
488 * @return An instance of the component itself<ko>컴포넌트 자신의 인스턴스</ko>
489 * @example
490 * ```ts
491 * import Component, { ComponentEvent } from "@egjs/component";
492 *
493 * class Some extends Component<{
494 * hi: ComponentEvent;
495 * }> {
496 * hi() {
497 * alert("hi");
498 * }
499 * thing() {
500 * this.once("hi", this.hi);
501 * }
502 * }
503 *
504 * var some = new Some();
505 * some.thing();
506 * some.trigger(new ComponentEvent("hi"));
507 * // fire alert("hi");
508 * some.trigger(new ComponentEvent("hi"));
509 * // Nothing happens
510 * ```
511 */
512
513
514 __proto.once = function (eventName, handlerToAttach) {
515 var _this = this;
516
517 if (typeof eventName === "object" && isUndefined(handlerToAttach)) {
518 var eventHash = eventName;
519
520 for (var key in eventHash) {
521 this.once(key, eventHash[key]);
522 }
523
524 return this;
525 } else if (typeof eventName === "string" && typeof handlerToAttach === "function") {
526 var listener_1 = function () {
527 var args = [];
528
529 for (var _i = 0; _i < arguments.length; _i++) {
530 args[_i] = arguments[_i];
531 } // eslint-disable-next-line @typescript-eslint/no-unsafe-call
532
533
534 handlerToAttach.apply(void 0, __spread(args));
535
536 _this.off(eventName, listener_1);
537 };
538
539 this.on(eventName, listener_1);
540 }
541
542 return this;
543 };
544 /**
545 * Checks whether an event has been attached to a component.
546 * @ko 컴포넌트에 이벤트가 등록됐는지 확인한다.
547 * @param {string} eventName The name of the event to be attached <ko>등록 여부를 확인할 이벤트의 이름</ko>
548 * @return {boolean} Indicates whether the event is attached. <ko>이벤트 등록 여부</ko>
549 * @example
550 * ```ts
551 * import Component from "@egjs/component";
552 *
553 * class Some extends Component<{
554 * hi: void;
555 * }> {
556 * some() {
557 * this.hasOn("hi");// check hi event.
558 * }
559 * }
560 * ```
561 */
562
563
564 __proto.hasOn = function (eventName) {
565 return !!this._eventHandler[eventName];
566 };
567 /**
568 * Attaches an event to a component.
569 * @ko 컴포넌트에 이벤트를 등록한다.
570 * @param {string} eventName The name of the event to be attached or an event name - event handler mapped object.<ko>등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트</ko>
571 * @param {function} handlerToAttach The handler function of the event to be attached <ko>등록할 이벤트의 핸들러 함수</ko>
572 * @return An instance of a component itself<ko>컴포넌트 자신의 인스턴스</ko>
573 * @example
574 * ```ts
575 * import Component, { ComponentEvent } from "@egjs/component";
576 *
577 * class Some extends Component<{
578 * hi: void;
579 * }> {
580 * hi() {
581 * console.log("hi");
582 * }
583 * some() {
584 * this.on("hi",this.hi); //attach event
585 * }
586 * }
587 * ```
588 */
589
590
591 __proto.on = function (eventName, handlerToAttach) {
592 if (typeof eventName === "object" && isUndefined(handlerToAttach)) {
593 var eventHash = eventName;
594
595 for (var name in eventHash) {
596 this.on(name, eventHash[name]);
597 }
598
599 return this;
600 } else if (typeof eventName === "string" && typeof handlerToAttach === "function") {
601 var handlerList = this._eventHandler[eventName];
602
603 if (isUndefined(handlerList)) {
604 this._eventHandler[eventName] = [];
605 handlerList = this._eventHandler[eventName];
606 }
607
608 handlerList.push(handlerToAttach);
609 }
610
611 return this;
612 };
613 /**
614 * Detaches an event from the component.<br/>If the `eventName` is not given this will detach all event handlers attached.<br/>If the `handlerToDetach` is not given, this will detach all event handlers for `eventName`.
615 * @ko 컴포넌트에 등록된 이벤트를 해제한다.<br/>`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.<br/>`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다.
616 * @param {string?} eventName The name of the event to be detached <ko>해제할 이벤트의 이름</ko>
617 * @param {function?} handlerToDetach The handler function of the event to be detached <ko>해제할 이벤트의 핸들러 함수</ko>
618 * @return An instance of a component itself <ko>컴포넌트 자신의 인스턴스</ko>
619 * @example
620 * ```ts
621 * import Component, { ComponentEvent } from "@egjs/component";
622 *
623 * class Some extends Component<{
624 * hi: void;
625 * }> {
626 * hi() {
627 * console.log("hi");
628 * }
629 * some() {
630 * this.off("hi",this.hi); //detach event
631 * }
632 * }
633 * ```
634 */
635
636
637 __proto.off = function (eventName, handlerToDetach) {
638 var e_1, _a; // Detach all event handlers.
639
640
641 if (isUndefined(eventName)) {
642 this._eventHandler = {};
643 return this;
644 } // Detach all handlers for eventname or detach event handlers by object.
645
646
647 if (isUndefined(handlerToDetach)) {
648 if (typeof eventName === "string") {
649 delete this._eventHandler[eventName];
650 return this;
651 } else {
652 var eventHash = eventName;
653
654 for (var name in eventHash) {
655 this.off(name, eventHash[name]);
656 }
657
658 return this;
659 }
660 } // Detach single event handler
661
662
663 var handlerList = this._eventHandler[eventName];
664
665 if (handlerList) {
666 var idx = 0;
667
668 try {
669 for (var handlerList_1 = __values(handlerList), handlerList_1_1 = handlerList_1.next(); !handlerList_1_1.done; handlerList_1_1 = handlerList_1.next()) {
670 var handlerFunction = handlerList_1_1.value;
671
672 if (handlerFunction === handlerToDetach) {
673 handlerList.splice(idx, 1);
674
675 if (handlerList.length <= 0) {
676 delete this._eventHandler[eventName];
677 }
678
679 break;
680 }
681
682 idx++;
683 }
684 } catch (e_1_1) {
685 e_1 = {
686 error: e_1_1
687 };
688 } finally {
689 try {
690 if (handlerList_1_1 && !handlerList_1_1.done && (_a = handlerList_1.return)) _a.call(handlerList_1);
691 } finally {
692 if (e_1) throw e_1.error;
693 }
694 }
695 }
696
697 return this;
698 };
699 /**
700 * Version info string
701 * @ko 버전정보 문자열
702 * @name VERSION
703 * @static
704 * @example
705 * Component.VERSION; // ex) 3.0.0
706 * @memberof Component
707 */
708
709
710 Component.VERSION = "3.0.2";
711 return Component;
712 }();
713
714 /*
715 * Copyright (c) 2015 NAVER Corp.
716 * egjs projects are licensed under the MIT license
717 */
718
719 var ComponentEvent$1 = ComponentEvent;
720
721 /*
722 * Copyright (c) 2015 NAVER Corp.
723 * egjs projects are licensed under the MIT license
724 */
725
726 /* eslint-disable @typescript-eslint/restrict-template-expressions */
727
728 /**
729 * Error codes of {@link FlickingError}. Below are the conditions where each error code occurs.
730 * @ko {@link FlickingError}의 에러 코드. 아래는 각각의 에러 코드가 발생하는 조건입니다.
731 * @name ERROR_CODE
732 * @constant
733 * @type object
734 * @property {number} WRONG_TYPE Parameter type is wrong<ko>패러미터의 타입이 잘못되었을 경우</ko>
735 * @property {number} ELEMENT_NOT_FOUND Element is not found inside page with the given CSS selector<ko>주어진 CSS selector로 페이지 내에서 해당 엘리먼트를 찾지 못했을 경우</ko>
736 * @property {number} VAL_MUST_NOT_NULL Expected non-null value, but given `null` or `undefined`<ko>값을 기대했으나, `null`이나 `undefined`를 받은 경우</ko>
737 * @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>
738 * @property {number} WRONG_OPTION One of the options is wrong<ko>옵션들 중 잘못된 값이 있을 때</ko>
739 * @property {number} INDEX_OUT_OF_RANGE When the given index is out of possible range<ko>인덱스가 주어진 범위를 벗어난 경우</ko>
740 * @property {number} POSITION_NOT_REACHABLE When {@link Control#moveToPosition}'s position parameter is out of possible range.<ko>{@link Control#moveToPosition}의 `position` 패러미터가 도달 가능한 범위를 벗어난 경우</ko>
741 * @property {number} TRANSFORM_NOT_SUPPORTED CSS `transform` property is not available(<=IE8) <ko>CSS `transform` 속성을 사용할 수 없는 경우(<=IE8)</ko>
742 * @property {number} STOP_CALLED_BY_USER When the event's `stop()` is called by user.<ko>사용자에 의해 이벤트의 `stop()`이 호출된 경우</ko>
743 * @property {number} ANIMATION_INTERRUPTED When the animation is interrupted by user.<ko>사용자에 의해 애니메이션이 중단된 경우</ko>
744 * @property {number} ANIMATION_ALREADY_PLAYING When the animation is already playing.<ko>현재 애니메이션이 이미 진행중인 경우</ko>
745 * @property {number} NOT_ALLOWED_IN_FRAMEWORK When the non-allowed method is called from frameworks (React, Angular, Vue...)
746 * <ko>프레임워크(React, Angular, Vue ...)에서 사용 불가능한 메소드를 호출했을 경우</ko>
747 * @property {number} NOT_INITIALIZED When the {@link Flicking#init} is not called before but is needed<ko>{@link Flicking#init}의 호출이 필요하나, 아직 호출되지 않았을 경우</ko>
748 * @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>
749 * @property {number} NOT_ALLOWED_IN_VIRTUAL When the non-allowed method is called while the virtual option is enabled<ko>virtual 옵션이 활성화된 상태에서 사용 불가능한 메소드가 호출되었을 경우</ko>
750 */
751 var CODE = {
752 WRONG_TYPE: 0,
753 ELEMENT_NOT_FOUND: 1,
754 VAL_MUST_NOT_NULL: 2,
755 NOT_ATTACHED_TO_FLICKING: 3,
756 WRONG_OPTION: 4,
757 INDEX_OUT_OF_RANGE: 5,
758 POSITION_NOT_REACHABLE: 6,
759 TRANSFORM_NOT_SUPPORTED: 7,
760 STOP_CALLED_BY_USER: 8,
761 ANIMATION_INTERRUPTED: 9,
762 ANIMATION_ALREADY_PLAYING: 10,
763 NOT_ALLOWED_IN_FRAMEWORK: 11,
764 NOT_INITIALIZED: 12,
765 NO_ACTIVE: 13,
766 NOT_ALLOWED_IN_VIRTUAL: 14
767 };
768 var MESSAGE = {
769 WRONG_TYPE: function (wrongVal, correctTypes) {
770 return wrongVal + "(" + typeof wrongVal + ") is not a " + correctTypes.map(function (type) {
771 return "\"" + type + "\"";
772 }).join(" or ") + ".";
773 },
774 ELEMENT_NOT_FOUND: function (selector) {
775 return "Element with selector \"" + selector + "\" not found.";
776 },
777 VAL_MUST_NOT_NULL: function (val, name) {
778 return name + " should be provided. Given: " + val;
779 },
780 NOT_ATTACHED_TO_FLICKING: "This module is not attached to the Flicking instance. \"init()\" should be called first.",
781 WRONG_OPTION: function (optionName, val) {
782 return "Option \"" + optionName + "\" is not in correct format, given: " + val;
783 },
784 INDEX_OUT_OF_RANGE: function (val, min, max) {
785 return "Index \"" + val + "\" is out of range: should be between " + min + " and " + max + ".";
786 },
787 POSITION_NOT_REACHABLE: function (position) {
788 return "Position \"" + position + "\" is not reachable.";
789 },
790 TRANSFORM_NOT_SUPPORTED: "Browser does not support CSS transform.",
791 STOP_CALLED_BY_USER: "Event stop() is called by user.",
792 ANIMATION_INTERRUPTED: "Animation is interrupted by user input.",
793 ANIMATION_ALREADY_PLAYING: "Animation is already playing.",
794 NOT_ALLOWED_IN_FRAMEWORK: "This behavior is not allowed in the frameworks like React, Vue, or Angular.",
795 NOT_INITIALIZED: "Flicking is not initialized yet, call init() first.",
796 NO_ACTIVE: "There's no active panel that Flicking has selected. This may be due to the absence of any panels.",
797 NOT_ALLOWED_IN_VIRTUAL: "This behavior is not allowed when the virtual option is enabled"
798 };
799
800 /*
801 * Copyright (c) 2015 NAVER Corp.
802 * egjs projects are licensed under the MIT license
803 */
804 /**
805 * Event type object with event name strings of {@link Flicking}
806 * @ko {@link Flicking}의 이벤트 이름 문자열들을 담은 객체
807 * @type {object}
808 * @property {"holdStart"} HOLD_START holdStart event<ko>holdStart 이벤트</ko>
809 * @property {"holdEnd"} HOLD_END holdEnd event<ko>holdEnd 이벤트</ko>
810 * @property {"moveStart"} MOVE_START moveStart event<ko>moveStart 이벤트</ko>
811 * @property {"move"} MOVE move event<ko>move 이벤트</ko>
812 * @property {"moveEnd"} MOVE_END moveEnd event<ko>moveEnd 이벤트</ko>
813 * @property {"willChange"} WILL_CHANGE willChange event<ko>willChange 이벤트</ko>
814 * @property {"changed"} CHANGED changed event<ko>changed 이벤트</ko>
815 * @property {"willRestore"} WILL_RESTORE willRestore event<ko>willRestore 이벤트</ko>
816 * @property {"restored"} RESTORED restored event<ko>restored 이벤트</ko>
817 * @property {"select"} SELECT select event<ko>select 이벤트</ko>
818 * @property {"needPanel"} NEED_PANEL needPanel event<ko>needPanel 이벤트</ko>
819 * @property {"panelChange"} PANEL_CHANGE panelChange event<ko>panelChange 이벤트</ko>
820 * @example
821 * ```ts
822 * import { EVENTS } from "@egjs/flicking";
823 * EVENTS.MOVE_START; // "moveStart"
824 * ```
825 */
826
827 var EVENTS = {
828 READY: "ready",
829 BEFORE_RESIZE: "beforeResize",
830 AFTER_RESIZE: "afterResize",
831 HOLD_START: "holdStart",
832 HOLD_END: "holdEnd",
833 MOVE_START: "moveStart",
834 MOVE: "move",
835 MOVE_END: "moveEnd",
836 WILL_CHANGE: "willChange",
837 CHANGED: "changed",
838 WILL_RESTORE: "willRestore",
839 RESTORED: "restored",
840 SELECT: "select",
841 NEED_PANEL: "needPanel",
842 VISIBLE_CHANGE: "visibleChange",
843 REACH_EDGE: "reachEdge",
844 PANEL_CHANGE: "panelChange"
845 };
846 /**
847 * An object with all possible predefined literal string for the {@link Flicking#align align} option
848 * @ko {@link Flicking#align align} 옵션에 사용되는 미리 정의된 리터럴 상수들을 담고 있는 객체
849 * @type {object}
850 * @property {"prev"} PREV left/top align<ko>좌/상 정렬</ko>
851 * @property {"center"} CENTER center align<ko>중앙 정렬</ko>
852 * @property {"next"} NEXT right/bottom align<ko>우/하 정렬</ko>
853 */
854
855 var ALIGN = {
856 PREV: "prev",
857 CENTER: "center",
858 NEXT: "next"
859 };
860 /**
861 * An object of directions
862 * @ko 방향을 나타내는 값들을 담고 있는 객체
863 * @type {object}
864 * @property {"PREV"} PREV "left" when {@link Flicking#horizontal horizontal} is true, and "top" when {@link Flicking#horizontal horizontal} is false
865 * <ko>{@link Flicking#horizontal horizontal}가 `true`일 경우 왼쪽, {@link Flicking#horizontal horizontal}가 `false`일 경우 위쪽을 의미합니다</ko>
866 * @property {"NEXT"} NEXT "right" when {@link Flicking#horizontal horizontal} is true, and "bottom" when {@link Flicking#horizontal horizontal} is false
867 * <ko>{@link Flicking#horizontal horizontal}가 `true`일 경우 오른쪽, {@link Flicking#horizontal horizontal}가 `false`일 경우 아래쪽을 의미합니다</ko>
868 * @property {null} NONE This value usually means it's the same position<ko>주로 제자리인 경우를 의미합니다</ko>
869 */
870
871 var DIRECTION = {
872 PREV: "PREV",
873 NEXT: "NEXT",
874 NONE: null
875 };
876 /**
877 * An object with all possible {@link Flicking#moveType moveType}s
878 * @ko Flicking이 제공하는 {@link Flicking#moveType moveType}들을 담고 있는 객체
879 * @type {object}
880 * @property {"snap"} SNAP Flicking's {@link Flicking#moveType moveType} that enables {@link SnapControl} as a Flicking's {@link Flicking#control control}
881 * <ko>Flicking의 {@link Flicking#control control}을 {@link SnapControl}로 설정하게 하는 {@link Flicking#moveType moveType}</ko>
882 * @property {"freeScroll"} FREE_SCROLL Flicking's {@link Flicking#moveType moveType} that enables {@link FreeControl} as a Flicking's {@link Flicking#control control}
883 * <ko>Flicking의 {@link Flicking#control control}을 {@link FreeControl}로 설정하게 하는 {@link Flicking#moveType moveType}</ko>
884 * @property {"strict"} STRICT Flicking's {@link Flicking#moveType moveType} that enables {@link StrictControl} as a Flicking's {@link Flicking#control control}
885 * <ko>Flicking의 {@link Flicking#control control}을 {@link StrictControl}로 설정하게 하는 {@link Flicking#moveType moveType}</ko>
886 */
887
888 var MOVE_TYPE = {
889 SNAP: "snap",
890 FREE_SCROLL: "freeScroll",
891 STRICT: "strict"
892 };
893 var CLASS = {
894 VERTICAL: "vertical",
895 HIDDEN: "flicking-hidden",
896 DEFAULT_VIRTUAL: "flicking-panel"
897 };
898 /**
899 * An object with all possible {@link Flicking#circularFallback circularFallback}s
900 * @ko Flicking의 {@link Flicking#circularFallback circularFallback}에 설정 가능한 값들을 담고 있는 객체
901 * @type {object}
902 * @property {string} LINEAR "linear"
903 * @property {string} BOUND "bound"
904 */
905
906 var CIRCULAR_FALLBACK = {
907 LINEAR: "linear",
908 BOUND: "bound"
909 };
910
911 var Constants = {
912 __proto__: null,
913 EVENTS: EVENTS,
914 ALIGN: ALIGN,
915 DIRECTION: DIRECTION,
916 MOVE_TYPE: MOVE_TYPE,
917 CLASS: CLASS,
918 CIRCULAR_FALLBACK: CIRCULAR_FALLBACK,
919 ERROR_CODE: CODE
920 };
921
922 var merge = function (target) {
923 var sources = [];
924
925 for (var _i = 1; _i < arguments.length; _i++) {
926 sources[_i - 1] = arguments[_i];
927 }
928
929 sources.forEach(function (source) {
930 Object.keys(source).forEach(function (key) {
931 target[key] = source[key];
932 });
933 });
934 return target;
935 };
936 var getElement = function (el, parent) {
937 var targetEl = null;
938
939 if (isString(el)) {
940 var parentEl = parent ? parent : document;
941 var queryResult = parentEl.querySelector(el);
942
943 if (!queryResult) {
944 throw new FlickingError(MESSAGE.ELEMENT_NOT_FOUND(el), CODE.ELEMENT_NOT_FOUND);
945 }
946
947 targetEl = queryResult;
948 } else if (el && el.nodeType === Node.ELEMENT_NODE) {
949 targetEl = el;
950 }
951
952 if (!targetEl) {
953 throw new FlickingError(MESSAGE.WRONG_TYPE(el, ["HTMLElement", "string"]), CODE.WRONG_TYPE);
954 }
955
956 return targetEl;
957 };
958 var checkExistence = function (value, nameOnErrMsg) {
959 if (value == null) {
960 throw new FlickingError(MESSAGE.VAL_MUST_NOT_NULL(value, nameOnErrMsg), CODE.VAL_MUST_NOT_NULL);
961 }
962 };
963 var clamp$1 = function (x, min, max) {
964 return Math.max(Math.min(x, max), min);
965 };
966 var getFlickingAttached = function (val) {
967 if (!val) {
968 throw new FlickingError(MESSAGE.NOT_ATTACHED_TO_FLICKING, CODE.NOT_ATTACHED_TO_FLICKING);
969 }
970
971 return val;
972 };
973 var toArray$2 = function (iterable) {
974 return [].slice.call(iterable);
975 };
976 var parseAlign$1 = function (align, size) {
977 var alignPoint;
978
979 if (isString(align)) {
980 switch (align) {
981 case ALIGN.PREV:
982 alignPoint = 0;
983 break;
984
985 case ALIGN.CENTER:
986 alignPoint = 0.5 * size;
987 break;
988
989 case ALIGN.NEXT:
990 alignPoint = size;
991 break;
992
993 default:
994 alignPoint = parseArithmeticSize(align, size);
995
996 if (alignPoint == null) {
997 throw new FlickingError(MESSAGE.WRONG_OPTION("align", align), CODE.WRONG_OPTION);
998 }
999
1000 }
1001 } else {
1002 alignPoint = align;
1003 }
1004
1005 return alignPoint;
1006 };
1007 var parseBounce = function (bounce, size) {
1008 var parsedBounce;
1009
1010 if (Array.isArray(bounce)) {
1011 parsedBounce = bounce.map(function (val) {
1012 return parseArithmeticSize(val, size);
1013 });
1014 } else {
1015 var parsedVal = parseArithmeticSize(bounce, size);
1016 parsedBounce = [parsedVal, parsedVal];
1017 }
1018
1019 return parsedBounce.map(function (val) {
1020 if (val == null) {
1021 throw new FlickingError(MESSAGE.WRONG_OPTION("bounce", bounce), CODE.WRONG_OPTION);
1022 }
1023
1024 return val;
1025 });
1026 };
1027 var parseArithmeticSize = function (cssValue, base) {
1028 var parsed = parseArithmeticExpression(cssValue);
1029 if (parsed == null) return null;
1030 return parsed.percentage * base + parsed.absolute;
1031 };
1032 var parseArithmeticExpression = function (cssValue) {
1033 var cssRegex = /(?:(\+|\-)\s*)?(\d+(?:\.\d+)?(%|px)?)/g;
1034
1035 if (typeof cssValue === "number") {
1036 return {
1037 percentage: 0,
1038 absolute: cssValue
1039 };
1040 }
1041
1042 var parsed = {
1043 percentage: 0,
1044 absolute: 0
1045 };
1046 var idx = 0;
1047 var matchResult = cssRegex.exec(cssValue);
1048
1049 while (matchResult != null) {
1050 var sign = matchResult[1];
1051 var value = matchResult[2];
1052 var unit = matchResult[3];
1053 var parsedValue = parseFloat(value);
1054
1055 if (idx <= 0) {
1056 sign = sign || "+";
1057 } // Return default value for values not in good form
1058
1059
1060 if (!sign) {
1061 return null;
1062 }
1063
1064 var signMultiplier = sign === "+" ? 1 : -1;
1065
1066 if (unit === "%") {
1067 parsed.percentage += signMultiplier * (parsedValue / 100);
1068 } else {
1069 parsed.absolute += signMultiplier * parsedValue;
1070 } // Match next occurrence
1071
1072
1073 ++idx;
1074 matchResult = cssRegex.exec(cssValue);
1075 } // None-matched
1076
1077
1078 if (idx === 0) {
1079 return null;
1080 }
1081
1082 return parsed;
1083 };
1084 var parseCSSSizeValue = function (val) {
1085 return isString(val) ? val : val + "px";
1086 };
1087 var parsePanelAlign = function (align) {
1088 return typeof align === "object" ? align.panel : align;
1089 };
1090 var getDirection$1 = function (start, end) {
1091 if (start === end) return DIRECTION.NONE;
1092 return start < end ? DIRECTION.NEXT : DIRECTION.PREV;
1093 };
1094 var parseElement = function (element) {
1095 if (!Array.isArray(element)) {
1096 element = [element];
1097 }
1098
1099 var elements = [];
1100 element.forEach(function (el) {
1101 if (isString(el)) {
1102 var tempDiv = document.createElement("div");
1103 tempDiv.innerHTML = el;
1104 elements.push.apply(elements, __spread$1(toArray$2(tempDiv.children)));
1105
1106 while (tempDiv.firstChild) {
1107 tempDiv.removeChild(tempDiv.firstChild);
1108 }
1109 } else if (el && el.nodeType === Node.ELEMENT_NODE) {
1110 elements.push(el);
1111 } else {
1112 throw new FlickingError(MESSAGE.WRONG_TYPE(el, ["HTMLElement", "string"]), CODE.WRONG_TYPE);
1113 }
1114 });
1115 return elements;
1116 };
1117 var getMinusCompensatedIndex = function (idx, max) {
1118 return idx < 0 ? clamp$1(idx + max, 0, max) : clamp$1(idx, 0, max);
1119 };
1120 var includes = function (array, target) {
1121 var e_1, _a;
1122
1123 try {
1124 for (var array_1 = __values$1(array), array_1_1 = array_1.next(); !array_1_1.done; array_1_1 = array_1.next()) {
1125 var val = array_1_1.value;
1126 if (val === target) return true;
1127 }
1128 } catch (e_1_1) {
1129 e_1 = {
1130 error: e_1_1
1131 };
1132 } finally {
1133 try {
1134 if (array_1_1 && !array_1_1.done && (_a = array_1.return)) _a.call(array_1);
1135 } finally {
1136 if (e_1) throw e_1.error;
1137 }
1138 }
1139
1140 return false;
1141 };
1142 var isString = function (val) {
1143 return typeof val === "string";
1144 };
1145 var circulatePosition = function (pos, min, max) {
1146 var size = max - min;
1147
1148 if (pos < min) {
1149 var offset = (min - pos) % size;
1150 pos = max - offset;
1151 } else if (pos > max) {
1152 var offset = (pos - max) % size;
1153 pos = min + offset;
1154 }
1155
1156 return pos;
1157 };
1158 var find$1 = function (array, checker) {
1159 var e_2, _a;
1160
1161 try {
1162 for (var array_2 = __values$1(array), array_2_1 = array_2.next(); !array_2_1.done; array_2_1 = array_2.next()) {
1163 var val = array_2_1.value;
1164
1165 if (checker(val)) {
1166 return val;
1167 }
1168 }
1169 } catch (e_2_1) {
1170 e_2 = {
1171 error: e_2_1
1172 };
1173 } finally {
1174 try {
1175 if (array_2_1 && !array_2_1.done && (_a = array_2.return)) _a.call(array_2);
1176 } finally {
1177 if (e_2) throw e_2.error;
1178 }
1179 }
1180
1181 return null;
1182 };
1183 var findRight = function (array, checker) {
1184 for (var idx = array.length - 1; idx >= 0; idx--) {
1185 var val = array[idx];
1186
1187 if (checker(val)) {
1188 return val;
1189 }
1190 }
1191
1192 return null;
1193 };
1194 var findIndex = function (array, checker) {
1195 for (var idx = 0; idx < array.length; idx++) {
1196 if (checker(array[idx])) {
1197 return idx;
1198 }
1199 }
1200
1201 return -1;
1202 };
1203 var getProgress = function (pos, prev, next) {
1204 return (pos - prev) / (next - prev);
1205 }; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1206
1207 var getStyle = function (el) {
1208 return window.getComputedStyle(el) || el.currentStyle;
1209 };
1210 var setSize = function (el, _a) {
1211 var width = _a.width,
1212 height = _a.height;
1213
1214 if (width != null) {
1215 if (isString(width)) {
1216 el.style.width = width;
1217 } else {
1218 el.style.width = width + "px";
1219 }
1220 }
1221
1222 if (height != null) {
1223 if (isString(height)) {
1224 el.style.height = height;
1225 } else {
1226 el.style.height = height + "px";
1227 }
1228 }
1229 };
1230 var isBetween = function (val, min, max) {
1231 return val >= min && val <= max;
1232 };
1233 var circulateIndex = function (index, max) {
1234 if (index >= max) {
1235 return index % max;
1236 } else if (index < 0) {
1237 return getMinusCompensatedIndex((index + 1) % max - 1, max);
1238 } else {
1239 return index;
1240 }
1241 };
1242 var range = function (end) {
1243 var arr = new Array(end);
1244
1245 for (var i = 0; i < end; i++) {
1246 arr[i] = i;
1247 }
1248
1249 return arr;
1250 };
1251 var getElementSize = function (_a) {
1252 var el = _a.el,
1253 horizontal = _a.horizontal,
1254 useFractionalSize = _a.useFractionalSize,
1255 useOffset = _a.useOffset,
1256 style = _a.style;
1257
1258 if (useFractionalSize) {
1259 var baseSize = parseFloat(horizontal ? style.width : style.height);
1260 var isBorderBoxSizing = style.boxSizing === "border-box";
1261 var border = horizontal ? parseFloat(style.borderLeftWidth || "0") + parseFloat(style.borderRightWidth || "0") : parseFloat(style.borderTopWidth || "0") + parseFloat(style.borderBottomWidth || "0");
1262
1263 if (isBorderBoxSizing) {
1264 return useOffset ? baseSize : baseSize - border;
1265 } else {
1266 var padding = horizontal ? parseFloat(style.paddingLeft || "0") + parseFloat(style.paddingRight || "0") : parseFloat(style.paddingTop || "0") + parseFloat(style.paddingBottom || "0");
1267 return useOffset ? baseSize + padding + border : baseSize + padding;
1268 }
1269 } else {
1270 var sizeStr = horizontal ? "Width" : "Height";
1271 return useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
1272 }
1273 };
1274 var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
1275 obj.__proto__ = proto;
1276 return obj;
1277 };
1278
1279 var Utils = {
1280 __proto__: null,
1281 merge: merge,
1282 getElement: getElement,
1283 checkExistence: checkExistence,
1284 clamp: clamp$1,
1285 getFlickingAttached: getFlickingAttached,
1286 toArray: toArray$2,
1287 parseAlign: parseAlign$1,
1288 parseBounce: parseBounce,
1289 parseArithmeticSize: parseArithmeticSize,
1290 parseArithmeticExpression: parseArithmeticExpression,
1291 parseCSSSizeValue: parseCSSSizeValue,
1292 parsePanelAlign: parsePanelAlign,
1293 getDirection: getDirection$1,
1294 parseElement: parseElement,
1295 getMinusCompensatedIndex: getMinusCompensatedIndex,
1296 includes: includes,
1297 isString: isString,
1298 circulatePosition: circulatePosition,
1299 find: find$1,
1300 findRight: findRight,
1301 findIndex: findIndex,
1302 getProgress: getProgress,
1303 getStyle: getStyle,
1304 setSize: setSize,
1305 isBetween: isBetween,
1306 circulateIndex: circulateIndex,
1307 range: range,
1308 getElementSize: getElementSize,
1309 setPrototypeOf: setPrototypeOf
1310 };
1311
1312 /*
1313 * Copyright (c) 2015 NAVER Corp.
1314 * egjs projects are licensed under the MIT license
1315 */
1316 /**
1317 * Special type of known error that {@link Flicking} throws.
1318 * @ko Flicking 내부에서 알려진 오류 발생시 throw되는 에러
1319 * @property {number} code Error code<ko>에러 코드</ko>
1320 * @property {string} message Error message<ko>에러 메시지</ko>
1321 * @see {@link ERROR_CODE ERROR_CODE}
1322 * @example
1323 * ```ts
1324 * import Flicking, { FlickingError, ERROR_CODES } from "@egjs/flicking";
1325 * try {
1326 * const flicking = new Flicking(".flicking-viewport")
1327 * } catch (e) {
1328 * if (e instanceof FlickingError && e.code === ERROR_CODES.ELEMENT_NOT_FOUND) {
1329 * console.error("Element not found")
1330 * }
1331 * }
1332 * ```
1333 */
1334
1335 var FlickingError =
1336 /*#__PURE__*/
1337 function (_super) {
1338 __extends$2(FlickingError, _super);
1339 /**
1340 * @param message Error message<ko>에러 메시지</ko>
1341 * @param code Error code<ko>에러 코드</ko>
1342 */
1343
1344
1345 function FlickingError(message, code) {
1346 var _this = _super.call(this, message) || this;
1347
1348 setPrototypeOf(_this, FlickingError.prototype);
1349 _this.name = "FlickingError";
1350 _this.code = code;
1351 return _this;
1352 }
1353
1354 return FlickingError;
1355 }(Error);
1356
1357 /**
1358 * A component that manages viewport size
1359 * @ko 뷰포트 크기 정보를 담당하는 컴포넌트
1360 */
1361
1362 var Viewport =
1363 /*#__PURE__*/
1364 function () {
1365 /**
1366 * @param el A viewport element<ko>뷰포트 엘리먼트</ko>
1367 */
1368 function Viewport(flicking, el) {
1369 this._flicking = flicking;
1370 this._el = el;
1371 this._width = 0;
1372 this._height = 0;
1373 this._padding = {
1374 left: 0,
1375 right: 0,
1376 top: 0,
1377 bottom: 0
1378 };
1379 this._isBorderBoxSizing = false;
1380 }
1381
1382 var __proto = Viewport.prototype;
1383 Object.defineProperty(__proto, "element", {
1384 /**
1385 * A viewport(root) element
1386 * @ko 뷰포트(root) 엘리먼트
1387 * @type {HTMLElement}
1388 * @readonly
1389 */
1390 get: function () {
1391 return this._el;
1392 },
1393 enumerable: false,
1394 configurable: true
1395 });
1396 Object.defineProperty(__proto, "width", {
1397 /**
1398 * Viewport width, without paddings
1399 * @ko 뷰포트 너비
1400 * @type {number}
1401 * @readonly
1402 */
1403 get: function () {
1404 return this._width - this._padding.left - this._padding.right;
1405 },
1406 enumerable: false,
1407 configurable: true
1408 });
1409 Object.defineProperty(__proto, "height", {
1410 /**
1411 * Viewport height, without paddings
1412 * @ko 뷰포트 높이
1413 * @type {number}
1414 * @readonly
1415 */
1416 get: function () {
1417 return this._height - this._padding.top - this._padding.bottom;
1418 },
1419 enumerable: false,
1420 configurable: true
1421 });
1422 Object.defineProperty(__proto, "padding", {
1423 /**
1424 * Viewport paddings
1425 * @ko 뷰포트 CSS padding 값
1426 * @type {object}
1427 * @property {number} left CSS `padding-left`
1428 * @property {number} right CSS `padding-right`
1429 * @property {number} top CSS `padding-top`
1430 * @property {number} bottom CSS `padding-bottom`
1431 * @readonly
1432 */
1433 get: function () {
1434 return this._padding;
1435 },
1436 enumerable: false,
1437 configurable: true
1438 });
1439 /**
1440 * Change viewport's size.
1441 * This will change the actual size of `.flicking-viewport` element by changing its CSS width/height property
1442 * @ko 뷰포트 크기를 변경합니다.
1443 * `.flicking-viewport` 엘리먼트에 해당 크기의 CSS width/height를 적용합니다
1444 * @param {object} [size] New viewport size<ko>새 뷰포트 크기</ko>
1445 * @param {number|string} [size.width] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
1446 * @param {number|string} [size.height] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
1447 */
1448
1449 __proto.setSize = function (_a) {
1450 var width = _a.width,
1451 height = _a.height;
1452 var el = this._el;
1453 var padding = this._padding;
1454 var isBorderBoxSizing = this._isBorderBoxSizing;
1455
1456 if (width != null) {
1457 if (isString(width)) {
1458 el.style.width = width;
1459 } else {
1460 var newWidth = isBorderBoxSizing ? width + padding.left + padding.right : width;
1461 el.style.width = newWidth + "px";
1462 }
1463 }
1464
1465 if (height != null) {
1466 if (isString(height)) {
1467 el.style.height = height;
1468 } else {
1469 var newHeight = isBorderBoxSizing ? height + padding.top + padding.bottom : height;
1470 el.style.height = newHeight + "px";
1471 }
1472 }
1473
1474 this.resize();
1475 };
1476 /**
1477 * Update width/height to the current viewport element's size
1478 * @ko 현재 뷰포트 엘리먼트의 크기로 너비/높이를 업데이트합니다
1479 */
1480
1481
1482 __proto.resize = function () {
1483 var el = this._el;
1484 var elStyle = getStyle(el);
1485 var useFractionalSize = this._flicking.useFractionalSize;
1486 this._width = getElementSize({
1487 el: el,
1488 horizontal: true,
1489 useFractionalSize: useFractionalSize,
1490 useOffset: false,
1491 style: elStyle
1492 });
1493 this._height = getElementSize({
1494 el: el,
1495 horizontal: false,
1496 useFractionalSize: useFractionalSize,
1497 useOffset: false,
1498 style: elStyle
1499 });
1500 this._padding = {
1501 left: elStyle.paddingLeft ? parseFloat(elStyle.paddingLeft) : 0,
1502 right: elStyle.paddingRight ? parseFloat(elStyle.paddingRight) : 0,
1503 top: elStyle.paddingTop ? parseFloat(elStyle.paddingTop) : 0,
1504 bottom: elStyle.paddingBottom ? parseFloat(elStyle.paddingBottom) : 0
1505 };
1506 this._isBorderBoxSizing = elStyle.boxSizing === "border-box";
1507 };
1508
1509 return Viewport;
1510 }();
1511
1512 var AutoResizer =
1513 /*#__PURE__*/
1514 function () {
1515 function AutoResizer(flicking) {
1516 var _this = this;
1517
1518 this._onResize = function () {
1519 var flicking = _this._flicking;
1520 var resizeDebounce = flicking.resizeDebounce;
1521 var maxResizeDebounce = flicking.maxResizeDebounce;
1522
1523 if (resizeDebounce <= 0) {
1524 void flicking.resize();
1525 } else {
1526 if (_this._maxResizeDebounceTimer <= 0) {
1527 if (maxResizeDebounce > 0 && maxResizeDebounce >= resizeDebounce) {
1528 _this._maxResizeDebounceTimer = window.setTimeout(_this._doScheduledResize, maxResizeDebounce);
1529 }
1530 }
1531
1532 if (_this._resizeTimer > 0) {
1533 clearTimeout(_this._resizeTimer);
1534 _this._resizeTimer = 0;
1535 }
1536
1537 _this._resizeTimer = window.setTimeout(_this._doScheduledResize, resizeDebounce);
1538 }
1539 };
1540
1541 this._doScheduledResize = function () {
1542 clearTimeout(_this._resizeTimer);
1543 clearTimeout(_this._maxResizeDebounceTimer);
1544 _this._maxResizeDebounceTimer = -1;
1545 _this._resizeTimer = -1;
1546 void _this._flicking.resize();
1547 }; // eslint-disable-next-line @typescript-eslint/member-ordering
1548
1549
1550 this._skipFirstResize = function () {
1551 var isFirstResize = true;
1552 return function () {
1553 if (isFirstResize) {
1554 isFirstResize = false;
1555 return;
1556 }
1557
1558 _this._onResize();
1559 };
1560 }();
1561
1562 this._flicking = flicking;
1563 this._enabled = false;
1564 this._resizeObserver = null;
1565 this._resizeTimer = -1;
1566 this._maxResizeDebounceTimer = -1;
1567 }
1568
1569 var __proto = AutoResizer.prototype;
1570 Object.defineProperty(__proto, "enabled", {
1571 get: function () {
1572 return this._enabled;
1573 },
1574 enumerable: false,
1575 configurable: true
1576 });
1577
1578 __proto.enable = function () {
1579 var flicking = this._flicking;
1580 var viewport = flicking.viewport;
1581
1582 if (this._enabled) {
1583 this.disable();
1584 }
1585
1586 if (flicking.useResizeObserver && !!window.ResizeObserver) {
1587 var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
1588 var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
1589 resizeObserver.observe(flicking.viewport.element);
1590 this._resizeObserver = resizeObserver;
1591 } else {
1592 window.addEventListener("resize", this._onResize);
1593 }
1594
1595 this._enabled = true;
1596 return this;
1597 };
1598
1599 __proto.disable = function () {
1600 if (!this._enabled) return this;
1601 var resizeObserver = this._resizeObserver;
1602
1603 if (resizeObserver) {
1604 resizeObserver.disconnect();
1605 this._resizeObserver = null;
1606 } else {
1607 window.removeEventListener("resize", this._onResize);
1608 }
1609
1610 this._enabled = false;
1611 return this;
1612 };
1613
1614 return AutoResizer;
1615 }();
1616
1617 /**
1618 * @internal
1619 */
1620 var VanillaElementProvider =
1621 /*#__PURE__*/
1622 function () {
1623 function VanillaElementProvider(element) {
1624 this._element = element;
1625 this._rendered = true;
1626 }
1627
1628 var __proto = VanillaElementProvider.prototype;
1629 Object.defineProperty(__proto, "element", {
1630 get: function () {
1631 return this._element;
1632 },
1633 enumerable: false,
1634 configurable: true
1635 });
1636 Object.defineProperty(__proto, "rendered", {
1637 get: function () {
1638 return this._rendered;
1639 },
1640 enumerable: false,
1641 configurable: true
1642 });
1643
1644 __proto.show = function (flicking) {
1645 var el = this.element;
1646 var cameraEl = flicking.camera.element;
1647
1648 if (el.parentElement !== cameraEl) {
1649 cameraEl.appendChild(el);
1650 this._rendered = true;
1651 }
1652 };
1653
1654 __proto.hide = function (flicking) {
1655 var el = this.element;
1656 var cameraEl = flicking.camera.element;
1657
1658 if (el.parentElement === cameraEl) {
1659 cameraEl.removeChild(el);
1660 this._rendered = false;
1661 }
1662 };
1663
1664 return VanillaElementProvider;
1665 }();
1666
1667 /*
1668 * Copyright (c) 2015 NAVER Corp.
1669 * egjs projects are licensed under the MIT license
1670 */
1671
1672 /**
1673 * @internal
1674 */
1675 var VirtualElementProvider =
1676 /*#__PURE__*/
1677 function () {
1678 function VirtualElementProvider(flicking) {
1679 this._flicking = flicking;
1680 }
1681
1682 var __proto = VirtualElementProvider.prototype;
1683 Object.defineProperty(__proto, "element", {
1684 get: function () {
1685 return this._virtualElement.nativeElement;
1686 },
1687 enumerable: false,
1688 configurable: true
1689 });
1690 Object.defineProperty(__proto, "rendered", {
1691 get: function () {
1692 return this._virtualElement.visible;
1693 },
1694 enumerable: false,
1695 configurable: true
1696 });
1697 Object.defineProperty(__proto, "_virtualElement", {
1698 get: function () {
1699 var flicking = this._flicking;
1700 var elIndex = this._panel.elementIndex;
1701 var virtualElements = flicking.virtual.elements;
1702 return virtualElements[elIndex];
1703 },
1704 enumerable: false,
1705 configurable: true
1706 });
1707
1708 __proto.init = function (panel) {
1709 this._panel = panel;
1710 };
1711
1712 __proto.show = function () {// DO_NOTHING
1713 // Actual element visibility is controlled by VirtualManager
1714 };
1715
1716 __proto.hide = function () {// DO_NOTHING
1717 // Actual element visibility is controlled by VirtualManager
1718 };
1719
1720 return VirtualElementProvider;
1721 }();
1722
1723 /**
1724 * A manager class to add / remove virtual panels
1725 */
1726
1727 var VirtualManager =
1728 /*#__PURE__*/
1729 function () {
1730 function VirtualManager(flicking, options) {
1731 var _a, _b, _c, _d;
1732
1733 this._flicking = flicking;
1734 this._renderPanel = (_a = options === null || options === void 0 ? void 0 : options.renderPanel) !== null && _a !== void 0 ? _a : function () {
1735 return "";
1736 };
1737 this._initialPanelCount = (_b = options === null || options === void 0 ? void 0 : options.initialPanelCount) !== null && _b !== void 0 ? _b : -1;
1738 this._cache = (_c = options === null || options === void 0 ? void 0 : options.cache) !== null && _c !== void 0 ? _c : false;
1739 this._panelClass = (_d = options === null || options === void 0 ? void 0 : options.panelClass) !== null && _d !== void 0 ? _d : CLASS.DEFAULT_VIRTUAL;
1740 this._elements = [];
1741 }
1742
1743 var __proto = VirtualManager.prototype;
1744 Object.defineProperty(__proto, "elements", {
1745 get: function () {
1746 return this._elements;
1747 },
1748 enumerable: false,
1749 configurable: true
1750 });
1751 Object.defineProperty(__proto, "renderPanel", {
1752 // Options
1753
1754 /**
1755 * A rendering function for the panel element's innerHTML
1756 * @ko 패널 엘리먼트의 innerHTML을 렌더링하는 함수
1757 * @type {function}
1758 * @param {VirtualPanel} panel Instance of the panel<ko>패널 인스턴스</ko>
1759 * @param {number} index Index of the panel<ko>패널 인덱스</ko>
1760 * @default "() => {}"
1761 */
1762 get: function () {
1763 return this._renderPanel;
1764 },
1765 set: function (val) {
1766 this._renderPanel = val;
1767
1768 this._flicking.renderer.panels.forEach(function (panel) {
1769 return panel.uncacheRenderResult();
1770 });
1771 },
1772 enumerable: false,
1773 configurable: true
1774 });
1775 Object.defineProperty(__proto, "initialPanelCount", {
1776 /**
1777 * Initial panel count to render
1778 * @ko 최초로 렌더링할 패널의 개수
1779 * @readonly
1780 * @type {number}
1781 * @default -1
1782 */
1783 get: function () {
1784 return this._initialPanelCount;
1785 },
1786 enumerable: false,
1787 configurable: true
1788 });
1789 Object.defineProperty(__proto, "cache", {
1790 /**
1791 * Whether to cache rendered panel's innerHTML
1792 * @ko 렌더링된 패널의 innerHTML 정보를 캐시할지 여부
1793 * @type {boolean}
1794 * @default false
1795 */
1796 get: function () {
1797 return this._cache;
1798 },
1799 set: function (val) {
1800 this._cache = val;
1801 },
1802 enumerable: false,
1803 configurable: true
1804 });
1805 Object.defineProperty(__proto, "panelClass", {
1806 /**
1807 * The class name that will be applied to rendered panel elements
1808 * @ko 렌더링되는 패널 엘리먼트에 적용될 클래스 이름
1809 * @type {string}
1810 * @default "flicking-panel"
1811 */
1812 get: function () {
1813 return this._panelClass;
1814 },
1815 set: function (val) {
1816 this._panelClass = val;
1817 },
1818 enumerable: false,
1819 configurable: true
1820 });
1821
1822 __proto.init = function () {
1823 var flicking = this._flicking;
1824 if (!flicking.virtualEnabled) return;
1825
1826 if (!flicking.externalRenderer && !flicking.renderExternal) {
1827 this._initVirtualElements();
1828 }
1829
1830 var virtualElements = flicking.camera.children;
1831 this._elements = virtualElements.map(function (el) {
1832 return {
1833 nativeElement: el,
1834 visible: true
1835 };
1836 });
1837 };
1838
1839 __proto.show = function (index) {
1840 var el = this._elements[index];
1841 var nativeEl = el.nativeElement;
1842 el.visible = true;
1843
1844 if (nativeEl.style.display) {
1845 nativeEl.style.display = "";
1846 }
1847 };
1848
1849 __proto.hide = function (index) {
1850 var el = this._elements[index];
1851 var nativeEl = el.nativeElement;
1852 el.visible = false;
1853 nativeEl.style.display = "none";
1854 };
1855 /**
1856 * Add new virtual panels at the end of the list
1857 * @ko 새로운 가상 패널들을 리스트의 끝에 추가합니다
1858 * @param {number} count The number of panels to add<ko>추가할 패널의 개수</ko>
1859 * @returns {Array<VirtualPanel>} The new panels added<ko>새롭게 추가된 패널들</ko>
1860 */
1861
1862
1863 __proto.append = function (count) {
1864 if (count === void 0) {
1865 count = 1;
1866 }
1867
1868 var flicking = this._flicking;
1869 return this.insert(flicking.panels.length, count);
1870 };
1871 /**
1872 * Add new virtual panels at the start of the list
1873 * @ko 새로운 가상 패널들을 리스트의 시작에 추가합니다
1874 * @param {number} count The number of panels to add<ko>추가할 패널의 개수</ko>
1875 * @returns {Array<VirtualPanel>} The new panels added<ko>새롭게 추가된 패널들</ko>
1876 */
1877
1878
1879 __proto.prepend = function (count) {
1880 if (count === void 0) {
1881 count = 1;
1882 }
1883
1884 return this.insert(0, count);
1885 };
1886 /**
1887 * Add new virtual panels at the given index
1888 * @ko 새로운 가상 패널들을 주어진 인덱스에 추가합니다
1889 * @param {number} count The number of panels to add<ko>추가할 패널의 개수</ko>
1890 * @returns {Array<VirtualPanel>} The new panels added<ko>새롭게 추가된 패널들</ko>
1891 */
1892
1893
1894 __proto.insert = function (index, count) {
1895 if (count === void 0) {
1896 count = 1;
1897 }
1898
1899 if (count <= 0) return [];
1900 var flicking = this._flicking;
1901 return flicking.renderer.batchInsert({
1902 index: index,
1903 elements: range(count),
1904 hasDOMInElements: false
1905 });
1906 };
1907 /**
1908 * Remove panels at the given index
1909 * @ko 주어진 인덱스에서 패널들을 삭제합니다
1910 * @param {number} count The number of panels to remove<ko>삭제할 패널의 개수</ko>
1911 * @returns {Array<VirtualPanel>} The panels removed<ko>삭제된 패널들</ko>
1912 */
1913
1914
1915 __proto.remove = function (index, count) {
1916 if (count <= 0) return [];
1917 var flicking = this._flicking;
1918 return flicking.renderer.batchRemove({
1919 index: index,
1920 deleteCount: count,
1921 hasDOMInElements: false
1922 });
1923 };
1924
1925 __proto._initVirtualElements = function () {
1926 var _this = this;
1927
1928 var flicking = this._flicking;
1929 var cameraElement = flicking.camera.element;
1930 var panelsPerView = flicking.panelsPerView;
1931 var fragment = document.createDocumentFragment();
1932 var newElements = range(panelsPerView + 1).map(function (idx) {
1933 var panelEl = document.createElement("div");
1934 panelEl.className = _this._panelClass;
1935 panelEl.dataset.elementIndex = idx.toString();
1936 return panelEl;
1937 });
1938 newElements.forEach(function (el) {
1939 fragment.appendChild(el);
1940 });
1941 cameraElement.appendChild(fragment);
1942 };
1943
1944 return VirtualManager;
1945 }();
1946
1947 /*
1948 Copyright (c) 2015 NAVER Corp.
1949 name: @egjs/agent
1950 license: MIT
1951 author: NAVER Corp.
1952 repository: git+https://github.com/naver/agent.git
1953 version: 2.4.2
1954 */
1955 function some(arr, callback) {
1956 var length = arr.length;
1957
1958 for (var i = 0; i < length; ++i) {
1959 if (callback(arr[i], i)) {
1960 return true;
1961 }
1962 }
1963
1964 return false;
1965 }
1966 function find(arr, callback) {
1967 var length = arr.length;
1968
1969 for (var i = 0; i < length; ++i) {
1970 if (callback(arr[i], i)) {
1971 return arr[i];
1972 }
1973 }
1974
1975 return null;
1976 }
1977 function getUserAgentString(agent) {
1978 var userAgent = agent;
1979
1980 if (typeof userAgent === "undefined") {
1981 if (typeof navigator === "undefined" || !navigator) {
1982 return "";
1983 }
1984
1985 userAgent = navigator.userAgent || "";
1986 }
1987
1988 return userAgent.toLowerCase();
1989 }
1990 function execRegExp(pattern, text) {
1991 try {
1992 return new RegExp(pattern, "g").exec(text);
1993 } catch (e) {
1994 return null;
1995 }
1996 }
1997 function hasUserAgentData() {
1998 if (typeof navigator === "undefined" || !navigator || !navigator.userAgentData) {
1999 return false;
2000 }
2001
2002 var userAgentData = navigator.userAgentData;
2003 var brands = userAgentData.brands || userAgentData.uaList;
2004 return !!(brands && brands.length);
2005 }
2006 function findVersion(versionTest, userAgent) {
2007 var result = execRegExp("(" + versionTest + ")((?:\\/|\\s|:)([0-9|\\.|_]+))", userAgent);
2008 return result ? result[3] : "";
2009 }
2010 function convertVersion(text) {
2011 return text.replace(/_/g, ".");
2012 }
2013 function findPreset(presets, userAgent) {
2014 var userPreset = null;
2015 var version = "-1";
2016 some(presets, function (preset) {
2017 var result = execRegExp("(" + preset.test + ")((?:\\/|\\s|:)([0-9|\\.|_]+))?", userAgent);
2018
2019 if (!result || preset.brand) {
2020 return false;
2021 }
2022
2023 userPreset = preset;
2024 version = result[3] || "-1";
2025
2026 if (preset.versionAlias) {
2027 version = preset.versionAlias;
2028 } else if (preset.versionTest) {
2029 version = findVersion(preset.versionTest.toLowerCase(), userAgent) || version;
2030 }
2031
2032 version = convertVersion(version);
2033 return true;
2034 });
2035 return {
2036 preset: userPreset,
2037 version: version
2038 };
2039 }
2040 function findPresetBrand(presets, brands) {
2041 var brandInfo = {
2042 brand: "",
2043 version: "-1"
2044 };
2045 some(presets, function (preset) {
2046 var result = findBrand(brands, preset);
2047
2048 if (!result) {
2049 return false;
2050 }
2051
2052 brandInfo.brand = preset.id;
2053 brandInfo.version = preset.versionAlias || result.version;
2054 return brandInfo.version !== "-1";
2055 });
2056 return brandInfo;
2057 }
2058 function findBrand(brands, preset) {
2059 return find(brands, function (_a) {
2060 var brand = _a.brand;
2061 return execRegExp("" + preset.test, brand.toLowerCase());
2062 });
2063 }
2064
2065 var BROWSER_PRESETS = [{
2066 test: "phantomjs",
2067 id: "phantomjs"
2068 }, {
2069 test: "whale",
2070 id: "whale"
2071 }, {
2072 test: "edgios|edge|edg",
2073 id: "edge"
2074 }, {
2075 test: "msie|trident|windows phone",
2076 id: "ie",
2077 versionTest: "iemobile|msie|rv"
2078 }, {
2079 test: "miuibrowser",
2080 id: "miui browser"
2081 }, {
2082 test: "samsungbrowser",
2083 id: "samsung internet"
2084 }, {
2085 test: "samsung",
2086 id: "samsung internet",
2087 versionTest: "version"
2088 }, {
2089 test: "chrome|crios",
2090 id: "chrome"
2091 }, {
2092 test: "firefox|fxios",
2093 id: "firefox"
2094 }, {
2095 test: "android",
2096 id: "android browser",
2097 versionTest: "version"
2098 }, {
2099 test: "safari|iphone|ipad|ipod",
2100 id: "safari",
2101 versionTest: "version"
2102 }]; // chromium's engine(blink) is based on applewebkit 537.36.
2103
2104 var CHROMIUM_PRESETS = [{
2105 test: "(?=.*applewebkit/(53[0-7]|5[0-2]|[0-4]))(?=.*\\schrome)",
2106 id: "chrome",
2107 versionTest: "chrome"
2108 }, {
2109 test: "chromium",
2110 id: "chrome"
2111 }, {
2112 test: "whale",
2113 id: "chrome",
2114 versionAlias: "-1",
2115 brand: true
2116 }];
2117 var WEBKIT_PRESETS = [{
2118 test: "applewebkit",
2119 id: "webkit",
2120 versionTest: "applewebkit|safari"
2121 }];
2122 var WEBVIEW_PRESETS = [{
2123 test: "(?=(iphone|ipad))(?!(.*version))",
2124 id: "webview"
2125 }, {
2126 test: "(?=(android|iphone|ipad))(?=.*(naver|daum|; wv))",
2127 id: "webview"
2128 }, {
2129 // test webview
2130 test: "webview",
2131 id: "webview"
2132 }];
2133 var OS_PRESETS = [{
2134 test: "windows phone",
2135 id: "windows phone"
2136 }, {
2137 test: "windows 2000",
2138 id: "window",
2139 versionAlias: "5.0"
2140 }, {
2141 test: "windows nt",
2142 id: "window"
2143 }, {
2144 test: "win32|windows",
2145 id: "window"
2146 }, {
2147 test: "iphone|ipad|ipod",
2148 id: "ios",
2149 versionTest: "iphone os|cpu os"
2150 }, {
2151 test: "macos|macintel|mac os x",
2152 id: "mac"
2153 }, {
2154 test: "android|linux armv81",
2155 id: "android"
2156 }, {
2157 test: "tizen",
2158 id: "tizen"
2159 }, {
2160 test: "webos|web0s",
2161 id: "webos"
2162 }];
2163
2164 function isWebView(userAgent) {
2165 return !!findPreset(WEBVIEW_PRESETS, userAgent).preset;
2166 }
2167 function getLegacyAgent(userAgent) {
2168 var nextAgent = getUserAgentString(userAgent);
2169 var isMobile = !!/mobi/g.exec(nextAgent);
2170 var browser = {
2171 name: "unknown",
2172 version: "-1",
2173 majorVersion: -1,
2174 webview: isWebView(nextAgent),
2175 chromium: false,
2176 chromiumVersion: "-1",
2177 webkit: false,
2178 webkitVersion: "-1"
2179 };
2180 var os = {
2181 name: "unknown",
2182 version: "-1",
2183 majorVersion: -1
2184 };
2185
2186 var _a = findPreset(BROWSER_PRESETS, nextAgent),
2187 browserPreset = _a.preset,
2188 browserVersion = _a.version;
2189
2190 var _b = findPreset(OS_PRESETS, nextAgent),
2191 osPreset = _b.preset,
2192 osVersion = _b.version;
2193
2194 var chromiumPreset = findPreset(CHROMIUM_PRESETS, nextAgent);
2195 browser.chromium = !!chromiumPreset.preset;
2196 browser.chromiumVersion = chromiumPreset.version;
2197
2198 if (!browser.chromium) {
2199 var webkitPreset = findPreset(WEBKIT_PRESETS, nextAgent);
2200 browser.webkit = !!webkitPreset.preset;
2201 browser.webkitVersion = webkitPreset.version;
2202 }
2203
2204 if (osPreset) {
2205 os.name = osPreset.id;
2206 os.version = osVersion;
2207 os.majorVersion = parseInt(osVersion, 10);
2208 }
2209
2210 if (browserPreset) {
2211 browser.name = browserPreset.id;
2212 browser.version = browserVersion; // Early whale bugs
2213
2214 if (browser.webview && os.name === "ios" && browser.name !== "safari") {
2215 browser.webview = false;
2216 }
2217 }
2218
2219 browser.majorVersion = parseInt(browser.version, 10);
2220 return {
2221 browser: browser,
2222 os: os,
2223 isMobile: isMobile,
2224 isHints: false
2225 };
2226 }
2227
2228 function getClientHintsAgent(osData) {
2229 var userAgentData = navigator.userAgentData;
2230 var brands = (userAgentData.uaList || userAgentData.brands).slice();
2231 var fullVersionList = osData && osData.fullVersionList;
2232 var isMobile = userAgentData.mobile || false;
2233 var firstBrand = brands[0];
2234 var platform = (osData && osData.platform || userAgentData.platform || navigator.platform).toLowerCase();
2235 var browser = {
2236 name: firstBrand.brand,
2237 version: firstBrand.version,
2238 majorVersion: -1,
2239 webkit: false,
2240 webkitVersion: "-1",
2241 chromium: false,
2242 chromiumVersion: "-1",
2243 webview: !!findPresetBrand(WEBVIEW_PRESETS, brands).brand || isWebView(getUserAgentString())
2244 };
2245 var os = {
2246 name: "unknown",
2247 version: "-1",
2248 majorVersion: -1
2249 };
2250 browser.webkit = !browser.chromium && some(WEBKIT_PRESETS, function (preset) {
2251 return findBrand(brands, preset);
2252 });
2253 var chromiumBrand = findPresetBrand(CHROMIUM_PRESETS, brands);
2254 browser.chromium = !!chromiumBrand.brand;
2255 browser.chromiumVersion = chromiumBrand.version;
2256
2257 if (!browser.chromium) {
2258 var webkitBrand = findPresetBrand(WEBKIT_PRESETS, brands);
2259 browser.webkit = !!webkitBrand.brand;
2260 browser.webkitVersion = webkitBrand.version;
2261 }
2262
2263 var platfomResult = find(OS_PRESETS, function (preset) {
2264 return new RegExp("" + preset.test, "g").exec(platform);
2265 });
2266 os.name = platfomResult ? platfomResult.id : "";
2267
2268 if (osData) {
2269 os.version = osData.platformVersion;
2270 }
2271
2272 if (fullVersionList && fullVersionList.length) {
2273 var browserBrandByFullVersionList = findPresetBrand(BROWSER_PRESETS, fullVersionList);
2274 browser.name = browserBrandByFullVersionList.brand || browser.name;
2275 browser.version = browserBrandByFullVersionList.version || browser.version;
2276 } else {
2277 var browserBrand = findPresetBrand(BROWSER_PRESETS, brands);
2278 browser.name = browserBrand.brand || browser.name;
2279 browser.version = browserBrand.brand && osData ? osData.uaFullVersion : browserBrand.version;
2280 }
2281
2282 if (browser.webkit) {
2283 os.name = isMobile ? "ios" : "mac";
2284 }
2285
2286 if (os.name === "ios" && browser.webview) {
2287 browser.version = "-1";
2288 }
2289
2290 os.version = convertVersion(os.version);
2291 browser.version = convertVersion(browser.version);
2292 os.majorVersion = parseInt(os.version, 10);
2293 browser.majorVersion = parseInt(browser.version, 10);
2294 return {
2295 browser: browser,
2296 os: os,
2297 isMobile: isMobile,
2298 isHints: true
2299 };
2300 }
2301 /**
2302 * Extracts browser and operating system information from the user agent string.
2303 * @ko 유저 에이전트 문자열에서 브라우저와 운영체제 정보를 추출한다.
2304 * @function eg.agent#agent
2305 * @param - user agent string to parse <ko>파싱할 유저에이전트 문자열</ko>
2306 * @return - agent Info <ko> 에이전트 정보 </ko>
2307 * @example
2308 import agent from "@egjs/agent";
2309 // eg.agent();
2310 const { os, browser, isMobile } = agent();
2311 */
2312
2313 function agent(userAgent) {
2314 if (typeof userAgent === "undefined" && hasUserAgentData()) {
2315 return getClientHintsAgent();
2316 } else {
2317 return getLegacyAgent(userAgent);
2318 }
2319 }
2320
2321 /*
2322 Copyright (c) NAVER Crop.
2323 name: @cfcs/core
2324 license: MIT
2325 author: NAVER Crop.
2326 repository: https://github.com/naver/cfcs
2327 version: 0.0.4
2328 */
2329
2330 /**
2331 * cfcs
2332 * Copyright (c) 2022-present NAVER Corp.
2333 * MIT license
2334 */
2335 function keys(obj) {
2336 return Object.keys(obj);
2337 }
2338
2339 var OBSERVERS_PATH = "__observers__";
2340
2341 var Observer =
2342 /*#__PURE__*/
2343 function () {
2344 function Observer(value) {
2345 this._emitter = new Component();
2346 this._current = value;
2347 }
2348
2349 var __proto = Observer.prototype;
2350 Object.defineProperty(__proto, "current", {
2351 get: function () {
2352 return this._current;
2353 },
2354 set: function (value) {
2355 var isUpdate = value !== this._current;
2356 this._current = value;
2357
2358 if (isUpdate) {
2359 this._emitter.trigger("update", value);
2360 }
2361 },
2362 enumerable: false,
2363 configurable: true
2364 });
2365
2366 __proto.subscribe = function (callback) {
2367 this._emitter.on("update", callback);
2368 };
2369
2370 __proto.unsubscribe = function (callback) {
2371 this._emitter.off("update", callback);
2372 };
2373
2374 return Observer;
2375 }();
2376 function observe(defaultValue) {
2377 return new Observer(defaultValue);
2378 }
2379 function getObservers(instance) {
2380 if (!instance[OBSERVERS_PATH]) {
2381 instance[OBSERVERS_PATH] = {};
2382 }
2383
2384 return instance[OBSERVERS_PATH];
2385 }
2386 function getObserver(instance, name, defaultValue) {
2387 var observers = getObservers(instance);
2388
2389 if (!observers[name]) {
2390 observers[name] = observe(defaultValue);
2391 }
2392
2393 return observers[name];
2394 }
2395
2396 function injectReactiveSubscribe(object) {
2397 object["subscribe"] = function (name, callback) {
2398 getObserver(this, name).subscribe(callback);
2399 };
2400
2401 object["unsubscribe"] = function (name, callback) {
2402 var _this = this;
2403
2404 if (!name) {
2405 keys(getObservers(this)).forEach(function (observerName) {
2406 _this.unsubscribe(observerName);
2407 });
2408 return;
2409 }
2410
2411 if (!(name in this)) {
2412 return;
2413 }
2414
2415 getObserver(this, name).unsubscribe(callback);
2416 };
2417 }
2418 function ReactiveSubscribe(Constructor) {
2419 var prototype = Constructor.prototype;
2420 injectReactiveSubscribe(prototype);
2421 }
2422
2423 /*
2424 Copyright (c) NAVER Corp.
2425 name: @egjs/axes
2426 license: MIT
2427 author: NAVER Corp.
2428 repository: https://github.com/naver/egjs-axes
2429 version: 3.8.1
2430 */
2431
2432 /*! *****************************************************************************
2433 Copyright (c) Microsoft Corporation. All rights reserved.
2434 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
2435 this file except in compliance with the License. You may obtain a copy of the
2436 License at http://www.apache.org/licenses/LICENSE-2.0
2437
2438 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2439 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
2440 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
2441 MERCHANTABLITY OR NON-INFRINGEMENT.
2442
2443 See the Apache Version 2.0 License for specific language governing permissions
2444 and limitations under the License.
2445 ***************************************************************************** */
2446
2447 /* global Reflect, Promise */
2448 var extendStatics$1 = function (d, b) {
2449 extendStatics$1 = Object.setPrototypeOf || {
2450 __proto__: []
2451 } instanceof Array && function (d, b) {
2452 d.__proto__ = b;
2453 } || function (d, b) {
2454 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
2455 };
2456
2457 return extendStatics$1(d, b);
2458 };
2459
2460 function __extends$1(d, b) {
2461 extendStatics$1(d, b);
2462
2463 function __() {
2464 this.constructor = d;
2465 }
2466
2467 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2468 }
2469 var __assign$1 = function () {
2470 __assign$1 = Object.assign || function __assign(t) {
2471 for (var s, i = 1, n = arguments.length; i < n; i++) {
2472 s = arguments[i];
2473
2474 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
2475 }
2476
2477 return t;
2478 };
2479
2480 return __assign$1.apply(this, arguments);
2481 };
2482 function __decorate(decorators, target, key, desc) {
2483 var c = arguments.length,
2484 r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
2485 d;
2486 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2487 return c > 3 && r && Object.defineProperty(target, key, r), r;
2488 }
2489
2490 /*
2491 * Copyright (c) 2015 NAVER Corp.
2492 * egjs projects are licensed under the MIT license
2493 */
2494
2495 /* eslint-disable no-new-func, no-nested-ternary */
2496 var win;
2497
2498 if (typeof window === "undefined") {
2499 // window is undefined in node.js
2500 win = {
2501 navigator: {
2502 userAgent: ""
2503 }
2504 };
2505 } else {
2506 win = window;
2507 }
2508
2509 /*
2510 * Copyright (c) 2015 NAVER Corp.
2511 * egjs projects are licensed under the MIT license
2512 */
2513 var DIRECTION_NONE = 1;
2514 var DIRECTION_LEFT = 2;
2515 var DIRECTION_RIGHT = 4;
2516 var DIRECTION_HORIZONTAL = 2 | 4;
2517 var DIRECTION_UP = 8;
2518 var DIRECTION_DOWN = 16;
2519 var DIRECTION_VERTICAL = 8 | 16;
2520 var DIRECTION_ALL = 2 | 4 | 8 | 16;
2521 var MOUSE_LEFT = "left";
2522 var MOUSE_RIGHT = "right";
2523 var MOUSE_MIDDLE = "middle";
2524 var VELOCITY_INTERVAL = 16;
2525 var IOS_EDGE_THRESHOLD = 30;
2526 var IS_IOS_SAFARI = "ontouchstart" in win && agent().browser.name === "safari";
2527 var TRANSFORM = function () {
2528 if (typeof document === "undefined") {
2529 return "";
2530 }
2531
2532 var bodyStyle = (document.head || document.getElementsByTagName("head")[0]).style;
2533 var target = ["transform", "webkitTransform", "msTransform", "mozTransform"];
2534
2535 for (var i = 0, len = target.length; i < len; i++) {
2536 if (target[i] in bodyStyle) {
2537 return target[i];
2538 }
2539 }
2540
2541 return "";
2542 }();
2543 var PREVENT_DRAG_CSSPROPS = {
2544 "user-select": "none",
2545 "-webkit-user-drag": "none"
2546 };
2547
2548 var toArray$1 = function (nodes) {
2549 // const el = Array.prototype.slice.call(nodes);
2550 // for IE8
2551 var el = [];
2552
2553 for (var i = 0, len = nodes.length; i < len; i++) {
2554 el.push(nodes[i]);
2555 }
2556
2557 return el;
2558 };
2559 var $ = function (param, multi) {
2560 if (multi === void 0) {
2561 multi = false;
2562 }
2563
2564 var el;
2565
2566 if (typeof param === "string") {
2567 // String (HTML, Selector)
2568 // check if string is HTML tag format
2569 var match = param.match(/^<([a-z]+)\s*([^>]*)>/); // creating element
2570
2571 if (match) {
2572 // HTML
2573 var dummy = document.createElement("div");
2574 dummy.innerHTML = param;
2575 el = toArray$1(dummy.childNodes);
2576 } else {
2577 // Selector
2578 el = toArray$1(document.querySelectorAll(param));
2579 }
2580
2581 if (!multi) {
2582 el = el.length >= 1 ? el[0] : undefined;
2583 }
2584 } else if (param === win) {
2585 // window
2586 el = param;
2587 } else if ("value" in param || "current" in param) {
2588 el = param.value || param.current;
2589 } else if (param.nodeName && (param.nodeType === 1 || param.nodeType === 9)) {
2590 // HTMLElement, Document
2591 el = param;
2592 } else if ("jQuery" in win && param instanceof jQuery || param.constructor.prototype.jquery) {
2593 // jQuery
2594 el = multi ? param.toArray() : param.get(0);
2595 } else if (Array.isArray(param)) {
2596 el = param.map(function (v) {
2597 return $(v);
2598 });
2599
2600 if (!multi) {
2601 el = el.length >= 1 ? el[0] : undefined;
2602 }
2603 }
2604
2605 return el;
2606 };
2607 var raf = win.requestAnimationFrame || win.webkitRequestAnimationFrame;
2608 var caf = win.cancelAnimationFrame || win.webkitCancelAnimationFrame;
2609
2610 if (raf && !caf) {
2611 var keyInfo_1 = {};
2612 var oldraf_1 = raf;
2613
2614 raf = function (callback) {
2615 var wrapCallback = function (timestamp) {
2616 if (keyInfo_1[key]) {
2617 callback(timestamp);
2618 }
2619 };
2620
2621 var key = oldraf_1(wrapCallback);
2622 keyInfo_1[key] = true;
2623 return key;
2624 };
2625
2626 caf = function (key) {
2627 delete keyInfo_1[key];
2628 };
2629 } else if (!(raf && caf)) {
2630 raf = function (callback) {
2631 return win.setTimeout(function () {
2632 callback(win.performance && win.performance.now && win.performance.now() || new Date().getTime());
2633 }, 16);
2634 };
2635
2636 caf = win.clearTimeout;
2637 }
2638 /**
2639 * A polyfill for the window.requestAnimationFrame() method.
2640 * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
2641 * @private
2642 */
2643
2644
2645 var requestAnimationFrame = function (fp) {
2646 return raf(fp);
2647 };
2648 /**
2649 * A polyfill for the window.cancelAnimationFrame() method. It cancels an animation executed through a call to the requestAnimationFrame() method.
2650 * @param {Number} key − The ID value returned through a call to the requestAnimationFrame() method. <ko>requestAnimationFrame() 메서드가 반환한 아이디 값</ko>
2651 * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/cancelAnimationFrame
2652 * @private
2653 */
2654
2655 var cancelAnimationFrame = function (key) {
2656 caf(key);
2657 };
2658 var map = function (obj, callback) {
2659 var tranformed = {};
2660
2661 for (var k in obj) {
2662 if (k) {
2663 tranformed[k] = callback(obj[k], k);
2664 }
2665 }
2666
2667 return tranformed;
2668 };
2669 var filter = function (obj, callback) {
2670 var filtered = {};
2671
2672 for (var k in obj) {
2673 if (k && callback(obj[k], k)) {
2674 filtered[k] = obj[k];
2675 }
2676 }
2677
2678 return filtered;
2679 };
2680 var every = function (obj, callback) {
2681 for (var k in obj) {
2682 if (k && !callback(obj[k], k)) {
2683 return false;
2684 }
2685 }
2686
2687 return true;
2688 };
2689 var equal = function (target, base) {
2690 return every(target, function (v, k) {
2691 return v === base[k];
2692 });
2693 };
2694 var roundNumFunc = {};
2695 var roundNumber = function (num, roundUnit) {
2696 // Cache for performance
2697 if (!roundNumFunc[roundUnit]) {
2698 roundNumFunc[roundUnit] = getRoundFunc(roundUnit);
2699 }
2700
2701 return roundNumFunc[roundUnit](num);
2702 };
2703 var roundNumbers = function (num, roundUnit) {
2704 if (!num || !roundUnit) {
2705 return num;
2706 }
2707
2708 return map(num, function (value, key) {
2709 return roundNumber(value, typeof roundUnit === "number" ? roundUnit : roundUnit[key]);
2710 });
2711 };
2712 var getDecimalPlace = function (val) {
2713 if (!isFinite(val)) {
2714 return 0;
2715 }
2716
2717 var v = "".concat(val);
2718
2719 if (v.indexOf("e") >= 0) {
2720 // Exponential Format
2721 // 1e-10, 1e-12
2722 var p = 0;
2723 var e = 1;
2724
2725 while (Math.round(val * e) / e !== val) {
2726 e *= 10;
2727 p++;
2728 }
2729
2730 return p;
2731 } // In general, following has performance benefit.
2732 // https://jsperf.com/precision-calculation
2733
2734
2735 return v.indexOf(".") >= 0 ? v.length - v.indexOf(".") - 1 : 0;
2736 };
2737 var inversePow = function (n) {
2738 // replace Math.pow(10, -n) to solve floating point issue.
2739 // eg. Math.pow(10, -4) => 0.00009999999999999999
2740 return 1 / Math.pow(10, n);
2741 };
2742 var getRoundFunc = function (v) {
2743 var p = v < 1 ? Math.pow(10, getDecimalPlace(v)) : 1;
2744 return function (n) {
2745 if (v === 0) {
2746 return 0;
2747 }
2748
2749 return Math.round(Math.round(n / v) * v * p) / p;
2750 };
2751 };
2752 var getAngle = function (posX, posY) {
2753 return Math.atan2(posY, posX) * 180 / Math.PI;
2754 };
2755 var isCssPropsFromAxes = function (originalCssProps) {
2756 var same = true;
2757 Object.keys(PREVENT_DRAG_CSSPROPS).forEach(function (prop) {
2758 if (!originalCssProps || originalCssProps[prop] !== PREVENT_DRAG_CSSPROPS[prop]) {
2759 same = false;
2760 }
2761 });
2762 return same;
2763 };
2764 var getDirection = function (useHorizontal, useVertical) {
2765 if (useHorizontal && useVertical) {
2766 return DIRECTION_ALL;
2767 } else if (useHorizontal) {
2768 return DIRECTION_HORIZONTAL;
2769 } else if (useVertical) {
2770 return DIRECTION_VERTICAL;
2771 } else {
2772 return DIRECTION_NONE;
2773 }
2774 };
2775 var useDirection = function (checkType, direction, userDirection) {
2776 if (userDirection) {
2777 return !!(direction === DIRECTION_ALL || direction & checkType && userDirection & checkType);
2778 } else {
2779 return !!(direction & checkType);
2780 }
2781 };
2782 var setCssProps = function (element, option, direction) {
2783 var _a;
2784
2785 var touchActionMap = (_a = {}, _a[DIRECTION_NONE] = "auto", _a[DIRECTION_ALL] = "none", _a[DIRECTION_VERTICAL] = "pan-x", _a[DIRECTION_HORIZONTAL] = "pan-y", _a);
2786 var oldCssProps = {};
2787
2788 if (element && element.style) {
2789 var touchAction = option.touchAction ? option.touchAction : touchActionMap[direction];
2790
2791 var newCssProps_1 = __assign$1(__assign$1({}, PREVENT_DRAG_CSSPROPS), {
2792 "touch-action": element.style["touch-action"] === "none" ? "none" : touchAction
2793 });
2794
2795 Object.keys(newCssProps_1).forEach(function (prop) {
2796 oldCssProps[prop] = element.style[prop];
2797 element.style[prop] = newCssProps_1[prop];
2798 });
2799 }
2800
2801 return oldCssProps;
2802 };
2803 var revertCssProps = function (element, originalCssProps) {
2804 if (element && element.style && originalCssProps) {
2805 Object.keys(originalCssProps).forEach(function (prop) {
2806 element.style[prop] = originalCssProps[prop];
2807 });
2808 }
2809
2810 return;
2811 };
2812
2813 var EventManager =
2814 /*#__PURE__*/
2815 function () {
2816 function EventManager(_axes) {
2817 this._axes = _axes;
2818 }
2819 /**
2820 * This event is fired when a user holds an element on the screen of the device.
2821 * @ko 사용자가 기기의 화면에 손을 대고 있을 때 발생하는 이벤트
2822 * @event Axes#hold
2823 * @type {object}
2824 * @property {Object.<string, number>} pos coordinate <ko>좌표 정보</ko>
2825 * @property {Object} input The instance of inputType where the event occurred<ko>이벤트가 발생한 inputType 인스턴스</ko>
2826 * @property {Object} inputEvent The event object received from inputType <ko>inputType으로 부터 받은 이벤트 객체</ko>
2827 * @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>
2828 *
2829 * @example
2830 * ```js
2831 * const axes = new eg.Axes({
2832 * "x": {
2833 * range: [0, 100]
2834 * },
2835 * "zoom": {
2836 * range: [50, 30]
2837 * }
2838 * }).on("hold", function(event) {
2839 * // event.pos
2840 * // event.input
2841 * // event.inputEvent
2842 * // isTrusted
2843 * });
2844 * ```
2845 */
2846
2847
2848 var __proto = EventManager.prototype;
2849
2850 __proto.hold = function (pos, option) {
2851 var roundPos = this._getRoundPos(pos).roundPos;
2852
2853 this._axes.trigger(new ComponentEvent$1("hold", {
2854 pos: roundPos,
2855 input: option.input || null,
2856 inputEvent: option.event || null,
2857 isTrusted: true
2858 }));
2859 };
2860 /**
2861 * Specifies the coordinates to move after the 'change' event. It works when the holding value of the change event is true.
2862 * @ko 'change' 이벤트 이후 이동할 좌표를 지정한다. change이벤트의 holding 값이 true일 경우에 동작한다
2863 * @param {Object.<string, number>} pos The coordinate to move to <ko>이동할 좌표</ko>
2864 * @example
2865 * ```js
2866 * const axes = new eg.Axes({
2867 * "x": {
2868 * range: [0, 100]
2869 * },
2870 * "zoom": {
2871 * range: [50, 30]
2872 * }
2873 * }).on("change", function(event) {
2874 * event.holding && event.set({x: 10});
2875 * });
2876 * ```
2877 */
2878
2879 /** Specifies the animation coordinates to move after the 'release' or 'animationStart' events.
2880 * @ko 'release' 또는 'animationStart' 이벤트 이후 이동할 좌표를 지정한다.
2881 * @param {Object.<string, number>} pos The coordinate to move to <ko>이동할 좌표</ko>
2882 * @param {Number} [duration=0] Duration of the animation (unit: ms) <ko>애니메이션 진행 시간(단위: ms)</ko>
2883 * @example
2884 * ```js
2885 * const axes = new eg.Axes({
2886 * "x": {
2887 * range: [0, 100]
2888 * },
2889 * "zoom": {
2890 * range: [50, 30]
2891 * }
2892 * }).on("animationStart", function(event) {
2893 * event.setTo({x: 10}, 2000);
2894 * });
2895 * ```
2896 */
2897
2898 /**
2899 * This event is fired when a user release an element on the screen of the device.
2900 * @ko 사용자가 기기의 화면에서 손을 뗐을 때 발생하는 이벤트
2901 * @event Axes#release
2902 * @type {object}
2903 * @property {Object.<string, number>} depaPos The coordinates when releasing an element<ko>손을 뗐을 때의 좌표 </ko>
2904 * @property {Object.<string, number>} destPos The coordinates to move to after releasing an element<ko>손을 뗀 뒤에 이동할 좌표</ko>
2905 * @property {Object.<string, number>} delta The movement variation of coordinate <ko>좌표의 변화량</ko>
2906 * @property {Object.<string, number>} bounceRatio If the coordinates at the time of release are in the bounce area, the current bounce value divided by the maximum bounce value <ko>손을 뗐을 때의 좌표가 bounce 영역에 있는 경우 현재 bounce된 값을 최대 bounce 값으로 나눈 수치.</ko>
2907 * @property {Object} inputEvent The event object received from inputType <ko>inputType으로 부터 받은 이벤트 객체</ko>
2908 * @property {Object} input The instance of inputType where the event occurred<ko>이벤트가 발생한 inputType 인스턴스</ko>
2909 * @property {setTo} setTo Specifies the animation coordinates to move after the event <ko>이벤트 이후 이동할 애니메이션 좌표를 지정한다</ko>
2910 * @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>
2911 *
2912 * @example
2913 * ```js
2914 * const axes = new eg.Axes({
2915 * "x": {
2916 * range: [0, 100]
2917 * },
2918 * "zoom": {
2919 * range: [50, 30]
2920 * }
2921 * }).on("release", function(event) {
2922 * // event.depaPos
2923 * // event.destPos
2924 * // event.delta
2925 * // event.input
2926 * // event.inputEvent
2927 * // event.setTo
2928 * // event.isTrusted
2929 *
2930 * // if you want to change the animation coordinates to move after the 'release' event.
2931 * event.setTo({x: 10}, 2000);
2932 * });
2933 * ```
2934 */
2935
2936
2937 __proto.triggerRelease = function (param) {
2938 var _a = this._getRoundPos(param.destPos, param.depaPos),
2939 roundPos = _a.roundPos,
2940 roundDepa = _a.roundDepa;
2941
2942 param.destPos = roundPos;
2943 param.depaPos = roundDepa;
2944 param.setTo = this._createUserControll(param.destPos, param.duration);
2945
2946 this._axes.trigger(new ComponentEvent$1("release", __assign$1(__assign$1({}, param), {
2947 bounceRatio: this._getBounceRatio(roundPos)
2948 })));
2949 };
2950 /**
2951 * This event is fired when coordinate changes.
2952 * @ko 좌표가 변경됐을 때 발생하는 이벤트
2953 * @event Axes#change
2954 * @type {object}
2955 * @property {Object.<string, number>} pos The coordinate <ko>좌표</ko>
2956 * @property {Object.<string, number>} delta The movement variation of coordinate <ko>좌표의 변화량</ko>
2957 * @property {Object.<string, number>} bounceRatio If the current coordinates are in the bounce area, the current bounce value divided by the maximum bounce value <ko>현재 좌표가 bounce 영역에 있는 경우 현재 bounce된 값을 최대 bounce 값으로 나눈 수치.</ko>
2958 * @property {Boolean} holding Indicates whether a user holds an element on the screen of the device.<ko>사용자가 기기의 화면을 누르고 있는지 여부</ko>
2959 * @property {Object} input The instance of inputType where the event occurred. If the value is changed by animation, it returns 'null'.<ko>이벤트가 발생한 inputType 인스턴스. 애니메이션에 의해 값이 변경될 경우에는 'null'을 반환한다.</ko>
2960 * @property {Object} inputEvent The event object received from inputType. If the value is changed by animation, it returns 'null'.<ko>inputType으로 부터 받은 이벤트 객체. 애니메이션에 의해 값이 변경될 경우에는 'null'을 반환한다.</ko>
2961 * @property {set} set Specifies the coordinates to move after the event. It works when the holding value is true <ko>이벤트 이후 이동할 좌표를 지정한다. holding 값이 true일 경우에 동작한다.</ko>
2962 * @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>
2963 *
2964 * @example
2965 * ```js
2966 * const axes = new eg.Axes({
2967 * "x": {
2968 * range: [0, 100]
2969 * },
2970 * "zoom": {
2971 * range: [50, 30]
2972 * }
2973 * }).on("change", function(event) {
2974 * // event.pos
2975 * // event.delta
2976 * // event.input
2977 * // event.inputEvent
2978 * // event.holding
2979 * // event.set
2980 * // event.isTrusted
2981 *
2982 * // if you want to change the coordinates to move after the 'change' event.
2983 * // it works when the holding value of the change event is true.
2984 * event.holding && event.set({x: 10});
2985 * });
2986 * ```
2987 */
2988
2989
2990 __proto.triggerChange = function (pos, depaPos, option, holding) {
2991 var _this = this;
2992
2993 if (holding === void 0) {
2994 holding = false;
2995 }
2996
2997 var animationManager = this.animationManager;
2998 var axisManager = animationManager.axisManager;
2999 var eventInfo = animationManager.getEventInfo();
3000
3001 var _a = this._getRoundPos(pos, depaPos),
3002 roundPos = _a.roundPos,
3003 roundDepa = _a.roundDepa;
3004
3005 var moveTo = axisManager.moveTo(roundPos, roundDepa);
3006 var inputEvent = (option === null || option === void 0 ? void 0 : option.event) || (eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.event) || null;
3007 var param = {
3008 pos: moveTo.pos,
3009 delta: moveTo.delta,
3010 bounceRatio: this._getBounceRatio(moveTo.pos),
3011 holding: holding,
3012 inputEvent: inputEvent,
3013 isTrusted: !!inputEvent,
3014 input: (option === null || option === void 0 ? void 0 : option.input) || (eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.input) || null,
3015 set: inputEvent ? this._createUserControll(moveTo.pos) : function () {} // eslint-disable-line @typescript-eslint/no-empty-function
3016
3017 };
3018 var event = new ComponentEvent$1("change", param);
3019
3020 this._axes.trigger(event);
3021
3022 Object.keys(moveTo.pos).forEach(function (axis) {
3023 var p = moveTo.pos[axis];
3024 getObserver(_this._axes, axis, p).current = p;
3025 });
3026
3027 if (inputEvent) {
3028 axisManager.set(param.set().destPos);
3029 }
3030
3031 return !event.isCanceled();
3032 };
3033 /**
3034 * This event is fired when animation starts.
3035 * @ko 에니메이션이 시작할 때 발생한다.
3036 * @event Axes#animationStart
3037 * @type {object}
3038 * @property {Object.<string, number>} depaPos The coordinates when animation starts<ko>애니메이션이 시작 되었을 때의 좌표 </ko>
3039 * @property {Object.<string, number>} destPos The coordinates to move to. If you change this value, you can run the animation<ko>이동할 좌표. 이값을 변경하여 애니메이션을 동작시킬수 있다</ko>
3040 * @property {Object.<string, number>} delta The movement variation of coordinate <ko>좌표의 변화량</ko>
3041 * @property {Number} duration Duration of the animation (unit: ms). If you change this value, you can control the animation duration time.<ko>애니메이션 진행 시간(단위: ms). 이값을 변경하여 애니메이션의 이동시간을 조절할 수 있다.</ko>
3042 * @property {Object} input The instance of inputType where the event occurred. If the value is changed by animation, it returns 'null'.<ko>이벤트가 발생한 inputType 인스턴스. 애니메이션에 의해 값이 변경될 경우에는 'null'을 반환한다.</ko>
3043 * @property {Object} inputEvent The event object received from inputType <ko>inputType으로 부터 받은 이벤트 객체</ko>
3044 * @property {setTo} setTo Specifies the animation coordinates to move after the event <ko>이벤트 이후 이동할 애니메이션 좌표를 지정한다</ko>
3045 * @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>
3046 *
3047 * @example
3048 * ```js
3049 * const axes = new eg.Axes({
3050 * "x": {
3051 * range: [0, 100]
3052 * },
3053 * "zoom": {
3054 * range: [50, 30]
3055 * }
3056 * }).on("release", function(event) {
3057 * // event.depaPos
3058 * // event.destPos
3059 * // event.delta
3060 * // event.input
3061 * // event.inputEvent
3062 * // event.setTo
3063 * // event.isTrusted
3064 *
3065 * // if you want to change the animation coordinates to move after the 'animationStart' event.
3066 * event.setTo({x: 10}, 2000);
3067 * });
3068 * ```
3069 */
3070
3071
3072 __proto.triggerAnimationStart = function (param) {
3073 var _a = this._getRoundPos(param.destPos, param.depaPos),
3074 roundPos = _a.roundPos,
3075 roundDepa = _a.roundDepa;
3076
3077 param.destPos = roundPos;
3078 param.depaPos = roundDepa;
3079 param.setTo = this._createUserControll(param.destPos, param.duration);
3080 var event = new ComponentEvent$1("animationStart", param);
3081
3082 this._axes.trigger(event);
3083
3084 return !event.isCanceled();
3085 };
3086 /**
3087 * This event is fired when animation ends.
3088 * @ko 에니메이션이 끝났을 때 발생한다.
3089 * @event Axes#animationEnd
3090 * @type {object}
3091 * @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>
3092 *
3093 * @example
3094 * ```js
3095 * const axes = new eg.Axes({
3096 * "x": {
3097 * range: [0, 100]
3098 * },
3099 * "zoom": {
3100 * range: [50, 30]
3101 * }
3102 * }).on("animationEnd", function(event) {
3103 * // event.isTrusted
3104 * });
3105 * ```
3106 */
3107
3108
3109 __proto.triggerAnimationEnd = function (isTrusted) {
3110 if (isTrusted === void 0) {
3111 isTrusted = false;
3112 }
3113
3114 this._axes.trigger(new ComponentEvent$1("animationEnd", {
3115 isTrusted: isTrusted
3116 }));
3117 };
3118 /**
3119 * This event is fired when all actions have been completed.
3120 * @ko 에니메이션이 끝났을 때 발생한다.
3121 * @event Axes#finish
3122 * @type {object}
3123 * @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko>
3124 *
3125 * @example
3126 * ```js
3127 * const axes = new eg.Axes({
3128 * "x": {
3129 * range: [0, 100]
3130 * },
3131 * "zoom": {
3132 * range: [50, 30]
3133 * }
3134 * }).on("finish", function(event) {
3135 * // event.isTrusted
3136 * });
3137 * ```
3138 */
3139
3140
3141 __proto.triggerFinish = function (isTrusted) {
3142 if (isTrusted === void 0) {
3143 isTrusted = false;
3144 }
3145
3146 this._axes.trigger(new ComponentEvent$1("finish", {
3147 isTrusted: isTrusted
3148 }));
3149 };
3150
3151 __proto.setAnimationManager = function (animationManager) {
3152 this.animationManager = animationManager;
3153 };
3154
3155 __proto.destroy = function () {
3156 this._axes.off();
3157 };
3158
3159 __proto._createUserControll = function (pos, duration) {
3160 if (duration === void 0) {
3161 duration = 0;
3162 } // to controll
3163
3164
3165 var userControl = {
3166 destPos: __assign$1({}, pos),
3167 duration: duration
3168 };
3169 return function (toPos, userDuration) {
3170 if (toPos) {
3171 userControl.destPos = __assign$1({}, toPos);
3172 }
3173
3174 if (userDuration !== undefined) {
3175 userControl.duration = userDuration;
3176 }
3177
3178 return userControl;
3179 };
3180 };
3181
3182 __proto._getRoundPos = function (pos, depaPos) {
3183 // round value if round exist
3184 var roundUnit = this._axes.options.round; // if (round == null) {
3185 // return {pos, depaPos}; // undefined, undefined
3186 // }
3187
3188 return {
3189 roundPos: roundNumbers(pos, roundUnit),
3190 roundDepa: roundNumbers(depaPos, roundUnit)
3191 };
3192 };
3193
3194 __proto._getBounceRatio = function (pos) {
3195 return this._axes.axisManager.map(pos, function (v, opt) {
3196 if (v < opt.range[0] && opt.bounce[0] !== 0) {
3197 return (opt.range[0] - v) / opt.bounce[0];
3198 } else if (v > opt.range[1] && opt.bounce[1] !== 0) {
3199 return (v - opt.range[1]) / opt.bounce[1];
3200 } else {
3201 return 0;
3202 }
3203 });
3204 };
3205
3206 return EventManager;
3207 }();
3208
3209 var InterruptManager =
3210 /*#__PURE__*/
3211 function () {
3212 function InterruptManager(_options) {
3213 this._options = _options;
3214 this._prevented = false; // check whether the animation event was prevented
3215 }
3216
3217 var __proto = InterruptManager.prototype;
3218
3219 __proto.isInterrupting = function () {
3220 // when interruptable is 'true', return value is always 'true'.
3221 return this._options.interruptable || this._prevented;
3222 };
3223
3224 __proto.isInterrupted = function () {
3225 return !this._options.interruptable && this._prevented;
3226 };
3227
3228 __proto.setInterrupt = function (prevented) {
3229 if (!this._options.interruptable) {
3230 this._prevented = prevented;
3231 }
3232 };
3233
3234 return InterruptManager;
3235 }();
3236
3237 /*
3238 * Copyright (c) 2015 NAVER Corp.
3239 * egjs projects are licensed under the MIT license
3240 */
3241 var getInsidePosition = function (destPos, range, circular, bounce) {
3242 var toDestPos = destPos;
3243 var targetRange = [circular[0] ? range[0] : bounce ? range[0] - bounce[0] : range[0], circular[1] ? range[1] : bounce ? range[1] + bounce[1] : range[1]];
3244 toDestPos = Math.max(targetRange[0], toDestPos);
3245 toDestPos = Math.min(targetRange[1], toDestPos);
3246 return toDestPos;
3247 }; // determine outside
3248
3249 var isOutside = function (pos, range) {
3250 return pos < range[0] || pos > range[1];
3251 }; // determine whether position has reached the maximum moveable area
3252
3253 var isEndofBounce = function (pos, range, bounce, circular) {
3254 return !circular[0] && pos === range[0] - bounce[0] || !circular[1] && pos === range[1] + bounce[1];
3255 };
3256 var getDuration = function (distance, deceleration) {
3257 var duration = Math.sqrt(distance / deceleration * 2); // when duration is under 100, then value is zero
3258
3259 return duration < 100 ? 0 : duration;
3260 };
3261 var isCircularable = function (destPos, range, circular) {
3262 return circular[1] && destPos > range[1] || circular[0] && destPos < range[0];
3263 };
3264 var getCirculatedPos = function (pos, range, circular) {
3265 var toPos = pos;
3266 var min = range[0];
3267 var max = range[1];
3268 var length = max - min;
3269
3270 if (circular[1] && pos > max) {
3271 // right
3272 toPos = (toPos - max) % length + min;
3273 }
3274
3275 if (circular[0] && pos < min) {
3276 // left
3277 toPos = (toPos - min) % length + max;
3278 }
3279
3280 return toPos;
3281 };
3282
3283 var AxisManager =
3284 /*#__PURE__*/
3285 function () {
3286 function AxisManager(_axis) {
3287 var _this = this;
3288
3289 this._axis = _axis;
3290
3291 this._complementOptions();
3292
3293 this._pos = Object.keys(this._axis).reduce(function (pos, v) {
3294 pos[v] = _this._axis[v].startPos;
3295 return pos;
3296 }, {});
3297 }
3298
3299 var __proto = AxisManager.prototype;
3300
3301 __proto.getDelta = function (depaPos, destPos) {
3302 var fullDepaPos = this.get(depaPos);
3303 return map(this.get(destPos), function (v, k) {
3304 return v - fullDepaPos[k];
3305 });
3306 };
3307
3308 __proto.get = function (axes) {
3309 var _this = this;
3310
3311 if (axes && Array.isArray(axes)) {
3312 return axes.reduce(function (acc, v) {
3313 if (v && v in _this._pos) {
3314 acc[v] = _this._pos[v];
3315 }
3316
3317 return acc;
3318 }, {});
3319 } else {
3320 return __assign$1(__assign$1({}, this._pos), axes || {});
3321 }
3322 };
3323
3324 __proto.moveTo = function (pos, depaPos) {
3325 if (depaPos === void 0) {
3326 depaPos = this._pos;
3327 }
3328
3329 var delta = map(this._pos, function (v, key) {
3330 return key in pos && key in depaPos ? pos[key] - depaPos[key] : 0;
3331 });
3332 this.set(this.map(pos, function (v, opt) {
3333 return opt ? getCirculatedPos(v, opt.range, opt.circular) : 0;
3334 }));
3335 return {
3336 pos: __assign$1({}, this._pos),
3337 delta: delta
3338 };
3339 };
3340
3341 __proto.set = function (pos) {
3342 for (var k in pos) {
3343 if (k && k in this._pos) {
3344 this._pos[k] = pos[k];
3345 }
3346 }
3347 };
3348
3349 __proto.every = function (pos, callback) {
3350 var axisOptions = this._axis;
3351 return every(pos, function (value, key) {
3352 return callback(value, axisOptions[key], key);
3353 });
3354 };
3355
3356 __proto.filter = function (pos, callback) {
3357 var axisOptions = this._axis;
3358 return filter(pos, function (value, key) {
3359 return callback(value, axisOptions[key], key);
3360 });
3361 };
3362
3363 __proto.map = function (pos, callback) {
3364 var axisOptions = this._axis;
3365 return map(pos, function (value, key) {
3366 return callback(value, axisOptions[key], key);
3367 });
3368 };
3369
3370 __proto.isOutside = function (axes) {
3371 return !this.every(axes ? this.get(axes) : this._pos, function (v, opt) {
3372 return !isOutside(v, opt.range);
3373 });
3374 };
3375
3376 __proto.getAxisOptions = function (key) {
3377 return this._axis[key];
3378 };
3379
3380 __proto.setAxis = function (axis) {
3381 var _this = this;
3382
3383 Object.keys(axis).forEach(function (key) {
3384 if (!_this._axis[key]) {
3385 throw new Error("Axis ".concat(key, " does not exist in Axes instance"));
3386 }
3387
3388 _this._axis[key] = __assign$1(__assign$1({}, _this._axis[key]), axis[key]);
3389 });
3390
3391 this._complementOptions();
3392 };
3393 /**
3394 * set up 'css' expression
3395 * @private
3396 */
3397
3398
3399 __proto._complementOptions = function () {
3400 var _this = this;
3401
3402 Object.keys(this._axis).forEach(function (axis) {
3403 _this._axis[axis] = __assign$1({
3404 range: [0, 100],
3405 startPos: _this._axis[axis].range[0],
3406 bounce: [0, 0],
3407 circular: [false, false]
3408 }, _this._axis[axis]);
3409 ["bounce", "circular"].forEach(function (v) {
3410 var axisOption = _this._axis;
3411 var key = axisOption[axis][v];
3412
3413 if (/string|number|boolean/.test(typeof key)) {
3414 axisOption[axis][v] = [key, key];
3415 }
3416 });
3417 });
3418 };
3419
3420 return AxisManager;
3421 }();
3422
3423 var SUPPORT_TOUCH = ("ontouchstart" in win);
3424 var SUPPORT_POINTER = ("PointerEvent" in win);
3425 var SUPPORT_MSPOINTER = ("MSPointerEvent" in win);
3426 var SUPPORT_POINTER_EVENTS = SUPPORT_POINTER || SUPPORT_MSPOINTER;
3427
3428 var EventInput =
3429 /*#__PURE__*/
3430 function () {
3431 function EventInput() {
3432 var _this = this;
3433
3434 this._stopContextMenu = function (event) {
3435 event.preventDefault();
3436 win.removeEventListener("contextmenu", _this._stopContextMenu);
3437 };
3438 }
3439
3440 var __proto = EventInput.prototype;
3441
3442 __proto.extendEvent = function (event) {
3443 var _a;
3444
3445 var prevEvent = this.prevEvent;
3446
3447 var center = this._getCenter(event);
3448
3449 var movement = prevEvent ? this._getMovement(event) : {
3450 x: 0,
3451 y: 0
3452 };
3453 var scale = prevEvent ? this._getScale(event) : 1;
3454 var angle = prevEvent ? getAngle(center.x - prevEvent.center.x, center.y - prevEvent.center.y) : 0;
3455 var deltaX = prevEvent ? prevEvent.deltaX + movement.x : movement.x;
3456 var deltaY = prevEvent ? prevEvent.deltaY + movement.y : movement.y;
3457 var offsetX = movement.x;
3458 var offsetY = movement.y;
3459 var latestInterval = this._latestInterval;
3460 var timeStamp = Date.now();
3461 var deltaTime = latestInterval ? timeStamp - latestInterval.timestamp : 0;
3462 var velocityX = prevEvent ? prevEvent.velocityX : 0;
3463 var velocityY = prevEvent ? prevEvent.velocityY : 0;
3464
3465 if (!latestInterval || deltaTime >= VELOCITY_INTERVAL) {
3466 if (latestInterval) {
3467 _a = [(deltaX - latestInterval.deltaX) / deltaTime, (deltaY - latestInterval.deltaY) / deltaTime], velocityX = _a[0], velocityY = _a[1];
3468 }
3469
3470 this._latestInterval = {
3471 timestamp: timeStamp,
3472 deltaX: deltaX,
3473 deltaY: deltaY
3474 };
3475 }
3476
3477 return {
3478 srcEvent: event,
3479 scale: scale,
3480 angle: angle,
3481 center: center,
3482 deltaX: deltaX,
3483 deltaY: deltaY,
3484 offsetX: offsetX,
3485 offsetY: offsetY,
3486 velocityX: velocityX,
3487 velocityY: velocityY,
3488 preventSystemEvent: true
3489 };
3490 };
3491
3492 __proto._getDistance = function (start, end) {
3493 var x = end.clientX - start.clientX;
3494 var y = end.clientY - start.clientY;
3495 return Math.sqrt(x * x + y * y);
3496 };
3497
3498 __proto._getButton = function (event) {
3499 var buttonCodeMap = {
3500 1: MOUSE_LEFT,
3501 2: MOUSE_RIGHT,
3502 4: MOUSE_MIDDLE
3503 };
3504 var button = this._isTouchEvent(event) ? MOUSE_LEFT : buttonCodeMap[event.buttons];
3505 return button ? button : null;
3506 };
3507
3508 __proto._isTouchEvent = function (event) {
3509 return event.type.indexOf("touch") > -1;
3510 };
3511
3512 __proto._isValidButton = function (button, inputButton) {
3513 return inputButton.indexOf(button) > -1;
3514 };
3515
3516 __proto._preventMouseButton = function (event, button) {
3517 if (button === MOUSE_RIGHT) {
3518 win.addEventListener("contextmenu", this._stopContextMenu);
3519 } else if (button === MOUSE_MIDDLE) {
3520 event.preventDefault();
3521 }
3522 };
3523
3524 return EventInput;
3525 }();
3526
3527 var MouseEventInput =
3528 /*#__PURE__*/
3529 function (_super) {
3530 __extends$1(MouseEventInput, _super);
3531
3532 function MouseEventInput() {
3533 var _this = _super !== null && _super.apply(this, arguments) || this;
3534
3535 _this.start = ["mousedown"];
3536 _this.move = ["mousemove"];
3537 _this.end = ["mouseup"];
3538 return _this;
3539 }
3540
3541 var __proto = MouseEventInput.prototype;
3542
3543 __proto.onEventStart = function (event, inputButton) {
3544 var button = this._getButton(event);
3545
3546 if (inputButton && !this._isValidButton(button, inputButton)) {
3547 return null;
3548 }
3549
3550 this._preventMouseButton(event, button);
3551
3552 return this.extendEvent(event);
3553 };
3554
3555 __proto.onEventMove = function (event, inputButton) {
3556 if (inputButton && !this._isValidButton(this._getButton(event), inputButton)) {
3557 return null;
3558 }
3559
3560 return this.extendEvent(event);
3561 };
3562
3563 __proto.onEventEnd = function () {
3564 return;
3565 };
3566
3567 __proto.onRelease = function () {
3568 this.prevEvent = null;
3569 return;
3570 };
3571
3572 __proto.getTouches = function (event, inputButton) {
3573 if (inputButton) {
3574 var buttonCodeMap = {
3575 1: MOUSE_LEFT,
3576 2: MOUSE_MIDDLE,
3577 3: MOUSE_RIGHT
3578 };
3579 return this._isValidButton(buttonCodeMap[event.which], inputButton) && this.end.indexOf(event.type) === -1 ? 1 : 0;
3580 }
3581
3582 return 0;
3583 };
3584
3585 __proto._getScale = function () {
3586 return 1;
3587 };
3588
3589 __proto._getCenter = function (event) {
3590 return {
3591 x: event.clientX,
3592 y: event.clientY
3593 };
3594 };
3595
3596 __proto._getMovement = function (event) {
3597 var prev = this.prevEvent.srcEvent;
3598 return {
3599 x: event.clientX - prev.clientX,
3600 y: event.clientY - prev.clientY
3601 };
3602 };
3603
3604 return MouseEventInput;
3605 }(EventInput);
3606
3607 var TouchEventInput =
3608 /*#__PURE__*/
3609 function (_super) {
3610 __extends$1(TouchEventInput, _super);
3611
3612 function TouchEventInput() {
3613 var _this = _super !== null && _super.apply(this, arguments) || this;
3614
3615 _this.start = ["touchstart"];
3616 _this.move = ["touchmove"];
3617 _this.end = ["touchend", "touchcancel"];
3618 return _this;
3619 }
3620
3621 var __proto = TouchEventInput.prototype;
3622
3623 __proto.onEventStart = function (event) {
3624 this._baseTouches = event.touches;
3625 return this.extendEvent(event);
3626 };
3627
3628 __proto.onEventMove = function (event) {
3629 return this.extendEvent(event);
3630 };
3631
3632 __proto.onEventEnd = function (event) {
3633 this._baseTouches = event.touches;
3634 return;
3635 };
3636
3637 __proto.onRelease = function () {
3638 this.prevEvent = null;
3639 this._baseTouches = null;
3640 return;
3641 };
3642
3643 __proto.getTouches = function (event) {
3644 return event.touches.length;
3645 };
3646
3647 __proto._getScale = function (event) {
3648 if (event.touches.length !== 2 || this._baseTouches.length < 2) {
3649 return null; // TODO: consider calculating non-pinch gesture scale
3650 }
3651
3652 return this._getDistance(event.touches[0], event.touches[1]) / this._getDistance(this._baseTouches[0], this._baseTouches[1]);
3653 };
3654
3655 __proto._getCenter = function (event) {
3656 return {
3657 x: event.touches[0].clientX,
3658 y: event.touches[0].clientY
3659 };
3660 };
3661
3662 __proto._getMovement = function (event) {
3663 var prev = this.prevEvent.srcEvent;
3664
3665 if (event.touches[0].identifier !== prev.touches[0].identifier) {
3666 return {
3667 x: 0,
3668 y: 0
3669 };
3670 }
3671
3672 return {
3673 x: event.touches[0].clientX - prev.touches[0].clientX,
3674 y: event.touches[0].clientY - prev.touches[0].clientY
3675 };
3676 };
3677
3678 return TouchEventInput;
3679 }(EventInput);
3680
3681 var PointerEventInput =
3682 /*#__PURE__*/
3683 function (_super) {
3684 __extends$1(PointerEventInput, _super);
3685
3686 function PointerEventInput() {
3687 var _this = _super !== null && _super.apply(this, arguments) || this;
3688
3689 _this.start = SUPPORT_POINTER ? ["pointerdown"] : ["MSPointerDown"];
3690 _this.move = SUPPORT_POINTER ? ["pointermove"] : ["MSPointerMove"];
3691 _this.end = SUPPORT_POINTER ? ["pointerup", "pointercancel"] : ["MSPointerUp", "MSPointerCancel"]; // store first, recent inputs for each event id
3692
3693 _this._firstInputs = [];
3694 _this._recentInputs = [];
3695 return _this;
3696 }
3697
3698 var __proto = PointerEventInput.prototype;
3699
3700 __proto.onEventStart = function (event, inputButton) {
3701 var button = this._getButton(event);
3702
3703 if (inputButton && !this._isValidButton(button, inputButton)) {
3704 return null;
3705 }
3706
3707 this._preventMouseButton(event, button);
3708
3709 this._updatePointerEvent(event);
3710
3711 return this.extendEvent(event);
3712 };
3713
3714 __proto.onEventMove = function (event, inputButton) {
3715 if (inputButton && !this._isValidButton(this._getButton(event), inputButton)) {
3716 return null;
3717 }
3718
3719 this._updatePointerEvent(event);
3720
3721 return this.extendEvent(event);
3722 };
3723
3724 __proto.onEventEnd = function (event) {
3725 this._removePointerEvent(event);
3726 };
3727
3728 __proto.onRelease = function () {
3729 this.prevEvent = null;
3730 this._firstInputs = [];
3731 this._recentInputs = [];
3732 return;
3733 };
3734
3735 __proto.getTouches = function () {
3736 return this._recentInputs.length;
3737 };
3738
3739 __proto._getScale = function () {
3740 if (this._recentInputs.length !== 2) {
3741 return null; // TODO: consider calculating non-pinch gesture scale
3742 }
3743
3744 return this._getDistance(this._recentInputs[0], this._recentInputs[1]) / this._getDistance(this._firstInputs[0], this._firstInputs[1]);
3745 };
3746
3747 __proto._getCenter = function (event) {
3748 return {
3749 x: event.clientX,
3750 y: event.clientY
3751 };
3752 };
3753
3754 __proto._getMovement = function (event) {
3755 var prev = this.prevEvent.srcEvent;
3756
3757 if (event.pointerId !== prev.pointerId) {
3758 return {
3759 x: 0,
3760 y: 0
3761 };
3762 }
3763
3764 return {
3765 x: event.clientX - prev.clientX,
3766 y: event.clientY - prev.clientY
3767 };
3768 };
3769
3770 __proto._updatePointerEvent = function (event) {
3771 var _this = this;
3772
3773 var addFlag = false;
3774
3775 this._recentInputs.forEach(function (e, i) {
3776 if (e.pointerId === event.pointerId) {
3777 addFlag = true;
3778 _this._recentInputs[i] = event;
3779 }
3780 });
3781
3782 if (!addFlag) {
3783 this._firstInputs.push(event);
3784
3785 this._recentInputs.push(event);
3786 }
3787 };
3788
3789 __proto._removePointerEvent = function (event) {
3790 this._firstInputs = this._firstInputs.filter(function (x) {
3791 return x.pointerId !== event.pointerId;
3792 });
3793 this._recentInputs = this._recentInputs.filter(function (x) {
3794 return x.pointerId !== event.pointerId;
3795 });
3796 };
3797
3798 return PointerEventInput;
3799 }(EventInput);
3800
3801 var TouchMouseEventInput =
3802 /*#__PURE__*/
3803 function (_super) {
3804 __extends$1(TouchMouseEventInput, _super);
3805
3806 function TouchMouseEventInput() {
3807 var _this = _super !== null && _super.apply(this, arguments) || this;
3808
3809 _this.start = ["mousedown", "touchstart"];
3810 _this.move = ["mousemove", "touchmove"];
3811 _this.end = ["mouseup", "touchend", "touchcancel"];
3812 return _this;
3813 }
3814
3815 var __proto = TouchMouseEventInput.prototype;
3816
3817 __proto.onEventStart = function (event, inputButton) {
3818 var button = this._getButton(event);
3819
3820 if (this._isTouchEvent(event)) {
3821 this._baseTouches = event.touches;
3822 }
3823
3824 if (inputButton && !this._isValidButton(button, inputButton)) {
3825 return null;
3826 }
3827
3828 this._preventMouseButton(event, button);
3829
3830 return this.extendEvent(event);
3831 };
3832
3833 __proto.onEventMove = function (event, inputButton) {
3834 if (inputButton && !this._isValidButton(this._getButton(event), inputButton)) {
3835 return null;
3836 }
3837
3838 return this.extendEvent(event);
3839 };
3840
3841 __proto.onEventEnd = function (event) {
3842 if (this._isTouchEvent(event)) {
3843 this._baseTouches = event.touches;
3844 }
3845
3846 return;
3847 };
3848
3849 __proto.onRelease = function () {
3850 this.prevEvent = null;
3851 this._baseTouches = null;
3852 return;
3853 };
3854
3855 __proto.getTouches = function (event) {
3856 return this._isTouchEvent(event) ? event.touches.length : 0;
3857 };
3858
3859 __proto._getScale = function (event) {
3860 if (this._isTouchEvent(event)) {
3861 if (event.touches.length !== 2 || this._baseTouches.length < 2) {
3862 return 1; // TODO: consider calculating non-pinch gesture scale
3863 }
3864
3865 return this._getDistance(event.touches[0], event.touches[1]) / this._getDistance(this._baseTouches[0], this._baseTouches[1]);
3866 }
3867
3868 return this.prevEvent.scale;
3869 };
3870
3871 __proto._getCenter = function (event) {
3872 if (this._isTouchEvent(event)) {
3873 return {
3874 x: event.touches[0].clientX,
3875 y: event.touches[0].clientY
3876 };
3877 }
3878
3879 return {
3880 x: event.clientX,
3881 y: event.clientY
3882 };
3883 };
3884
3885 __proto._getMovement = function (event) {
3886 var _this = this;
3887
3888 var prev = this.prevEvent.srcEvent;
3889
3890 var _a = [event, prev].map(function (e) {
3891 if (_this._isTouchEvent(e)) {
3892 return {
3893 id: e.touches[0].identifier,
3894 x: e.touches[0].clientX,
3895 y: e.touches[0].clientY
3896 };
3897 }
3898
3899 return {
3900 id: null,
3901 x: e.clientX,
3902 y: e.clientY
3903 };
3904 }),
3905 nextSpot = _a[0],
3906 prevSpot = _a[1];
3907
3908 return nextSpot.id === prevSpot.id ? {
3909 x: nextSpot.x - prevSpot.x,
3910 y: nextSpot.y - prevSpot.y
3911 } : {
3912 x: 0,
3913 y: 0
3914 };
3915 };
3916
3917 return TouchMouseEventInput;
3918 }(EventInput);
3919
3920 var toAxis = function (source, offset) {
3921 return offset.reduce(function (acc, v, i) {
3922 if (source[i]) {
3923 acc[source[i]] = v;
3924 }
3925
3926 return acc;
3927 }, {});
3928 };
3929 var convertInputType = function (inputType) {
3930 if (inputType === void 0) {
3931 inputType = [];
3932 }
3933
3934 var hasTouch = false;
3935 var hasMouse = false;
3936 var hasPointer = false;
3937 inputType.forEach(function (v) {
3938 switch (v) {
3939 case "mouse":
3940 hasMouse = true;
3941 break;
3942
3943 case "touch":
3944 hasTouch = SUPPORT_TOUCH;
3945 break;
3946
3947 case "pointer":
3948 hasPointer = SUPPORT_POINTER_EVENTS;
3949 // no default
3950 }
3951 });
3952
3953 if (hasPointer) {
3954 return new PointerEventInput();
3955 } else if (hasTouch && hasMouse) {
3956 return new TouchMouseEventInput();
3957 } else if (hasTouch) {
3958 return new TouchEventInput();
3959 } else if (hasMouse) {
3960 return new MouseEventInput();
3961 }
3962
3963 return null;
3964 };
3965
3966 var InputObserver =
3967 /*#__PURE__*/
3968 function () {
3969 function InputObserver(_a) {
3970 var options = _a.options,
3971 interruptManager = _a.interruptManager,
3972 eventManager = _a.eventManager,
3973 axisManager = _a.axisManager,
3974 animationManager = _a.animationManager;
3975 this._isOutside = false;
3976 this._moveDistance = null;
3977 this._isStopped = false;
3978 this.options = options;
3979 this._interruptManager = interruptManager;
3980 this._eventManager = eventManager;
3981 this._axisManager = axisManager;
3982 this._animationManager = animationManager;
3983 }
3984
3985 var __proto = InputObserver.prototype;
3986
3987 __proto.get = function (input) {
3988 return this._axisManager.get(input.axes);
3989 };
3990
3991 __proto.hold = function (input, event) {
3992 if (this._interruptManager.isInterrupted() || !input.axes.length) {
3993 return;
3994 }
3995
3996 var changeOption = {
3997 input: input,
3998 event: event
3999 };
4000 this._isStopped = false;
4001
4002 this._interruptManager.setInterrupt(true);
4003
4004 this._animationManager.stopAnimation(changeOption);
4005
4006 if (!this._moveDistance) {
4007 this._eventManager.hold(this._axisManager.get(), changeOption);
4008 }
4009
4010 this._isOutside = this._axisManager.isOutside(input.axes);
4011 this._moveDistance = this._axisManager.get(input.axes);
4012 };
4013
4014 __proto.change = function (input, event, offset, useAnimation) {
4015 if (this._isStopped || !this._interruptManager.isInterrupting() || this._axisManager.every(offset, function (v) {
4016 return v === 0;
4017 })) {
4018 return;
4019 }
4020
4021 var nativeEvent = event.srcEvent ? event.srcEvent : event;
4022
4023 if (nativeEvent.__childrenAxesAlreadyChanged) {
4024 return;
4025 }
4026
4027 var depaPos = this._moveDistance || this._axisManager.get(input.axes);
4028
4029 var destPos; // for outside logic
4030
4031 destPos = map(depaPos, function (v, k) {
4032 return v + (offset[k] || 0);
4033 });
4034
4035 if (this._moveDistance) {
4036 this._moveDistance = this._axisManager.map(destPos, function (v, _a) {
4037 var circular = _a.circular,
4038 range = _a.range;
4039 return circular && (circular[0] || circular[1]) ? getCirculatedPos(v, range, circular) : v;
4040 });
4041 } // from outside to inside
4042
4043
4044 if (this._isOutside && this._axisManager.every(depaPos, function (v, opt) {
4045 return !isOutside(v, opt.range);
4046 })) {
4047 this._isOutside = false;
4048 }
4049
4050 depaPos = this._atOutside(depaPos);
4051 destPos = this._atOutside(destPos);
4052
4053 if (!this.options.nested || !this._isEndofAxis(offset, depaPos, destPos)) {
4054 nativeEvent.__childrenAxesAlreadyChanged = true;
4055 }
4056
4057 var changeOption = {
4058 input: input,
4059 event: event
4060 };
4061
4062 if (useAnimation) {
4063 var duration = this._animationManager.getDuration(destPos, depaPos);
4064
4065 this._animationManager.animateTo(destPos, duration, changeOption);
4066 } else {
4067 var isCanceled = !this._eventManager.triggerChange(destPos, depaPos, changeOption, true);
4068
4069 if (isCanceled) {
4070 this._isStopped = true;
4071 this._moveDistance = null;
4072
4073 this._animationManager.finish(false);
4074 }
4075 }
4076 };
4077
4078 __proto.release = function (input, event, velocity, inputDuration) {
4079 if (this._isStopped || !this._interruptManager.isInterrupting() || !this._moveDistance) {
4080 return;
4081 }
4082
4083 var nativeEvent = event.srcEvent ? event.srcEvent : event;
4084
4085 if (nativeEvent.__childrenAxesAlreadyReleased) {
4086 velocity = velocity.map(function () {
4087 return 0;
4088 });
4089 }
4090
4091 var pos = this._axisManager.get(input.axes);
4092
4093 var depaPos = this._axisManager.get();
4094
4095 var displacement = this._animationManager.getDisplacement(velocity);
4096
4097 var offset = toAxis(input.axes, displacement);
4098
4099 var destPos = this._axisManager.get(this._axisManager.map(offset, function (v, opt, k) {
4100 if (opt.circular && (opt.circular[0] || opt.circular[1])) {
4101 return pos[k] + v;
4102 } else {
4103 return getInsidePosition(pos[k] + v, opt.range, opt.circular, opt.bounce);
4104 }
4105 }));
4106
4107 nativeEvent.__childrenAxesAlreadyReleased = true;
4108
4109 var duration = this._animationManager.getDuration(destPos, pos, inputDuration);
4110
4111 if (duration === 0) {
4112 destPos = __assign$1({}, depaPos);
4113 } // prepare params
4114
4115
4116 var param = {
4117 depaPos: depaPos,
4118 destPos: destPos,
4119 duration: duration,
4120 delta: this._axisManager.getDelta(depaPos, destPos),
4121 inputEvent: event,
4122 input: input,
4123 isTrusted: true
4124 };
4125
4126 this._eventManager.triggerRelease(param);
4127
4128 this._moveDistance = null; // to contol
4129
4130 var userWish = this._animationManager.getUserControl(param);
4131
4132 var isEqual = equal(userWish.destPos, depaPos);
4133 var changeOption = {
4134 input: input,
4135 event: event
4136 };
4137
4138 if (isEqual || userWish.duration === 0) {
4139 if (!isEqual) {
4140 this._eventManager.triggerChange(userWish.destPos, depaPos, changeOption, true);
4141 }
4142
4143 this._interruptManager.setInterrupt(false);
4144
4145 if (this._axisManager.isOutside()) {
4146 this._animationManager.restore(changeOption);
4147 } else {
4148 this._eventManager.triggerFinish(true);
4149 }
4150 } else {
4151 this._animationManager.animateTo(userWish.destPos, userWish.duration, changeOption);
4152 }
4153 }; // when move pointer is held in outside
4154
4155
4156 __proto._atOutside = function (pos) {
4157 var _this = this;
4158
4159 if (this._isOutside) {
4160 return this._axisManager.map(pos, function (v, opt) {
4161 var tn = opt.range[0] - opt.bounce[0];
4162 var tx = opt.range[1] + opt.bounce[1];
4163 return v > tx ? tx : v < tn ? tn : v;
4164 });
4165 } else {
4166 return this._axisManager.map(pos, function (v, opt) {
4167 var min = opt.range[0];
4168 var max = opt.range[1];
4169 var out = opt.bounce;
4170 var circular = opt.circular;
4171
4172 if (circular && (circular[0] || circular[1])) {
4173 return v;
4174 } else if (v < min) {
4175 // left
4176 return min - _this._animationManager.interpolate(min - v, out[0]);
4177 } else if (v > max) {
4178 // right
4179 return max + _this._animationManager.interpolate(v - max, out[1]);
4180 }
4181
4182 return v;
4183 });
4184 }
4185 };
4186
4187 __proto._isEndofAxis = function (offset, depaPos, destPos) {
4188 return this._axisManager.every(depaPos, function (value, option, key) {
4189 return offset[key] === 0 || depaPos[key] === destPos[key] && isEndofBounce(value, option.range, option.bounce, option.circular);
4190 });
4191 };
4192
4193 return InputObserver;
4194 }();
4195
4196 var clamp = function (value, min, max) {
4197 return Math.max(Math.min(value, max), min);
4198 };
4199
4200 var AnimationManager =
4201 /*#__PURE__*/
4202 function () {
4203 function AnimationManager(_a) {
4204 var options = _a.options,
4205 interruptManager = _a.interruptManager,
4206 eventManager = _a.eventManager,
4207 axisManager = _a.axisManager;
4208 this._options = options;
4209 this.interruptManager = interruptManager;
4210 this.eventManager = eventManager;
4211 this.axisManager = axisManager;
4212 this.animationEnd = this.animationEnd.bind(this);
4213 }
4214
4215 var __proto = AnimationManager.prototype;
4216
4217 __proto.getDuration = function (depaPos, destPos, wishDuration) {
4218 var _this = this;
4219
4220 var duration;
4221
4222 if (typeof wishDuration !== "undefined") {
4223 duration = wishDuration;
4224 } else {
4225 var durations_1 = map(destPos, function (v, k) {
4226 return getDuration(Math.abs(v - depaPos[k]), _this._options.deceleration);
4227 });
4228 duration = Object.keys(durations_1).reduce(function (max, v) {
4229 return Math.max(max, durations_1[v]);
4230 }, -Infinity);
4231 }
4232
4233 return clamp(duration, this._options.minimumDuration, this._options.maximumDuration);
4234 };
4235
4236 __proto.getDisplacement = function (velocity) {
4237 var totalVelocity = Math.pow(velocity.reduce(function (total, v) {
4238 return total + v * v;
4239 }, 0), 1 / velocity.length);
4240 var duration = Math.abs(totalVelocity / -this._options.deceleration);
4241 return velocity.map(function (v) {
4242 return v / 2 * duration;
4243 });
4244 };
4245
4246 __proto.stopAnimation = function (option) {
4247 if (this._animateParam) {
4248 var orgPos_1 = this.axisManager.get();
4249 var pos = this.axisManager.map(orgPos_1, function (v, opt) {
4250 return getCirculatedPos(v, opt.range, opt.circular);
4251 });
4252
4253 if (!every(pos, function (v, k) {
4254 return orgPos_1[k] === v;
4255 })) {
4256 this.eventManager.triggerChange(pos, orgPos_1, option, !!option);
4257 }
4258
4259 this._animateParam = null;
4260
4261 if (this._raf) {
4262 cancelAnimationFrame(this._raf);
4263 }
4264
4265 this._raf = null;
4266 this.eventManager.triggerAnimationEnd(!!(option === null || option === void 0 ? void 0 : option.event));
4267 }
4268 };
4269
4270 __proto.getEventInfo = function () {
4271 if (this._animateParam && this._animateParam.input && this._animateParam.inputEvent) {
4272 return {
4273 input: this._animateParam.input,
4274 event: this._animateParam.inputEvent
4275 };
4276 } else {
4277 return null;
4278 }
4279 };
4280
4281 __proto.restore = function (option) {
4282 var pos = this.axisManager.get();
4283 var destPos = this.axisManager.map(pos, function (v, opt) {
4284 return Math.min(opt.range[1], Math.max(opt.range[0], v));
4285 });
4286 this.stopAnimation();
4287 this.animateTo(destPos, this.getDuration(pos, destPos), option);
4288 };
4289
4290 __proto.animationEnd = function () {
4291 var beforeParam = this.getEventInfo();
4292 this._animateParam = null; // for Circular
4293
4294 var circularTargets = this.axisManager.filter(this.axisManager.get(), function (v, opt) {
4295 return isCircularable(v, opt.range, opt.circular);
4296 });
4297
4298 if (Object.keys(circularTargets).length > 0) {
4299 this.setTo(this.axisManager.map(circularTargets, function (v, opt) {
4300 return getCirculatedPos(v, opt.range, opt.circular);
4301 }));
4302 }
4303
4304 this.interruptManager.setInterrupt(false);
4305 this.eventManager.triggerAnimationEnd(!!beforeParam);
4306
4307 if (this.axisManager.isOutside()) {
4308 this.restore(beforeParam);
4309 } else {
4310 this.finish(!!beforeParam);
4311 }
4312 };
4313
4314 __proto.finish = function (isTrusted) {
4315 this._animateParam = null;
4316 this.interruptManager.setInterrupt(false);
4317 this.eventManager.triggerFinish(isTrusted);
4318 };
4319
4320 __proto.getUserControl = function (param) {
4321 var userWish = param.setTo();
4322 userWish.destPos = this.axisManager.get(userWish.destPos);
4323 userWish.duration = clamp(userWish.duration, this._options.minimumDuration, this._options.maximumDuration);
4324 return userWish;
4325 };
4326
4327 __proto.animateTo = function (destPos, duration, option) {
4328 var _this = this;
4329
4330 this.stopAnimation();
4331
4332 var param = this._createAnimationParam(destPos, duration, option);
4333
4334 var depaPos = __assign$1({}, param.depaPos);
4335
4336 var retTrigger = this.eventManager.triggerAnimationStart(param); // to control
4337
4338 var userWish = this.getUserControl(param); // You can't stop the 'animationStart' event when 'circular' is true.
4339
4340 if (!retTrigger && this.axisManager.every(userWish.destPos, function (v, opt) {
4341 return isCircularable(v, opt.range, opt.circular);
4342 })) {
4343 console.warn("You can't stop the 'animation' event when 'circular' is true.");
4344 }
4345
4346 if (retTrigger && !equal(userWish.destPos, depaPos)) {
4347 var inputEvent = (option === null || option === void 0 ? void 0 : option.event) || null;
4348
4349 this._animateLoop({
4350 depaPos: depaPos,
4351 destPos: userWish.destPos,
4352 duration: userWish.duration,
4353 delta: this.axisManager.getDelta(depaPos, userWish.destPos),
4354 isTrusted: !!inputEvent,
4355 inputEvent: inputEvent,
4356 input: (option === null || option === void 0 ? void 0 : option.input) || null
4357 }, function () {
4358 return _this.animationEnd();
4359 });
4360 }
4361 };
4362
4363 __proto.setTo = function (pos, duration) {
4364 if (duration === void 0) {
4365 duration = 0;
4366 }
4367
4368 var axes = Object.keys(pos);
4369 var orgPos = this.axisManager.get(axes);
4370
4371 if (equal(pos, orgPos)) {
4372 return this;
4373 }
4374
4375 this.interruptManager.setInterrupt(true);
4376 var movedPos = filter(pos, function (v, k) {
4377 return orgPos[k] !== v;
4378 });
4379
4380 if (!Object.keys(movedPos).length) {
4381 return this;
4382 }
4383
4384 movedPos = this.axisManager.map(movedPos, function (v, opt) {
4385 var range = opt.range,
4386 circular = opt.circular;
4387
4388 if (circular && (circular[0] || circular[1])) {
4389 return v;
4390 } else {
4391 return getInsidePosition(v, range, circular);
4392 }
4393 });
4394
4395 if (equal(movedPos, orgPos)) {
4396 return this;
4397 }
4398
4399 if (duration > 0) {
4400 this.animateTo(movedPos, duration);
4401 } else {
4402 this.stopAnimation();
4403 this.eventManager.triggerChange(movedPos);
4404 this.finish(false);
4405 }
4406
4407 return this;
4408 };
4409
4410 __proto.setBy = function (pos, duration) {
4411 if (duration === void 0) {
4412 duration = 0;
4413 }
4414
4415 return this.setTo(map(this.axisManager.get(Object.keys(pos)), function (v, k) {
4416 return v + pos[k];
4417 }), duration);
4418 };
4419
4420 __proto._createAnimationParam = function (pos, duration, option) {
4421 var depaPos = this.axisManager.get();
4422 var destPos = pos;
4423 var inputEvent = (option === null || option === void 0 ? void 0 : option.event) || null;
4424 return {
4425 depaPos: depaPos,
4426 destPos: destPos,
4427 duration: clamp(duration, this._options.minimumDuration, this._options.maximumDuration),
4428 delta: this.axisManager.getDelta(depaPos, destPos),
4429 inputEvent: inputEvent,
4430 input: (option === null || option === void 0 ? void 0 : option.input) || null,
4431 isTrusted: !!inputEvent,
4432 done: this.animationEnd
4433 };
4434 };
4435
4436 __proto._animateLoop = function (param, complete) {
4437 var _this = this;
4438
4439 if (param.duration) {
4440 this._animateParam = __assign$1(__assign$1({}, param), {
4441 startTime: new Date().getTime()
4442 });
4443 var originalIntendedPos_1 = map(param.destPos, function (v) {
4444 return v;
4445 });
4446
4447 var state_1 = this._initState(this._animateParam);
4448
4449 var loop_1 = function () {
4450 _this._raf = null;
4451 var animateParam = _this._animateParam;
4452
4453 var nextState = _this._getNextState(state_1);
4454
4455 var isCanceled = !_this.eventManager.triggerChange(nextState.pos, state_1.pos);
4456 state_1 = nextState;
4457
4458 if (nextState.finished) {
4459 animateParam.destPos = _this._getFinalPos(animateParam.destPos, originalIntendedPos_1);
4460
4461 if (!equal(animateParam.destPos, _this.axisManager.get(Object.keys(animateParam.destPos)))) {
4462 _this.eventManager.triggerChange(animateParam.destPos, nextState.pos);
4463 }
4464
4465 complete();
4466 return;
4467 } else if (isCanceled) {
4468 _this.finish(false);
4469 } else {
4470 _this._raf = requestAnimationFrame(loop_1);
4471 }
4472 };
4473
4474 loop_1();
4475 } else {
4476 this.eventManager.triggerChange(param.destPos);
4477 complete();
4478 }
4479 };
4480 /**
4481 * Get estimated final value.
4482 *
4483 * If destPos is within the 'error range' of the original intended position, the initial intended position is returned.
4484 * - eg. original intended pos: 100, destPos: 100.0000000004 ==> return 100;
4485 * If dest Pos is outside the 'range of error' compared to the originally intended pos, it is returned rounded based on the originally intended pos.
4486 * - eg. original intended pos: 100.123 destPos: 50.12345 => return 50.123
4487 * @param originalIntendedPos
4488 * @param destPos
4489 */
4490
4491
4492 __proto._getFinalPos = function (destPos, originalIntendedPos) {
4493 var _this = this; // compare destPos and originalIntendedPos
4494 // eslint-disable-next-line @typescript-eslint/naming-convention
4495
4496
4497 var ERROR_LIMIT = 0.000001;
4498 var finalPos = map(destPos, function (value, key) {
4499 if (value >= originalIntendedPos[key] - ERROR_LIMIT && value <= originalIntendedPos[key] + ERROR_LIMIT) {
4500 // In error range, return original intended
4501 return originalIntendedPos[key];
4502 } else {
4503 // Out of error range, return rounded pos.
4504 var roundUnit = _this._getRoundUnit(value, key);
4505
4506 var result = roundNumber(value, roundUnit);
4507 return result;
4508 }
4509 });
4510 return finalPos;
4511 };
4512
4513 __proto._getRoundUnit = function (val, key) {
4514 var roundUnit = this._options.round; // manual mode
4515
4516 var minRoundUnit = null; // auto mode
4517 // auto mode
4518
4519 if (!roundUnit) {
4520 // Get minimum round unit
4521 var options = this.axisManager.getAxisOptions(key);
4522 minRoundUnit = inversePow(Math.max(getDecimalPlace(options.range[0]), getDecimalPlace(options.range[1]), getDecimalPlace(val)));
4523 }
4524
4525 return minRoundUnit || roundUnit;
4526 };
4527
4528 return AnimationManager;
4529 }();
4530
4531 var EasingManager =
4532 /*#__PURE__*/
4533 function (_super) {
4534 __extends$1(EasingManager, _super);
4535
4536 function EasingManager() {
4537 var _this = _super !== null && _super.apply(this, arguments) || this;
4538
4539 _this._useDuration = true;
4540 return _this;
4541 }
4542
4543 var __proto = EasingManager.prototype;
4544
4545 __proto.interpolate = function (displacement, threshold) {
4546 var initSlope = this._easing(0.00001) / 0.00001;
4547 return this._easing(displacement / (threshold * initSlope)) * threshold;
4548 };
4549
4550 __proto.updateAnimation = function (options) {
4551 var _a;
4552
4553 var animateParam = this._animateParam;
4554
4555 if (!animateParam) {
4556 return;
4557 }
4558
4559 var diffTime = new Date().getTime() - animateParam.startTime;
4560 var pos = (options === null || options === void 0 ? void 0 : options.destPos) || animateParam.destPos;
4561 var duration = (_a = options === null || options === void 0 ? void 0 : options.duration) !== null && _a !== void 0 ? _a : animateParam.duration;
4562
4563 if ((options === null || options === void 0 ? void 0 : options.restart) || duration <= diffTime) {
4564 this.setTo(pos, duration - diffTime);
4565 return;
4566 }
4567
4568 if (options === null || options === void 0 ? void 0 : options.destPos) {
4569 var currentPos = this.axisManager.get(); // When destination is changed, new delta should be calculated as remaining percent.
4570 // For example, moving x:0, y:0 to x:200, y:200 and it has current easing percent of 92%. coordinate is x:184 and y:184
4571 // If destination changes to x:300, y:300. xdelta:200, ydelta:200 changes to xdelta:116, ydelta:116 and use remaining easingPer as 100%, not 8% as previous.
4572 // Therefore, original easingPer by time is kept. And divided by (1 - self._initialEasingPer) which means new total easing percent. Like calculating 8% as 100%.
4573
4574 this._initialEasingPer = this._prevEasingPer;
4575 animateParam.delta = this.axisManager.getDelta(currentPos, pos);
4576 animateParam.destPos = pos;
4577 }
4578
4579 if (options === null || options === void 0 ? void 0 : options.duration) {
4580 var ratio = (diffTime + this._durationOffset) / animateParam.duration; // Use durationOffset for keeping animation ratio after duration is changed.
4581 // newRatio = (diffTime + newDurationOffset) / newDuration = oldRatio
4582 // newDurationOffset = oldRatio * newDuration - diffTime
4583
4584 this._durationOffset = ratio * duration - diffTime;
4585 animateParam.duration = duration;
4586 }
4587 };
4588
4589 __proto._initState = function (info) {
4590 this._initialEasingPer = 0;
4591 this._prevEasingPer = 0;
4592 this._durationOffset = 0;
4593 return {
4594 pos: info.depaPos,
4595 easingPer: 0,
4596 finished: false
4597 };
4598 };
4599
4600 __proto._getNextState = function (prevState) {
4601 var _this = this;
4602
4603 var animateParam = this._animateParam;
4604 var prevPos = prevState.pos;
4605 var destPos = animateParam.destPos;
4606 var directions = map(prevPos, function (value, key) {
4607 return value <= destPos[key] ? 1 : -1;
4608 });
4609 var diffTime = new Date().getTime() - animateParam.startTime;
4610 var ratio = (diffTime + this._durationOffset) / animateParam.duration;
4611
4612 var easingPer = this._easing(ratio);
4613
4614 var toPos = this.axisManager.map(prevPos, function (pos, options, key) {
4615 var nextPos = ratio >= 1 ? destPos[key] : pos + animateParam.delta[key] * (easingPer - _this._prevEasingPer) / (1 - _this._initialEasingPer); // Subtract distance from distance already moved.
4616 // Recalculate the remaining distance.
4617 // Fix the bouncing phenomenon by changing the range.
4618
4619 var circulatedPos = getCirculatedPos(nextPos, options.range, options.circular);
4620
4621 if (nextPos !== circulatedPos) {
4622 // circular
4623 var rangeOffset = directions[key] * (options.range[1] - options.range[0]);
4624 destPos[key] -= rangeOffset;
4625 prevPos[key] -= rangeOffset;
4626 }
4627
4628 return circulatedPos;
4629 });
4630 this._prevEasingPer = easingPer;
4631 return {
4632 pos: toPos,
4633 easingPer: easingPer,
4634 finished: easingPer >= 1
4635 };
4636 };
4637
4638 __proto._easing = function (p) {
4639 return p > 1 ? 1 : this._options.easing(p);
4640 };
4641
4642 return EasingManager;
4643 }(AnimationManager);
4644
4645 /**
4646 * @typedef {Object} AxisOption The Axis information. The key of the axis specifies the name to use as the logical virtual coordinate system.
4647 * @ko 축 정보. 축의 키는 논리적인 가상 좌표계로 사용할 이름을 지정한다.
4648 * @param {Number[]} [range] The range of coordinate <ko>좌표 범위</ko>
4649 * @param {Number} [range[0]=0] The coordinate of the minimum <ko>최소 좌표</ko>
4650 * @param {Number} [range[1]=0] The coordinate of the maximum <ko>최대 좌표</ko>
4651 * @param {Number} [startPos=range[0]] The coordinates to be moved when creating an instance <ko>인스턴스 생성시 이동할 좌표</ko>
4652 * @param {Number[]} [bounce] The size of bouncing area. The coordinates can exceed the coordinate area as much as the bouncing area based on user action. If the coordinates does not exceed the bouncing area when an element is dragged, the coordinates where bouncing effects are applied are retuned back into the coordinate area<ko>바운스 영역의 크기. 사용자의 동작에 따라 좌표가 좌표 영역을 넘어 바운스 영역의 크기만큼 더 이동할 수 있다. 사용자가 끌어다 놓는 동작을 했을 때 좌표가 바운스 영역에 있으면, 바운스 효과가 적용된 좌표가 다시 좌표 영역 안으로 들어온다</ko>
4653 * @param {Number} [bounce[0]=0] The size of coordinate of the minimum area <ko>최소 좌표 바운스 영역의 크기</ko>
4654 * @param {Number} [bounce[1]=0] The size of coordinate of the maximum area <ko>최대 좌표 바운스 영역의 크기</ko>
4655 * @param {Boolean[]} [circular] Indicates whether a circular element is available. If it is set to "true" and an element is dragged outside the coordinate area, the element will appear on the other side.<ko>순환 여부. 'true'로 설정한 방향의 좌표 영역 밖으로 엘리먼트가 이동하면 반대 방향에서 엘리먼트가 나타난다</ko>
4656 * @param {Boolean} [circular[0]=false] Indicates whether to circulate to the coordinate of the minimum <ko>최소 좌표 방향의 순환 여부</ko>
4657 * @param {Boolean} [circular[1]=false] Indicates whether to circulate to the coordinate of the maximum <ko>최대 좌표 방향의 순환 여부</ko>
4658 **/
4659
4660 /**
4661 * @typedef {Object} AxesOption The option object of the eg.Axes module
4662 * @ko eg.Axes 모듈의 옵션 객체
4663 * @param {Function} [easing=easing.easeOutCubic] The easing function to apply to an animation <ko>애니메이션에 적용할 easing 함수</ko>
4664 * @param {Number} [maximumDuration=Infinity] Maximum duration of the animation <ko>가속도에 의해 애니메이션이 동작할 때의 최대 좌표 이동 시간</ko>
4665 * @param {Number} [minimumDuration=0] Minimum duration of the animation <ko>가속도에 의해 애니메이션이 동작할 때의 최소 좌표 이동 시간</ko>
4666 * @param {Number} [deceleration=0.0006] Deceleration of the animation where acceleration is manually enabled by user. A higher value indicates shorter running time. <ko>사용자의 동작으로 가속도가 적용된 애니메이션의 감속도. 값이 높을수록 애니메이션 실행 시간이 짧아진다</ko>
4667 * @param {Boolean} [interruptable=true] Indicates whether an animation is interruptible.
4668 * - true: It can be paused or stopped by user action or the API.
4669 * - false: It cannot be paused or stopped by user action or the API while it is running.
4670 * <ko>진행 중인 애니메이션 중지 가능 여부.
4671 * - true: 사용자의 동작이나 API로 애니메이션을 중지할 수 있다.
4672 * - false: 애니메이션이 진행 중일 때는 사용자의 동작이나 API가 적용되지 않는다</ko>
4673 * @param {Number} [round=null] Rounding unit. For example, 0.1 rounds to 0.1 decimal point(6.1234 => 6.1), 5 rounds to 5 (93 => 95)
4674 * [Details](https://github.com/naver/egjs-axes/wiki/round-option)<ko>반올림 단위. 예를 들어 0.1 은 소숫점 0.1 까지 반올림(6.1234 => 6.1), 5 는 5 단위로 반올림(93 => 95).
4675 * [상세내용](https://github.com/naver/egjs-axes/wiki/round-option)</ko>
4676 * @param {Boolean} [nested=false] Whether the event propagates to other instances when the coordinates reach the end of the movable area <ko>좌표가 이동 가능한 영역의 끝까지 도달했을 때 다른 인스턴스들로의 이벤트 전파 여부</ko>
4677 **/
4678
4679 /**
4680 * A module used to change the information of user action entered by various input devices such as touch screen or mouse into the logical virtual coordinates. You can easily create a UI that responds to user actions.
4681 * @ko 터치 입력 장치나 마우스와 같은 다양한 입력 장치를 통해 전달 받은 사용자의 동작을 논리적인 가상 좌표로 변경하는 모듈이다. 사용자 동작에 반응하는 UI를 손쉽게 만들수 있다.
4682 * @extends eg.Component
4683 *
4684 * @param {Object.<string, AxisOption>} axis Axis information managed by eg.Axes. The key of the axis specifies the name to use as the logical virtual coordinate system. <ko>eg.Axes가 관리하는 축 정보. 축의 키는 논리적인 가상 좌표계로 사용할 이름을 지정한다.</ko>
4685 * @param {AxesOption} [options={}] The option object of the eg.Axes module<ko>eg.Axes 모듈의 옵션 객체</ko>
4686 * @param {Object.<string, number>} [startPos={}] The coordinates to be moved when creating an instance. It is applied with higher priority than startPos of axisOption.<ko>인스턴스 생성시 이동할 좌표, axisOption의 startPos보다 높은 우선순위로 적용된다.</ko>
4687 *
4688 * @support {"ie": "10+", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "2.3+ (except 3.x)"}
4689 * @example
4690 * ```js
4691 * // 1. Initialize eg.Axes
4692 * const axes = new eg.Axes({
4693 * something1: {
4694 * range: [0, 150],
4695 * bounce: 50
4696 * },
4697 * something2: {
4698 * range: [0, 200],
4699 * bounce: 100
4700 * },
4701 * somethingN: {
4702 * range: [1, 10],
4703 * }
4704 * }, {
4705 * deceleration : 0.0024
4706 * });
4707 *
4708 * // 2. attach event handler
4709 * axes.on({
4710 * "hold" : function(evt) {
4711 * },
4712 * "release" : function(evt) {
4713 * },
4714 * "animationStart" : function(evt) {
4715 * },
4716 * "animationEnd" : function(evt) {
4717 * },
4718 * "change" : function(evt) {
4719 * }
4720 * });
4721 *
4722 * // 3. Initialize inputTypes
4723 * const panInputArea = new eg.Axes.PanInput("#area", {
4724 * scale: [0.5, 1]
4725 * });
4726 * const panInputHmove = new eg.Axes.PanInput("#hmove");
4727 * const panInputVmove = new eg.Axes.PanInput("#vmove");
4728 * const pinchInputArea = new eg.Axes.PinchInput("#area", {
4729 * scale: 1.5
4730 * });
4731 *
4732 * // 4. Connect eg.Axes and InputTypes
4733 * // [PanInput] When the mouse or touchscreen is down and moved.
4734 * // Connect the 'something2' axis to the mouse or touchscreen x position and
4735 * // connect the 'somethingN' axis to the mouse or touchscreen y position.
4736 * axes.connect(["something2", "somethingN"], panInputArea); // or axes.connect("something2 somethingN", panInputArea);
4737 *
4738 * // Connect only one 'something1' axis to the mouse or touchscreen x position.
4739 * axes.connect(["something1"], panInputHmove); // or axes.connect("something1", panInputHmove);
4740 *
4741 * // Connect only one 'something2' axis to the mouse or touchscreen y position.
4742 * axes.connect(["", "something2"], panInputVmove); // or axes.connect(" something2", panInputVmove);
4743 *
4744 * // [PinchInput] Connect 'something2' axis when two pointers are moving toward (zoom-in) or away from each other (zoom-out).
4745 * axes.connect("something2", pinchInputArea);
4746 * ```
4747 */
4748
4749 var Axes =
4750 /*#__PURE__*/
4751 function (_super) {
4752 __extends$1(Axes, _super);
4753 /**
4754 *
4755 */
4756
4757
4758 function Axes(axis, options, startPos) {
4759 if (axis === void 0) {
4760 axis = {};
4761 }
4762
4763 if (options === void 0) {
4764 options = {};
4765 }
4766
4767 if (startPos === void 0) {
4768 startPos = {};
4769 }
4770
4771 var _this = _super.call(this) || this;
4772
4773 _this.axis = axis;
4774 _this._inputs = [];
4775 _this.options = __assign$1({
4776 easing: function (x) {
4777 return 1 - Math.pow(1 - x, 3);
4778 },
4779 interruptable: true,
4780 maximumDuration: Infinity,
4781 minimumDuration: 0,
4782 deceleration: 0.0006,
4783 round: null,
4784 nested: false
4785 }, options);
4786 Object.keys(startPos).forEach(function (key) {
4787 _this.axis[key].startPos = startPos[key];
4788 });
4789 _this.interruptManager = new InterruptManager(_this.options);
4790 _this.axisManager = new AxisManager(_this.axis);
4791 _this.eventManager = new EventManager(_this);
4792 _this.animationManager = new EasingManager(_this);
4793 _this.inputObserver = new InputObserver(_this);
4794
4795 _this.eventManager.setAnimationManager(_this.animationManager);
4796
4797 _this.eventManager.triggerChange(_this.axisManager.get());
4798
4799 return _this;
4800 }
4801 /**
4802 * Connect the axis of eg.Axes to the inputType.
4803 * @ko eg.Axes의 축과 inputType을 연결한다
4804 * @param {(String[]|String)} axes The name of the axis to associate with inputType <ko>inputType과 연결할 축의 이름</ko>
4805 * @param {Object} inputType The inputType instance to associate with the axis of eg.Axes <ko>eg.Axes의 축과 연결할 inputType 인스턴스</ko>
4806 * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
4807 * @example
4808 * ```js
4809 * const axes = new eg.Axes({
4810 * "x": {
4811 * range: [0, 100]
4812 * },
4813 * "xOther": {
4814 * range: [-100, 100]
4815 * }
4816 * });
4817 *
4818 * axes.connect("x", new eg.Axes.PanInput("#area1"))
4819 * .connect("x xOther", new eg.Axes.PanInput("#area2"))
4820 * .connect(" xOther", new eg.Axes.PanInput("#area3"))
4821 * .connect(["x"], new eg.Axes.PanInput("#area4"))
4822 * .connect(["xOther", "x"], new eg.Axes.PanInput("#area5"))
4823 * .connect(["", "xOther"], new eg.Axes.PanInput("#area6"));
4824 * ```
4825 */
4826
4827
4828 var __proto = Axes.prototype;
4829
4830 __proto.connect = function (axes, inputType) {
4831 var mapped;
4832
4833 if (typeof axes === "string") {
4834 mapped = axes.split(" ");
4835 } else {
4836 mapped = axes.concat();
4837 } // check same instance
4838
4839
4840 if (~this._inputs.indexOf(inputType)) {
4841 this.disconnect(inputType);
4842 }
4843
4844 inputType.mapAxes(mapped);
4845 inputType.connect(this.inputObserver);
4846
4847 this._inputs.push(inputType);
4848
4849 return this;
4850 };
4851 /**
4852 * Disconnect the axis of eg.Axes from the inputType.
4853 * @ko eg.Axes의 축과 inputType의 연결을 끊는다.
4854 * @param {Object} [inputType] An inputType instance associated with the axis of eg.Axes <ko>eg.Axes의 축과 연결한 inputType 인스턴스</ko>
4855 * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
4856 * @example
4857 * ```js
4858 * const axes = new eg.Axes({
4859 * "x": {
4860 * range: [0, 100]
4861 * },
4862 * "xOther": {
4863 * range: [-100, 100]
4864 * }
4865 * });
4866 *
4867 * const input1 = new eg.Axes.PanInput("#area1");
4868 * const input2 = new eg.Axes.PanInput("#area2");
4869 * const input3 = new eg.Axes.PanInput("#area3");
4870 *
4871 * axes.connect("x", input1);
4872 * .connect("x xOther", input2)
4873 * .connect(["xOther", "x"], input3);
4874 *
4875 * axes.disconnect(input1); // disconnects input1
4876 * axes.disconnect(); // disconnects all of them
4877 * ```
4878 */
4879
4880
4881 __proto.disconnect = function (inputType) {
4882 if (inputType) {
4883 var index = this._inputs.indexOf(inputType);
4884
4885 if (index >= 0) {
4886 this._inputs[index].disconnect();
4887
4888 this._inputs.splice(index, 1);
4889 }
4890 } else {
4891 this._inputs.forEach(function (v) {
4892 return v.disconnect();
4893 });
4894
4895 this._inputs = [];
4896 }
4897
4898 return this;
4899 };
4900 /**
4901 * Returns the current position of the coordinates.
4902 * @ko 좌표의 현재 위치를 반환한다
4903 * @param {Object} [axes] The names of the axis <ko>축 이름들</ko>
4904 * @return {Object.<string, number>} Axis coordinate information <ko>축 좌표 정보</ko>
4905 * @example
4906 * ```js
4907 * const axes = new eg.Axes({
4908 * "x": {
4909 * range: [0, 100]
4910 * },
4911 * "xOther": {
4912 * range: [-100, 100]
4913 * },
4914 * "zoom": {
4915 * range: [50, 30]
4916 * }
4917 * });
4918 *
4919 * axes.get(); // {"x": 0, "xOther": -100, "zoom": 50}
4920 * axes.get(["x", "zoom"]); // {"x": 0, "zoom": 50}
4921 * ```
4922 */
4923
4924
4925 __proto.get = function (axes) {
4926 return this.axisManager.get(axes);
4927 };
4928 /**
4929 * Moves an axis to specific coordinates.
4930 * @ko 좌표를 이동한다.
4931 * @param {Object.<string, number>} pos The coordinate to move to <ko>이동할 좌표</ko>
4932 * @param {Number} [duration=0] Duration of the animation (unit: ms) <ko>애니메이션 진행 시간(단위: ms)</ko>
4933 * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
4934 * @example
4935 * ```js
4936 * const axes = new eg.Axes({
4937 * "x": {
4938 * range: [0, 100]
4939 * },
4940 * "xOther": {
4941 * range: [-100, 100]
4942 * },
4943 * "zoom": {
4944 * range: [50, 30]
4945 * }
4946 * });
4947 *
4948 * axes.setTo({"x": 30, "zoom": 60});
4949 * axes.get(); // {"x": 30, "xOther": -100, "zoom": 60}
4950 *
4951 * axes.setTo({"x": 100, "xOther": 60}, 1000); // animatation
4952 *
4953 * // after 1000 ms
4954 * axes.get(); // {"x": 100, "xOther": 60, "zoom": 60}
4955 * ```
4956 */
4957
4958
4959 __proto.setTo = function (pos, duration) {
4960 if (duration === void 0) {
4961 duration = 0;
4962 }
4963
4964 this.animationManager.setTo(pos, duration);
4965 return this;
4966 };
4967 /**
4968 * Moves an axis from the current coordinates to specific coordinates.
4969 * @ko 현재 좌표를 기준으로 좌표를 이동한다.
4970 * @param {Object.<string, number>} pos The coordinate to move to <ko>이동할 좌표</ko>
4971 * @param {Number} [duration=0] Duration of the animation (unit: ms) <ko>애니메이션 진행 시간(단위: ms)</ko>
4972 * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
4973 * @example
4974 * ```js
4975 * const axes = new eg.Axes({
4976 * "x": {
4977 * range: [0, 100]
4978 * },
4979 * "xOther": {
4980 * range: [-100, 100]
4981 * },
4982 * "zoom": {
4983 * range: [50, 30]
4984 * }
4985 * });
4986 *
4987 * axes.setBy({"x": 30, "zoom": 10});
4988 * axes.get(); // {"x": 30, "xOther": -100, "zoom": 60}
4989 *
4990 * axes.setBy({"x": 70, "xOther": 60}, 1000); // animatation
4991 *
4992 * // after 1000 ms
4993 * axes.get(); // {"x": 100, "xOther": -40, "zoom": 60}
4994 * ```
4995 */
4996
4997
4998 __proto.setBy = function (pos, duration) {
4999 if (duration === void 0) {
5000 duration = 0;
5001 }
5002
5003 this.animationManager.setBy(pos, duration);
5004 return this;
5005 };
5006 /**
5007 * Change the options of Axes instance.
5008 * @ko 인스턴스의 옵션을 변경한다.
5009 * @param {AxesOption} options Axes options to change <ko>변경할 옵션 목록</ko>
5010 * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
5011 * @example
5012 * ```js
5013 * const axes = new eg.Axes({
5014 * "x": {
5015 * range: [0, 100]
5016 * },
5017 * }, {
5018 * round: 10,
5019 * });
5020 *
5021 * axes.setTo({"x": 48});
5022 * axes.get(); // {"x": 50}
5023 *
5024 * axes.setOptions({
5025 * round: 1,
5026 * });
5027 *
5028 * axes.setTo({"x": 48});
5029 * axes.get(); // {"x": 48}
5030 * ```
5031 */
5032
5033
5034 __proto.setOptions = function (options) {
5035 this.options = __assign$1(__assign$1({}, this.options), options);
5036 return this;
5037 };
5038 /**
5039 * Change the information of an existing axis.
5040 * @ko 존재하는 축의 정보를 변경한다.
5041 * @param {Object.<string, AxisOption>} axis Axis options to change <ko>변경할 축의 정보</ko>
5042 * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
5043 * @example
5044 * ```js
5045 * const axes = new eg.Axes({
5046 * "x": {
5047 * range: [0, 100]
5048 * },
5049 * });
5050 *
5051 * axes.setTo({"x": 150});
5052 * axes.get(); // {"x": 100}
5053 *
5054 * axes.setAxis({
5055 * "x": {
5056 * range: [0, 200]
5057 * },
5058 * });
5059 *
5060 * axes.setTo({"x": 150});
5061 * axes.get(); // {"x": 150}
5062 * ```
5063 */
5064
5065
5066 __proto.setAxis = function (axis) {
5067 this.axisManager.setAxis(axis);
5068 return this;
5069 };
5070 /**
5071 * Stop an animation in progress.
5072 * @ko 재생 중인 애니메이션을 정지한다.
5073 * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
5074 * @example
5075 * ```js
5076 * const axes = new eg.Axes({
5077 * "x": {
5078 * range: [0, 100]
5079 * },
5080 * });
5081 *
5082 * axes.setTo({"x": 10}, 1000); // start animatation
5083 *
5084 * // after 500 ms
5085 * axes.stopAnimation(); // stop animation during movement.
5086 * ```
5087 */
5088
5089
5090 __proto.stopAnimation = function () {
5091 this.animationManager.stopAnimation();
5092 this.animationManager.finish(false);
5093 return this;
5094 };
5095 /**
5096 * Change the destination of an animation in progress.
5097 * @ko 재생 중인 애니메이션의 목적지와 진행 시간을 변경한다.
5098 * @param {UpdateAnimationOption} pos The coordinate to move to <ko>이동할 좌표</ko>
5099 * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
5100 * @example
5101 * ```js
5102 * const axes = new eg.Axes({
5103 * "x": {
5104 * range: [0, 200]
5105 * },
5106 * "y": {
5107 * range: [0, 200]
5108 * }
5109 * });
5110 *
5111 * axes.setTo({"x": 50, "y": 50}, 1000); // trigger animation by setTo
5112 *
5113 * // after 500 ms
5114 * axes.updateAnimation({destPos: {"x": 100, "y": 100}}); // animation will end after 500 ms, at {"x": 100, "y": 100}
5115 *
5116 * // after 500 ms
5117 * axes.setTo({"x": 50, "y": 50}, 1000); // trigger animation by setTo
5118 *
5119 * // after 700 ms
5120 * axes.updateAnimation({destPos: {"x": 100, "y": 100}, duration: 1500, restart: true}); // this works same as axes.setTo({"x": 100, "y": 100}, 800) since restart is true.
5121 * ```
5122 */
5123
5124
5125 __proto.updateAnimation = function (options) {
5126 this.animationManager.updateAnimation(options);
5127 return this;
5128 };
5129 /**
5130 * Returns whether there is a coordinate in the bounce area of ​​the target axis.
5131 * @ko 대상 축 중 bounce영역에 좌표가 존재하는지를 반환한다
5132 * @param {Object} [axes] The names of the axis <ko>축 이름들</ko>
5133 * @return {Boolen} Whether the bounce area exists. <ko>bounce 영역 존재 여부</ko>
5134 * @example
5135 * ```js
5136 * const axes = new eg.Axes({
5137 * "x": {
5138 * range: [0, 100]
5139 * },
5140 * "xOther": {
5141 * range: [-100, 100]
5142 * },
5143 * "zoom": {
5144 * range: [50, 30]
5145 * }
5146 * });
5147 *
5148 * axes.isBounceArea(["x"]);
5149 * axes.isBounceArea(["x", "zoom"]);
5150 * axes.isBounceArea();
5151 * ```
5152 */
5153
5154
5155 __proto.isBounceArea = function (axes) {
5156 return this.axisManager.isOutside(axes);
5157 };
5158 /**
5159 * Destroys properties, and events used in a module and disconnect all connections to inputTypes.
5160 * @ko 모듈에 사용한 속성, 이벤트를 해제한다. 모든 inputType과의 연결을 끊는다.
5161 */
5162
5163
5164 __proto.destroy = function () {
5165 this.disconnect();
5166 this.eventManager.destroy();
5167 };
5168 /**
5169 * @name VERSION
5170 * @desc Version info string
5171 * @ko 버전정보 문자열
5172 *
5173 * @constant
5174 * @type {String}
5175 * @example
5176 * ```js
5177 * eg.Axes.VERSION; // ex) 3.3.3
5178 * ```
5179 */
5180
5181
5182 Axes.VERSION = "3.8.1";
5183 /* eslint-enable */
5184
5185 /**
5186 * @name TRANSFORM
5187 * @desc Returns the transform attribute with CSS vendor prefixes.
5188 * @ko CSS vendor prefixes를 붙인 transform 속성을 반환한다.
5189 *
5190 * @constant
5191 * @type {String}
5192 * @example
5193 * ```js
5194 * eg.Axes.TRANSFORM; // "transform" or "webkitTransform"
5195 * ```
5196 */
5197
5198 Axes.TRANSFORM = TRANSFORM;
5199 /**
5200 * @name DIRECTION_NONE
5201 * @constant
5202 * @type {Number}
5203 */
5204
5205 Axes.DIRECTION_NONE = DIRECTION_NONE;
5206 /**
5207 * @name DIRECTION_LEFT
5208 * @constant
5209 * @type {Number}
5210 */
5211
5212 Axes.DIRECTION_LEFT = DIRECTION_LEFT;
5213 /**
5214 * @name DIRECTION_RIGHT
5215 * @constant
5216 * @type {Number}
5217 */
5218
5219 Axes.DIRECTION_RIGHT = DIRECTION_RIGHT;
5220 /**
5221 * @name DIRECTION_UP
5222 * @constant
5223 * @type {Number}
5224 */
5225
5226 Axes.DIRECTION_UP = DIRECTION_UP;
5227 /**
5228 * @name DIRECTION_DOWN
5229 * @constant
5230 * @type {Number}
5231 */
5232
5233 Axes.DIRECTION_DOWN = DIRECTION_DOWN;
5234 /**
5235 * @name DIRECTION_HORIZONTAL
5236 * @constant
5237 * @type {Number}
5238 */
5239
5240 Axes.DIRECTION_HORIZONTAL = DIRECTION_HORIZONTAL;
5241 /**
5242 * @name DIRECTION_VERTICAL
5243 * @constant
5244 * @type {Number}
5245 */
5246
5247 Axes.DIRECTION_VERTICAL = DIRECTION_VERTICAL;
5248 /**
5249 * @name DIRECTION_ALL
5250 * @constant
5251 * @type {Number}
5252 */
5253
5254 Axes.DIRECTION_ALL = DIRECTION_ALL;
5255 Axes = __decorate([ReactiveSubscribe], Axes);
5256 return Axes;
5257 }(Component);
5258
5259 /*
5260 * Copyright (c) 2015 NAVER Corp.
5261 * egjs projects are licensed under the MIT license
5262 */
5263
5264 var getDirectionByAngle = function (angle, thresholdAngle) {
5265 if (thresholdAngle < 0 || thresholdAngle > 90) {
5266 return DIRECTION_NONE;
5267 }
5268
5269 var toAngle = Math.abs(angle);
5270 return toAngle > thresholdAngle && toAngle < 180 - thresholdAngle ? DIRECTION_VERTICAL : DIRECTION_HORIZONTAL;
5271 };
5272 /**
5273 * @typedef {Object} PanInputOption The option object of the eg.Axes.PanInput module.
5274 * @ko eg.Axes.PanInput 모듈의 옵션 객체
5275 * @param {String[]} [inputType=["touch", "mouse", "pointer"]] Types of input devices
5276 * - touch: Touch screen
5277 * - mouse: Mouse
5278 * - pointer: Mouse and touch <ko>입력 장치 종류
5279 * - touch: 터치 입력 장치
5280 * - mouse: 마우스
5281 * - pointer: 마우스 및 터치</ko>
5282 * @param {String[]} [inputButton=["left"]] List of buttons to allow input
5283 * - left: Left mouse button and normal touch
5284 * - middle: Mouse wheel press
5285 * - right: Right mouse button <ko>입력을 허용할 버튼 목록
5286 * - left: 마우스 왼쪽 버튼
5287 * - middle: 마우스 휠 눌림
5288 * - right: 마우스 오른쪽 버튼 </ko>
5289 * @param {Number[]} [scale] Coordinate scale that a user can move<ko>사용자의 동작으로 이동하는 좌표의 배율</ko>
5290 * @param {Number} [scale[0]=1] horizontal axis scale <ko>수평축 배율</ko>
5291 * @param {Number} [scale[1]=1] vertical axis scale <ko>수직축 배율</ko>
5292 * @param {Number} [thresholdAngle=45] The threshold value that determines whether user action is horizontal or vertical (0~90) <ko>사용자의 동작이 가로 방향인지 세로 방향인지 판단하는 기준 각도(0~90)</ko>
5293 * @param {Number} [threshold=0] Minimal pan distance required before recognizing <ko>사용자의 Pan 동작을 인식하기 위해산 최소한의 거리</ko>
5294 * @param {Boolean} [preventClickOnDrag=false] Whether to cancel the {@link https://developer.mozilla.org/en/docs/Web/API/Element/click_event click} event when the user finishes dragging more than 1 pixel <ko>사용자가 1픽셀 이상 드래그를 마쳤을 때 {@link https://developer.mozilla.org/ko/docs/Web/API/Element/click_event click} 이벤트 취소 여부</ko>
5295 * @param {Number} [iOSEdgeSwipeThreshold=30] Area (px) that can go to the next page when swiping the right edge in iOS safari <ko>iOS Safari에서 오른쪽 엣지를 스와이프 하는 경우 다음 페이지로 넘어갈 수 있는 영역(px)</ko>
5296 * @param {String} [touchAction=null] Value that overrides the element's "touch-action" css property. If set to null, it is automatically set to prevent scrolling in the direction of the connected axis. <ko>엘리먼트의 "touch-action" CSS 속성을 덮어쓰는 값. 만약 null로 설정된 경우, 연결된 축 방향으로의 스크롤을 방지하게끔 자동으로 설정된다.</ko>
5297 **/
5298
5299 /**
5300 * A module that passes the amount of change to eg.Axes when the mouse or touchscreen is down and moved. use less than two axes.
5301 * @ko 마우스나 터치 스크린을 누르고 움직일때의 변화량을 eg.Axes에 전달하는 모듈. 두개 이하의 축을 사용한다.
5302 *
5303 * @example
5304 * ```js
5305 * const pan = new eg.Axes.PanInput("#area", {
5306 * inputType: ["touch"],
5307 * scale: [1, 1.3],
5308 * });
5309 *
5310 * // Connect the 'something2' axis to the mouse or touchscreen x position when the mouse or touchscreen is down and moved.
5311 * // Connect the 'somethingN' axis to the mouse or touchscreen y position when the mouse or touchscreen is down and moved.
5312 * axes.connect(["something2", "somethingN"], pan); // or axes.connect("something2 somethingN", pan);
5313 *
5314 * // Connect only one 'something1' axis to the mouse or touchscreen x position when the mouse or touchscreen is down and moved.
5315 * axes.connect(["something1"], pan); // or axes.connect("something1", pan);
5316 *
5317 * // Connect only one 'something2' axis to the mouse or touchscreen y position when the mouse or touchscreen is down and moved.
5318 * axes.connect(["", "something2"], pan); // or axes.connect(" something2", pan);
5319 * ```
5320 * @param {String|HTMLElement|Ref<HTMLElement>|jQuery} element An element to use the eg.Axes.PanInput module <ko>eg.Axes.PanInput 모듈을 사용할 엘리먼트</ko>
5321 * @param {PanInputOption} [options={}] The option object of the eg.Axes.PanInput module<ko>eg.Axes.PanInput 모듈의 옵션 객체</ko>
5322 */
5323
5324 var PanInput =
5325 /*#__PURE__*/
5326 function () {
5327 /**
5328 *
5329 */
5330 function PanInput(el, options) {
5331 var _this = this;
5332
5333 this.axes = [];
5334 this.element = null;
5335 this._enabled = false;
5336 this._activeEvent = null;
5337 this._atRightEdge = false;
5338 this._rightEdgeTimer = 0;
5339 this._dragged = false;
5340 this._isOverThreshold = false;
5341
5342 this._preventClickWhenDragged = function (e) {
5343 if (_this._dragged) {
5344 e.preventDefault();
5345 e.stopPropagation();
5346 }
5347
5348 _this._dragged = false;
5349 };
5350
5351 this._voidFunction = function () {};
5352
5353 this.element = $(el);
5354 this.options = __assign$1({
5355 inputType: ["touch", "mouse", "pointer"],
5356 inputButton: [MOUSE_LEFT],
5357 scale: [1, 1],
5358 thresholdAngle: 45,
5359 threshold: 0,
5360 preventClickOnDrag: false,
5361 iOSEdgeSwipeThreshold: IOS_EDGE_THRESHOLD,
5362 releaseOnScroll: false,
5363 touchAction: null
5364 }, options);
5365 this._onPanstart = this._onPanstart.bind(this);
5366 this._onPanmove = this._onPanmove.bind(this);
5367 this._onPanend = this._onPanend.bind(this);
5368 }
5369
5370 var __proto = PanInput.prototype;
5371
5372 __proto.mapAxes = function (axes) {
5373 this._direction = getDirection(!!axes[0], !!axes[1]);
5374 this.axes = axes;
5375 };
5376
5377 __proto.connect = function (observer) {
5378 if (this._activeEvent) {
5379 this._detachElementEvent();
5380
5381 this._detachWindowEvent(this._activeEvent);
5382 }
5383
5384 this._attachElementEvent(observer);
5385
5386 this._originalCssProps = setCssProps(this.element, this.options, this._direction);
5387 return this;
5388 };
5389
5390 __proto.disconnect = function () {
5391 this._detachElementEvent();
5392
5393 this._detachWindowEvent(this._activeEvent);
5394
5395 if (!isCssPropsFromAxes(this._originalCssProps)) {
5396 revertCssProps(this.element, this._originalCssProps);
5397 }
5398
5399 this._direction = DIRECTION_NONE;
5400 return this;
5401 };
5402 /**
5403 * Destroys elements, properties, and events used in a module.
5404 * @ko 모듈에 사용한 엘리먼트와 속성, 이벤트를 해제한다.
5405 */
5406
5407
5408 __proto.destroy = function () {
5409 this.disconnect();
5410 this.element = null;
5411 };
5412 /**
5413 * Enables input devices
5414 * @ko 입력 장치를 사용할 수 있게 한다
5415 * @return {PanInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
5416 */
5417
5418
5419 __proto.enable = function () {
5420 this._enabled = true;
5421 return this;
5422 };
5423 /**
5424 * Disables input devices
5425 * @ko 입력 장치를 사용할 수 없게 한다.
5426 * @return {PanInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
5427 */
5428
5429
5430 __proto.disable = function () {
5431 this._enabled = false;
5432 return this;
5433 };
5434 /**
5435 * Returns whether to use an input device
5436 * @ko 입력 장치 사용 여부를 반환한다.
5437 * @return {Boolean} Whether to use an input device <ko>입력장치 사용여부</ko>
5438 */
5439
5440
5441 __proto.isEnabled = function () {
5442 return this._enabled;
5443 };
5444 /**
5445 * Releases current user input.
5446 * @ko 사용자의 입력을 강제로 중단시킨다.
5447 * @return {PanInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
5448 */
5449
5450
5451 __proto.release = function () {
5452 var activeEvent = this._activeEvent;
5453 var prevEvent = activeEvent.prevEvent;
5454 activeEvent.onRelease();
5455
5456 this._observer.release(this, prevEvent, [0, 0]);
5457
5458 this._detachWindowEvent(activeEvent);
5459
5460 return this;
5461 };
5462
5463 __proto._onPanstart = function (event) {
5464 var inputButton = this.options.inputButton;
5465 var activeEvent = this._activeEvent;
5466 var panEvent = activeEvent.onEventStart(event, inputButton);
5467
5468 if (!panEvent || !this._enabled || activeEvent.getTouches(event, inputButton) > 1) {
5469 return;
5470 }
5471
5472 if (panEvent.srcEvent.cancelable !== false) {
5473 var edgeThreshold = this.options.iOSEdgeSwipeThreshold;
5474 this._dragged = false;
5475 this._isOverThreshold = false;
5476
5477 this._observer.hold(this, panEvent);
5478
5479 this._atRightEdge = IS_IOS_SAFARI && panEvent.center.x > window.innerWidth - edgeThreshold;
5480
5481 this._attachWindowEvent(activeEvent);
5482
5483 activeEvent.prevEvent = panEvent;
5484 }
5485 };
5486
5487 __proto._onPanmove = function (event) {
5488 var _this = this;
5489
5490 var _a = this.options,
5491 iOSEdgeSwipeThreshold = _a.iOSEdgeSwipeThreshold,
5492 releaseOnScroll = _a.releaseOnScroll,
5493 inputButton = _a.inputButton,
5494 threshold = _a.threshold,
5495 thresholdAngle = _a.thresholdAngle;
5496 var activeEvent = this._activeEvent;
5497 var panEvent = activeEvent.onEventMove(event, inputButton);
5498 var touches = activeEvent.getTouches(event, inputButton);
5499
5500 if (touches === 0 || releaseOnScroll && panEvent && !panEvent.srcEvent.cancelable) {
5501 this._onPanend(event);
5502
5503 return;
5504 }
5505
5506 if (!panEvent || !this._enabled || touches > 1) {
5507 return;
5508 }
5509
5510 var userDirection = getDirectionByAngle(panEvent.angle, thresholdAngle);
5511 var useHorizontal = useDirection(DIRECTION_HORIZONTAL, this._direction, userDirection);
5512 var useVertical = useDirection(DIRECTION_VERTICAL, this._direction, userDirection);
5513
5514 if (activeEvent.prevEvent && IS_IOS_SAFARI) {
5515 var swipeLeftToRight = panEvent.center.x < 0;
5516
5517 if (swipeLeftToRight) {
5518 // iOS swipe left => right
5519 this.release();
5520 return;
5521 } else if (this._atRightEdge) {
5522 clearTimeout(this._rightEdgeTimer); // - is right to left
5523
5524 var swipeRightToLeft = panEvent.deltaX < -iOSEdgeSwipeThreshold;
5525
5526 if (swipeRightToLeft) {
5527 this._atRightEdge = false;
5528 } else {
5529 // iOS swipe right => left
5530 this._rightEdgeTimer = window.setTimeout(function () {
5531 return _this.release();
5532 }, 100);
5533 }
5534 }
5535 }
5536
5537 var distance = this._getDistance([panEvent.deltaX, panEvent.deltaY], [useHorizontal, useVertical]);
5538
5539 var offset = this._getOffset([panEvent.offsetX, panEvent.offsetY], [useHorizontal, useVertical]);
5540
5541 var prevent = offset.some(function (v) {
5542 return v !== 0;
5543 });
5544
5545 if (prevent) {
5546 if (panEvent.srcEvent.cancelable !== false) {
5547 panEvent.srcEvent.preventDefault();
5548 }
5549
5550 panEvent.srcEvent.stopPropagation();
5551 }
5552
5553 panEvent.preventSystemEvent = prevent;
5554
5555 if (prevent && (this._isOverThreshold || distance >= threshold)) {
5556 this._dragged = true;
5557 this._isOverThreshold = true;
5558
5559 this._observer.change(this, panEvent, toAxis(this.axes, offset));
5560 }
5561
5562 activeEvent.prevEvent = panEvent;
5563 };
5564
5565 __proto._onPanend = function (event) {
5566 var inputButton = this.options.inputButton;
5567 var activeEvent = this._activeEvent;
5568 activeEvent.onEventEnd(event);
5569
5570 if (!this._enabled || activeEvent.getTouches(event, inputButton) !== 0) {
5571 return;
5572 }
5573
5574 this._detachWindowEvent(activeEvent);
5575
5576 clearTimeout(this._rightEdgeTimer);
5577 var prevEvent = activeEvent.prevEvent;
5578 var velocity = this._isOverThreshold ? this._getOffset([Math.abs(prevEvent.velocityX) * (prevEvent.offsetX < 0 ? -1 : 1), Math.abs(prevEvent.velocityY) * (prevEvent.offsetY < 0 ? -1 : 1)], [useDirection(DIRECTION_HORIZONTAL, this._direction), useDirection(DIRECTION_VERTICAL, this._direction)]) : [0, 0];
5579 activeEvent.onRelease();
5580
5581 this._observer.release(this, prevEvent, velocity);
5582 };
5583
5584 __proto._attachWindowEvent = function (activeEvent) {
5585 var _this = this;
5586
5587 activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.move.forEach(function (event) {
5588 window.addEventListener(event, _this._onPanmove, {
5589 passive: false
5590 });
5591 });
5592 activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.end.forEach(function (event) {
5593 window.addEventListener(event, _this._onPanend, {
5594 passive: false
5595 });
5596 });
5597 };
5598
5599 __proto._detachWindowEvent = function (activeEvent) {
5600 var _this = this;
5601
5602 activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.move.forEach(function (event) {
5603 window.removeEventListener(event, _this._onPanmove);
5604 });
5605 activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.end.forEach(function (event) {
5606 window.removeEventListener(event, _this._onPanend);
5607 });
5608 };
5609
5610 __proto._getOffset = function (properties, direction) {
5611 var scale = this.options.scale;
5612 return [direction[0] ? properties[0] * scale[0] : 0, direction[1] ? properties[1] * scale[1] : 0];
5613 };
5614
5615 __proto._getDistance = function (delta, direction) {
5616 return Math.sqrt(Number(direction[0]) * Math.pow(delta[0], 2) + Number(direction[1]) * Math.pow(delta[1], 2));
5617 };
5618
5619 __proto._attachElementEvent = function (observer) {
5620 var _this = this;
5621
5622 var activeEvent = convertInputType(this.options.inputType);
5623 var element = this.element;
5624
5625 if (!activeEvent) {
5626 return;
5627 }
5628
5629 if (!element) {
5630 throw new Error("Element to connect input does not exist.");
5631 }
5632
5633 this._observer = observer;
5634 this._enabled = true;
5635 this._activeEvent = activeEvent;
5636
5637 if (this.options.preventClickOnDrag) {
5638 element.addEventListener("click", this._preventClickWhenDragged, true);
5639 }
5640
5641 activeEvent.start.forEach(function (event) {
5642 element.addEventListener(event, _this._onPanstart);
5643 }); // adding event listener to element prevents invalid behavior in iOS Safari
5644
5645 activeEvent.move.forEach(function (event) {
5646 element.addEventListener(event, _this._voidFunction);
5647 });
5648 };
5649
5650 __proto._detachElementEvent = function () {
5651 var _this = this;
5652
5653 var activeEvent = this._activeEvent;
5654 var element = this.element;
5655
5656 if (element) {
5657 if (this.options.preventClickOnDrag) {
5658 element.removeEventListener("click", this._preventClickWhenDragged, true);
5659 }
5660
5661 activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.start.forEach(function (event) {
5662 element.removeEventListener(event, _this._onPanstart);
5663 });
5664 activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.move.forEach(function (event) {
5665 element.removeEventListener(event, _this._voidFunction);
5666 });
5667 }
5668
5669 this._enabled = false;
5670 this._observer = null;
5671 };
5672
5673 return PanInput;
5674 }();
5675
5676 /*
5677 * Copyright (c) 2015 NAVER Corp.
5678 * egjs projects are licensed under the MIT license
5679 */
5680
5681 var Axes$1 = Axes;
5682
5683 /**
5684 * All possible @egjs/axes event keys
5685 * @internal
5686 */
5687 var EVENT = {
5688 HOLD: "hold",
5689 CHANGE: "change",
5690 RELEASE: "release",
5691 ANIMATION_END: "animationEnd",
5692 FINISH: "finish"
5693 };
5694 /**
5695 * An Axis key that Flicking uses
5696 * @internal
5697 */
5698
5699 var POSITION_KEY = "flick";
5700
5701 var STATE_TYPE;
5702
5703 (function (STATE_TYPE) {
5704 STATE_TYPE[STATE_TYPE["IDLE"] = 0] = "IDLE";
5705 STATE_TYPE[STATE_TYPE["HOLDING"] = 1] = "HOLDING";
5706 STATE_TYPE[STATE_TYPE["DRAGGING"] = 2] = "DRAGGING";
5707 STATE_TYPE[STATE_TYPE["ANIMATING"] = 3] = "ANIMATING";
5708 STATE_TYPE[STATE_TYPE["DISABLED"] = 4] = "DISABLED";
5709 })(STATE_TYPE || (STATE_TYPE = {}));
5710 /**
5711 * A component that shows the current status of the user input or the animation
5712 * @ko 현재 사용자 입력 또는 애니메이션 상태를 나타내는 컴포넌트
5713 * @internal
5714 */
5715
5716
5717 var State =
5718 /*#__PURE__*/
5719 function () {
5720 function State() {
5721 this._delta = 0;
5722 this._targetPanel = null;
5723 }
5724
5725 var __proto = State.prototype;
5726 Object.defineProperty(__proto, "delta", {
5727 /**
5728 * A sum of delta values of change events from the last hold event of Axes
5729 * @ko 이전 hold이벤트부터 change에 의해 발생한 이동 delta값의 합산
5730 * @type {number}
5731 * @readonly
5732 */
5733 get: function () {
5734 return this._delta;
5735 },
5736 enumerable: false,
5737 configurable: true
5738 });
5739 Object.defineProperty(__proto, "targetPanel", {
5740 /**
5741 * A panel to set as {@link Control#activePanel} after the animation is finished
5742 * @ko 애니메이션 종료시 {@link Control#activePanel}로 설정할 패널
5743 * @type {number}
5744 * @readonly
5745 */
5746 get: function () {
5747 return this._targetPanel;
5748 },
5749 set: function (val) {
5750 this._targetPanel = val;
5751 },
5752 enumerable: false,
5753 configurable: true
5754 });
5755 /**
5756 * An callback which is called when state has changed to this state
5757 * @ko 현재 상태로 돌입했을때 호출되는 콜백 함수
5758 * @param {State} prevState An previous state<ko>이전 상태값</ko>
5759 * @return {void}
5760 */
5761
5762 __proto.onEnter = function (prevState) {
5763 this._delta = prevState._delta;
5764 this._targetPanel = prevState._targetPanel;
5765 };
5766 /**
5767 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} event
5768 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} 이벤트 핸들러
5769 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
5770 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
5771 * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} event of Axes
5772 * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:hold hold} 이벤트</ko>
5773 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
5774 * @return {void}
5775 */
5776
5777
5778 __proto.onHold = function (ctx) {// DO NOTHING
5779 };
5780 /**
5781 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} event
5782 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} 이벤트 핸들러
5783 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
5784 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
5785 * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} event of Axes
5786 * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:change change} 이벤트</ko>
5787 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
5788 * @return {void}
5789 */
5790
5791
5792 __proto.onChange = function (ctx) {// DO NOTHING
5793 };
5794 /**
5795 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event
5796 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트 핸들러
5797 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
5798 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
5799 * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} event of Axes
5800 * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:release release} 이벤트</ko>
5801 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
5802 * @return {void}
5803 */
5804
5805
5806 __proto.onRelease = function (ctx) {// DO NOTHING
5807 };
5808 /**
5809 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} event
5810 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} 이벤트 핸들러
5811 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
5812 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
5813 * @param {object} [ctx.axesEvent] A {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} event of Axes
5814 * <ko>Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:animationEnd animationEnd} 이벤트</ko>
5815 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
5816 * @return {void}
5817 */
5818
5819
5820 __proto.onAnimationEnd = function (ctx) {// DO NOTHING
5821 };
5822 /**
5823 * An event handler for Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} event
5824 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#event:finish finish} 이벤트 핸들러
5825 * @param {object} [ctx] Event context<ko>이벤트 콘텍스트</ko>
5826 * @param {Flicking} [ctx.flicking] An instance of Flicking<ko>Flicking 인스턴스</ko>
5827 * @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>
5828 * @param {function} [ctx.transitTo] A function for changing current state to other state<ko>다른 상태로 변경하기 위한 함수</ko>
5829 * @return {void}
5830 */
5831
5832
5833 __proto.onFinish = function (ctx) {// DO NOTHING
5834 };
5835
5836 __proto._moveToChangedPosition = function (ctx) {
5837 var flicking = ctx.flicking,
5838 axesEvent = ctx.axesEvent,
5839 transitTo = ctx.transitTo;
5840 var delta = axesEvent.delta[POSITION_KEY];
5841
5842 if (!delta) {
5843 return;
5844 }
5845
5846 this._delta += delta;
5847 var camera = flicking.camera;
5848 var prevPosition = camera.position;
5849 var position = axesEvent.pos[POSITION_KEY];
5850 var newPosition = flicking.circularEnabled ? circulatePosition(position, camera.range.min, camera.range.max) : position;
5851 camera.lookAt(newPosition);
5852 var moveEvent = new ComponentEvent$1(EVENTS.MOVE, {
5853 isTrusted: axesEvent.isTrusted,
5854 holding: this.holding,
5855 direction: getDirection$1(0, axesEvent.delta[POSITION_KEY]),
5856 axesEvent: axesEvent
5857 });
5858 flicking.trigger(moveEvent);
5859
5860 if (moveEvent.isCanceled()) {
5861 // Return to previous position
5862 camera.lookAt(prevPosition);
5863 transitTo(STATE_TYPE.DISABLED);
5864 }
5865 };
5866
5867 return State;
5868 }();
5869
5870 /**
5871 * A default state when there's no user input and no animation's playing
5872 * @ko 사용자의 입력이 없고, 애니메이션이 동작하고있지 않은 기본 상태
5873 * @internal
5874 */
5875
5876 var IdleState =
5877 /*#__PURE__*/
5878 function (_super) {
5879 __extends$2(IdleState, _super);
5880
5881 function IdleState() {
5882 var _this = _super !== null && _super.apply(this, arguments) || this;
5883 /**
5884 * Whether user is clicking or touching
5885 * @ko 현재 사용자가 클릭/터치중인지 여부
5886 * @type {false}
5887 * @readonly
5888 */
5889
5890
5891 _this.holding = false;
5892 /**
5893 * Whether Flicking's animating
5894 * @ko 현재 애니메이션 동작 여부
5895 * @type {false}
5896 * @readonly
5897 */
5898
5899 _this.animating = false;
5900 return _this;
5901 }
5902
5903 var __proto = IdleState.prototype;
5904
5905 __proto.onEnter = function () {
5906 this._delta = 0;
5907 this._targetPanel = null;
5908 };
5909
5910 __proto.onHold = function (ctx) {
5911 // Shouldn't do any action until any panels on flicking area
5912 var flicking = ctx.flicking,
5913 axesEvent = ctx.axesEvent,
5914 transitTo = ctx.transitTo;
5915
5916 if (flicking.renderer.panelCount <= 0) {
5917 transitTo(STATE_TYPE.DISABLED);
5918 return;
5919 }
5920
5921 var holdStartEvent = new ComponentEvent$1(EVENTS.HOLD_START, {
5922 axesEvent: axesEvent
5923 });
5924 flicking.trigger(holdStartEvent);
5925
5926 if (holdStartEvent.isCanceled()) {
5927 transitTo(STATE_TYPE.DISABLED);
5928 } else {
5929 transitTo(STATE_TYPE.HOLDING);
5930 }
5931 }; // By methods call
5932
5933
5934 __proto.onChange = function (ctx) {
5935 var flicking = ctx.flicking,
5936 axesEvent = ctx.axesEvent,
5937 transitTo = ctx.transitTo;
5938 var controller = flicking.control.controller;
5939 var animatingContext = controller.animatingContext;
5940 var moveStartEvent = new ComponentEvent$1(EVENTS.MOVE_START, {
5941 isTrusted: axesEvent.isTrusted,
5942 holding: this.holding,
5943 direction: getDirection$1(animatingContext.start, animatingContext.end),
5944 axesEvent: axesEvent
5945 });
5946 flicking.trigger(moveStartEvent);
5947
5948 if (moveStartEvent.isCanceled()) {
5949 transitTo(STATE_TYPE.DISABLED);
5950 } else {
5951 // Trigger AnimatingState's onChange, to trigger "move" event immediately
5952 transitTo(STATE_TYPE.ANIMATING).onChange(ctx);
5953 }
5954 };
5955
5956 return IdleState;
5957 }(State);
5958
5959 /**
5960 * A state that activates when user's holding the Flicking area, but not moved a single pixel yet
5961 * @ko 사용자의 입력이 시작되었으나, 아직 움직이지는 않은 상태
5962 * @internal
5963 */
5964
5965 var HoldingState =
5966 /*#__PURE__*/
5967 function (_super) {
5968 __extends$2(HoldingState, _super);
5969
5970 function HoldingState() {
5971 var _this = _super !== null && _super.apply(this, arguments) || this;
5972 /**
5973 * Whether user is clicking or touching
5974 * @ko 현재 사용자가 클릭/터치중인지 여부
5975 * @type {true}
5976 * @readonly
5977 */
5978
5979
5980 _this.holding = true;
5981 /**
5982 * Whether Flicking's animating
5983 * @ko 현재 애니메이션 동작 여부
5984 * @type {false}
5985 * @readonly
5986 */
5987
5988 _this.animating = false;
5989 _this._releaseEvent = null;
5990 return _this;
5991 }
5992
5993 var __proto = HoldingState.prototype;
5994
5995 __proto.onChange = function (ctx) {
5996 var flicking = ctx.flicking,
5997 axesEvent = ctx.axesEvent,
5998 transitTo = ctx.transitTo;
5999 var inputEvent = axesEvent.inputEvent;
6000 var offset = flicking.horizontal ? inputEvent.offsetX : inputEvent.offsetY;
6001 var moveStartEvent = new ComponentEvent$1(EVENTS.MOVE_START, {
6002 isTrusted: axesEvent.isTrusted,
6003 holding: this.holding,
6004 direction: getDirection$1(0, -offset),
6005 axesEvent: axesEvent
6006 });
6007 flicking.trigger(moveStartEvent);
6008
6009 if (moveStartEvent.isCanceled()) {
6010 transitTo(STATE_TYPE.DISABLED);
6011 } else {
6012 // Trigger DraggingState's onChange, to trigger "move" event immediately
6013 transitTo(STATE_TYPE.DRAGGING).onChange(ctx);
6014 }
6015 };
6016
6017 __proto.onRelease = function (ctx) {
6018 var flicking = ctx.flicking,
6019 axesEvent = ctx.axesEvent,
6020 transitTo = ctx.transitTo;
6021 flicking.trigger(new ComponentEvent$1(EVENTS.HOLD_END, {
6022 axesEvent: axesEvent
6023 }));
6024
6025 if (axesEvent.delta.flick !== 0) {
6026 // Sometimes "release" event on axes triggered before "change" event
6027 // Especially if user flicked panel fast in really short amount of time
6028 // if delta is not zero, that means above case happened.
6029 // Event flow should be HOLD_START -> MOVE_START -> MOVE -> HOLD_END
6030 // At least one move event should be included between holdStart and holdEnd
6031 axesEvent.setTo({
6032 flick: flicking.camera.position
6033 }, 0);
6034 transitTo(STATE_TYPE.IDLE);
6035 return;
6036 } // Can't handle select event here,
6037 // As "finish" axes event happens
6038
6039
6040 this._releaseEvent = axesEvent;
6041 };
6042
6043 __proto.onFinish = function (ctx) {
6044 var e_1, _a;
6045
6046 var flicking = ctx.flicking,
6047 transitTo = ctx.transitTo; // Should transite to IDLE state before select event
6048 // As user expects hold is already finished
6049
6050 transitTo(STATE_TYPE.IDLE);
6051
6052 if (!this._releaseEvent) {
6053 return;
6054 } // Handle release event here
6055 // To prevent finish event called twice
6056
6057
6058 var releaseEvent = this._releaseEvent; // Static click
6059
6060 /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
6061
6062 var srcEvent = releaseEvent.inputEvent.srcEvent;
6063 var clickedElement;
6064
6065 if (srcEvent.type === "touchend") {
6066 var touchEvent = srcEvent;
6067 var touch = touchEvent.changedTouches[0];
6068 clickedElement = document.elementFromPoint(touch.clientX, touch.clientY);
6069 } else {
6070 clickedElement = srcEvent.target;
6071 }
6072 /* eslint-enable */
6073
6074
6075 var panels = flicking.renderer.panels;
6076 var clickedPanel = null;
6077
6078 try {
6079 for (var panels_1 = __values$1(panels), panels_1_1 = panels_1.next(); !panels_1_1.done; panels_1_1 = panels_1.next()) {
6080 var panel = panels_1_1.value;
6081
6082 if (panel.contains(clickedElement)) {
6083 clickedPanel = panel;
6084 break;
6085 }
6086 }
6087 } catch (e_1_1) {
6088 e_1 = {
6089 error: e_1_1
6090 };
6091 } finally {
6092 try {
6093 if (panels_1_1 && !panels_1_1.done && (_a = panels_1.return)) _a.call(panels_1);
6094 } finally {
6095 if (e_1) throw e_1.error;
6096 }
6097 }
6098
6099 if (clickedPanel) {
6100 var cameraPosition = flicking.camera.position;
6101 var clickedPanelPosition = clickedPanel.position;
6102 flicking.trigger(new ComponentEvent$1(EVENTS.SELECT, {
6103 index: clickedPanel.index,
6104 panel: clickedPanel,
6105 // Direction to the clicked panel
6106 direction: getDirection$1(cameraPosition, clickedPanelPosition)
6107 }));
6108 }
6109 };
6110
6111 return HoldingState;
6112 }(State);
6113
6114 /**
6115 * A state that activates when user's dragging the Flicking area
6116 * @ko 사용자가 드래깅중인 상태
6117 * @internal
6118 */
6119
6120 var DraggingState =
6121 /*#__PURE__*/
6122 function (_super) {
6123 __extends$2(DraggingState, _super);
6124
6125 function DraggingState() {
6126 var _this = _super !== null && _super.apply(this, arguments) || this;
6127 /**
6128 * Whether user is clicking or touching
6129 * @ko 현재 사용자가 클릭/터치중인지 여부
6130 * @type {true}
6131 * @readonly
6132 */
6133
6134
6135 _this.holding = true;
6136 /**
6137 * Whether Flicking's animating
6138 * @ko 현재 애니메이션 동작 여부
6139 * @type {true}
6140 * @readonly
6141 */
6142
6143 _this.animating = true;
6144 return _this;
6145 }
6146
6147 var __proto = DraggingState.prototype;
6148
6149 __proto.onChange = function (ctx) {
6150 this._moveToChangedPosition(ctx);
6151 };
6152
6153 __proto.onRelease = function (ctx) {
6154 var _a;
6155
6156 var flicking = ctx.flicking,
6157 axesEvent = ctx.axesEvent,
6158 transitTo = ctx.transitTo; // Update last position to cope with Axes's animating behavior
6159 // Axes uses start position when animation start
6160
6161 flicking.trigger(new ComponentEvent$1(EVENTS.HOLD_END, {
6162 axesEvent: axesEvent
6163 }));
6164
6165 if (flicking.renderer.panelCount <= 0) {
6166 // There're no panels
6167 transitTo(STATE_TYPE.IDLE);
6168 return;
6169 }
6170
6171 transitTo(STATE_TYPE.ANIMATING);
6172 var control = flicking.control;
6173 var position = axesEvent.destPos[POSITION_KEY];
6174 var duration = Math.max(axesEvent.duration, flicking.duration);
6175
6176 try {
6177 void control.moveToPosition(position, duration, axesEvent);
6178 } catch (err) {
6179 transitTo(STATE_TYPE.IDLE);
6180 axesEvent.setTo((_a = {}, _a[POSITION_KEY] = flicking.camera.position, _a), 0);
6181 }
6182 };
6183
6184 return DraggingState;
6185 }(State);
6186
6187 /**
6188 * A state that activates when Flicking's animating by user input or method call
6189 * @ko 사용자 입력이나 메소드 호출에 의해 Flicking의 애니메이션이 동작중인 상태
6190 * @internal
6191 */
6192
6193 var AnimatingState =
6194 /*#__PURE__*/
6195 function (_super) {
6196 __extends$2(AnimatingState, _super);
6197
6198 function AnimatingState() {
6199 var _this = _super !== null && _super.apply(this, arguments) || this;
6200 /**
6201 * Whether user is clicking or touching
6202 * @ko 현재 사용자가 클릭/터치중인지 여부
6203 * @type {false}
6204 * @readonly
6205 */
6206
6207
6208 _this.holding = false;
6209 /**
6210 * Whether Flicking's animating
6211 * @ko 현재 애니메이션 동작 여부
6212 * @type {true}
6213 * @readonly
6214 */
6215
6216 _this.animating = true;
6217 return _this;
6218 }
6219
6220 var __proto = AnimatingState.prototype;
6221
6222 __proto.onHold = function (ctx) {
6223 var flicking = ctx.flicking,
6224 axesEvent = ctx.axesEvent,
6225 transitTo = ctx.transitTo;
6226 var targetPanel = this._targetPanel;
6227 var control = flicking.control;
6228 this._delta = 0;
6229 flicking.control.updateInput();
6230
6231 if (flicking.changeOnHold && targetPanel) {
6232 control.setActive(targetPanel, control.activePanel, axesEvent.isTrusted);
6233 }
6234
6235 var holdStartEvent = new ComponentEvent$1(EVENTS.HOLD_START, {
6236 axesEvent: axesEvent
6237 });
6238 flicking.trigger(holdStartEvent);
6239
6240 if (holdStartEvent.isCanceled()) {
6241 transitTo(STATE_TYPE.DISABLED);
6242 } else {
6243 transitTo(STATE_TYPE.DRAGGING);
6244 }
6245 };
6246
6247 __proto.onChange = function (ctx) {
6248 this._moveToChangedPosition(ctx);
6249 };
6250
6251 __proto.onFinish = function (ctx) {
6252 var flicking = ctx.flicking,
6253 axesEvent = ctx.axesEvent,
6254 transitTo = ctx.transitTo;
6255 var control = flicking.control;
6256 var controller = control.controller;
6257 var animatingContext = controller.animatingContext;
6258 transitTo(STATE_TYPE.IDLE);
6259 flicking.trigger(new ComponentEvent$1(EVENTS.MOVE_END, {
6260 isTrusted: axesEvent.isTrusted,
6261 direction: getDirection$1(animatingContext.start, animatingContext.end),
6262 axesEvent: axesEvent
6263 }));
6264 var targetPanel = this._targetPanel;
6265
6266 if (targetPanel) {
6267 control.setActive(targetPanel, control.activePanel, axesEvent.isTrusted);
6268 }
6269 };
6270
6271 return AnimatingState;
6272 }(State);
6273
6274 /**
6275 * A state that activates when Flicking is stopped by event's `stop` method
6276 * @ko 이벤트의 `stop`호출에 의해 Flicking이 정지된 상태
6277 * @internal
6278 */
6279
6280 var DisabledState =
6281 /*#__PURE__*/
6282 function (_super) {
6283 __extends$2(DisabledState, _super);
6284
6285 function DisabledState() {
6286 var _this = _super !== null && _super.apply(this, arguments) || this;
6287 /**
6288 * Whether user is clicking or touching
6289 * @ko 현재 사용자가 클릭/터치중인지 여부
6290 * @type {false}
6291 * @readonly
6292 */
6293
6294
6295 _this.holding = false;
6296 /**
6297 * Whether Flicking's animating
6298 * @ko 현재 애니메이션 동작 여부
6299 * @type {true}
6300 * @readonly
6301 */
6302
6303 _this.animating = true;
6304 return _this;
6305 }
6306
6307 var __proto = DisabledState.prototype;
6308
6309 __proto.onAnimationEnd = function (ctx) {
6310 var transitTo = ctx.transitTo;
6311 transitTo(STATE_TYPE.IDLE);
6312 };
6313
6314 __proto.onChange = function (ctx) {
6315 var axesEvent = ctx.axesEvent,
6316 transitTo = ctx.transitTo; // Can stop Axes's change event
6317
6318 axesEvent.stop();
6319 transitTo(STATE_TYPE.IDLE);
6320 };
6321
6322 __proto.onRelease = function (ctx) {
6323 var axesEvent = ctx.axesEvent,
6324 transitTo = ctx.transitTo; // This is needed when stopped hold start event
6325
6326 if (axesEvent.delta.flick === 0) {
6327 transitTo(STATE_TYPE.IDLE);
6328 }
6329 };
6330
6331 return DisabledState;
6332 }(State);
6333
6334 /**
6335 * @internal
6336 */
6337
6338 var StateMachine =
6339 /*#__PURE__*/
6340 function () {
6341 function StateMachine() {
6342 var _this = this;
6343
6344 this.transitTo = function (nextStateType) {
6345 var nextState;
6346
6347 switch (nextStateType) {
6348 case STATE_TYPE.IDLE:
6349 nextState = new IdleState();
6350 break;
6351
6352 case STATE_TYPE.HOLDING:
6353 nextState = new HoldingState();
6354 break;
6355
6356 case STATE_TYPE.DRAGGING:
6357 nextState = new DraggingState();
6358 break;
6359
6360 case STATE_TYPE.ANIMATING:
6361 nextState = new AnimatingState();
6362 break;
6363
6364 case STATE_TYPE.DISABLED:
6365 nextState = new DisabledState();
6366 break;
6367 }
6368
6369 nextState.onEnter(_this._state);
6370 _this._state = nextState;
6371 return _this._state;
6372 };
6373
6374 this._state = new IdleState();
6375 }
6376
6377 var __proto = StateMachine.prototype;
6378 Object.defineProperty(__proto, "state", {
6379 get: function () {
6380 return this._state;
6381 },
6382 enumerable: false,
6383 configurable: true
6384 });
6385
6386 __proto.fire = function (eventType, externalCtx) {
6387 var currentState = this._state;
6388
6389 var ctx = __assign$2(__assign$2({}, externalCtx), {
6390 transitTo: this.transitTo
6391 });
6392
6393 switch (eventType) {
6394 case EVENT.HOLD:
6395 currentState.onHold(ctx);
6396 break;
6397
6398 case EVENT.CHANGE:
6399 currentState.onChange(ctx);
6400 break;
6401
6402 case EVENT.RELEASE:
6403 currentState.onRelease(ctx);
6404 break;
6405
6406 case EVENT.ANIMATION_END:
6407 currentState.onAnimationEnd(ctx);
6408 break;
6409
6410 case EVENT.FINISH:
6411 currentState.onFinish(ctx);
6412 break;
6413 }
6414 };
6415
6416 return StateMachine;
6417 }();
6418
6419 /**
6420 * A controller that handles the {@link https://naver.github.io/egjs-axes/ @egjs/axes} events
6421 * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 이벤트를 처리하는 컨트롤러 컴포넌트
6422 * @internal
6423 */
6424
6425 var AxesController =
6426 /*#__PURE__*/
6427 function () {
6428 /** */
6429 function AxesController() {
6430 var _this = this;
6431
6432 this._onAxesHold = function () {
6433 _this._dragged = false;
6434 };
6435
6436 this._onAxesChange = function () {
6437 var _a;
6438
6439 _this._dragged = !!((_a = _this._panInput) === null || _a === void 0 ? void 0 : _a.isEnabled());
6440 };
6441
6442 this._preventClickWhenDragged = function (e) {
6443 if (_this._dragged) {
6444 e.preventDefault();
6445 e.stopPropagation();
6446 }
6447
6448 _this._dragged = false;
6449 };
6450
6451 this._resetInternalValues();
6452
6453 this._stateMachine = new StateMachine();
6454 }
6455
6456 var __proto = AxesController.prototype;
6457 Object.defineProperty(__proto, "axes", {
6458 /**
6459 * An {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} instance
6460 * @ko {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes}의 인스턴스
6461 * @type {Axes}
6462 * @see https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html
6463 * @readonly
6464 */
6465 get: function () {
6466 return this._axes;
6467 },
6468 enumerable: false,
6469 configurable: true
6470 });
6471 Object.defineProperty(__proto, "stateMachine", {
6472 /**
6473 * @internal
6474 */
6475 get: function () {
6476 return this._stateMachine;
6477 },
6478 enumerable: false,
6479 configurable: true
6480 });
6481 Object.defineProperty(__proto, "state", {
6482 /**
6483 * A activated {@link State} that shows the current status of the user input or the animation
6484 * @ko 현재 활성화된 {@link State} 인스턴스로 사용자 입력 또는 애니메이션 상태를 나타냅니다
6485 * @type {State}
6486 */
6487 get: function () {
6488 return this._stateMachine.state;
6489 },
6490 enumerable: false,
6491 configurable: true
6492 });
6493 Object.defineProperty(__proto, "animatingContext", {
6494 /**
6495 * A context of the current animation playing
6496 * @ko 현재 재생중인 애니메이션 정보
6497 * @type {object}
6498 * @property {number} start A start position of the animation<ko>애니메이션 시작 지점</ko>
6499 * @property {number} end A end position of the animation<ko>애니메이션 끝 지점</ko>
6500 * @property {number} offset camera offset<ko>카메라 오프셋</ko>
6501 * @readonly
6502 */
6503 get: function () {
6504 return this._animatingContext;
6505 },
6506 enumerable: false,
6507 configurable: true
6508 });
6509 Object.defineProperty(__proto, "controlParams", {
6510 /**
6511 * A current control parameters of the Axes instance
6512 * @ko 활성화된 현재 Axes 패러미터들
6513 * @type {ControlParams}
6514 */
6515 get: function () {
6516 var axes = this._axes;
6517
6518 if (!axes) {
6519 return {
6520 range: {
6521 min: 0,
6522 max: 0
6523 },
6524 position: 0,
6525 circular: false
6526 };
6527 }
6528
6529 var axis = axes.axis[POSITION_KEY];
6530 return {
6531 range: {
6532 min: axis.range[0],
6533 max: axis.range[1]
6534 },
6535 circular: axis.circular[0],
6536 position: this.position
6537 };
6538 },
6539 enumerable: false,
6540 configurable: true
6541 });
6542 Object.defineProperty(__proto, "enabled", {
6543 /**
6544 * A Boolean indicating whether the user input is enabled
6545 * @ko 현재 사용자 입력이 활성화되었는지를 나타내는 값
6546 * @type {boolean}
6547 * @readonly
6548 */
6549 get: function () {
6550 var _a, _b;
6551
6552 return (_b = (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.isEnabled()) !== null && _b !== void 0 ? _b : false;
6553 },
6554 enumerable: false,
6555 configurable: true
6556 });
6557 Object.defineProperty(__proto, "position", {
6558 /**
6559 * Current position value in {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} instance
6560 * @ko {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} 인스턴스 내부의 현재 좌표 값
6561 * @type {number}
6562 * @readonly
6563 */
6564 get: function () {
6565 var _a, _b;
6566
6567 return (_b = (_a = this._axes) === null || _a === void 0 ? void 0 : _a.get([POSITION_KEY])[POSITION_KEY]) !== null && _b !== void 0 ? _b : 0;
6568 },
6569 enumerable: false,
6570 configurable: true
6571 });
6572 Object.defineProperty(__proto, "range", {
6573 /**
6574 * Current range value in {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} instance
6575 * @ko {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html Axes} 인스턴스 내부의 현재 이동 범위 값
6576 * @type {number[]}
6577 * @readonly
6578 */
6579 get: function () {
6580 var _a, _b;
6581
6582 return (_b = (_a = this._axes) === null || _a === void 0 ? void 0 : _a.axis[POSITION_KEY].range) !== null && _b !== void 0 ? _b : [0, 0];
6583 },
6584 enumerable: false,
6585 configurable: true
6586 });
6587 Object.defineProperty(__proto, "bounce", {
6588 /**
6589 * Actual bounce size(px)
6590 * @ko 적용된 bounce 크기(px 단위)
6591 * @type {number[]}
6592 * @readonly
6593 */
6594 get: function () {
6595 var _a;
6596
6597 return (_a = this._axes) === null || _a === void 0 ? void 0 : _a.axis[POSITION_KEY].bounce;
6598 },
6599 enumerable: false,
6600 configurable: true
6601 });
6602 /**
6603 * Initialize AxesController
6604 * @ko AxesController를 초기화합니다
6605 * @param {Flicking} flicking An instance of Flicking
6606 * @chainable
6607 * @return {this}
6608 */
6609
6610 __proto.init = function (flicking) {
6611 var _a;
6612
6613 var _this = this;
6614
6615 this._flicking = flicking;
6616 this._axes = new Axes$1((_a = {}, _a[POSITION_KEY] = {
6617 range: [0, 0],
6618 circular: false,
6619 bounce: [0, 0]
6620 }, _a), {
6621 deceleration: flicking.deceleration,
6622 interruptable: flicking.interruptable,
6623 nested: flicking.nested,
6624 easing: flicking.easing
6625 });
6626 this._panInput = new PanInput(flicking.viewport.element, {
6627 inputType: flicking.inputType,
6628 iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
6629 scale: flicking.horizontal ? [-1, 0] : [0, -1],
6630 releaseOnScroll: true
6631 });
6632 var axes = this._axes;
6633 axes.connect(flicking.horizontal ? [POSITION_KEY, ""] : ["", POSITION_KEY], this._panInput);
6634
6635 var _loop_1 = function (key) {
6636 var eventType = EVENT[key];
6637 axes.on(eventType, function (e) {
6638 _this._stateMachine.fire(eventType, {
6639 flicking: flicking,
6640 axesEvent: e
6641 });
6642 });
6643 };
6644
6645 for (var key in EVENT) {
6646 _loop_1(key);
6647 }
6648
6649 return this;
6650 };
6651 /**
6652 * Destroy AxesController and return to initial state
6653 * @ko AxesController를 초기 상태로 되돌립니다
6654 * @return {void}
6655 */
6656
6657
6658 __proto.destroy = function () {
6659 var _a;
6660
6661 if (this._axes) {
6662 this.removePreventClickHandler();
6663
6664 this._axes.destroy();
6665 }
6666
6667 (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.destroy();
6668
6669 this._resetInternalValues();
6670 };
6671 /**
6672 * Enable input from the user (mouse/touch)
6673 * @ko 사용자의 입력(마우스/터치)를 활성화합니다
6674 * @chainable
6675 * @return {this}
6676 */
6677
6678
6679 __proto.enable = function () {
6680 var _a;
6681
6682 (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.enable();
6683 return this;
6684 };
6685 /**
6686 * Disable input from the user (mouse/touch)
6687 * @ko 사용자의 입력(마우스/터치)를 막습니다
6688 * @chainable
6689 * @return {this}
6690 */
6691
6692
6693 __proto.disable = function () {
6694 var _a;
6695
6696 (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.disable();
6697 return this;
6698 };
6699 /**
6700 * Releases ongoing user input (mouse/touch)
6701 * @ko 사용자의 현재 입력(마우스/터치)를 중단시킵니다
6702 * @chainable
6703 * @return {this}
6704 */
6705
6706
6707 __proto.release = function () {
6708 var _a;
6709
6710 (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.release();
6711 return this;
6712 };
6713 /**
6714 * Change the destination and duration of the animation currently playing
6715 * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
6716 * @param {number} position A position to move<ko>이동할 좌표</ko>
6717 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
6718 * @chainable
6719 * @return {this}
6720 */
6721
6722
6723 __proto.updateAnimation = function (position, duration) {
6724 var _a;
6725
6726 var _b;
6727
6728 this._animatingContext = __assign$2(__assign$2({}, this._animatingContext), {
6729 end: position
6730 });
6731 (_b = this._axes) === null || _b === void 0 ? void 0 : _b.updateAnimation({
6732 destPos: (_a = {}, _a[POSITION_KEY] = position, _a),
6733 duration: duration
6734 });
6735 return this;
6736 };
6737 /**
6738 * Stops the animation currently playing
6739 * @ko 재생 중인 애니메이션을 중단시킵니다
6740 * @chainable
6741 * @return {this}
6742 */
6743
6744
6745 __proto.stopAnimation = function () {
6746 var _a;
6747
6748 (_a = this._axes) === null || _a === void 0 ? void 0 : _a.stopAnimation();
6749 return this;
6750 };
6751 /**
6752 * Update {@link https://naver.github.io/egjs-axes/ @egjs/axes}'s state
6753 * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 상태를 갱신합니다
6754 * @chainable
6755 * @throws {FlickingError}
6756 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link AxesController#init init} is not called before
6757 * <ko>{@link AxesController#init init}이 이전에 호출되지 않은 경우</ko>
6758 * @return {this}
6759 */
6760
6761
6762 __proto.update = function (controlParams) {
6763 var _a;
6764
6765 var flicking = getFlickingAttached(this._flicking);
6766 var camera = flicking.camera;
6767 var axes = this._axes;
6768 var axis = axes.axis[POSITION_KEY];
6769 axis.circular = [controlParams.circular, controlParams.circular];
6770 axis.range = [controlParams.range.min, controlParams.range.max];
6771 axis.bounce = parseBounce(flicking.bounce, camera.size);
6772 axes.axisManager.set((_a = {}, _a[POSITION_KEY] = controlParams.position, _a));
6773 return this;
6774 };
6775 /**
6776 * Attach a handler to the camera element to prevent click events during animation
6777 * @ko 카메라 엘리먼트에 애니메이션 도중에 클릭 이벤트를 방지하는 핸들러를 부착합니다
6778 * @return {this}
6779 */
6780
6781
6782 __proto.addPreventClickHandler = function () {
6783 var flicking = getFlickingAttached(this._flicking);
6784 var axes = this._axes;
6785 var cameraEl = flicking.camera.element;
6786 axes.on(EVENT.HOLD, this._onAxesHold);
6787 axes.on(EVENT.CHANGE, this._onAxesChange);
6788 cameraEl.addEventListener("click", this._preventClickWhenDragged, true);
6789 return this;
6790 };
6791 /**
6792 * Detach a handler to the camera element to prevent click events during animation
6793 * @ko 카메라 엘리먼트에 애니메이션 도중에 클릭 이벤트를 방지하는 핸들러를 탈착합니다
6794 * @return {this}
6795 */
6796
6797
6798 __proto.removePreventClickHandler = function () {
6799 var flicking = getFlickingAttached(this._flicking);
6800 var axes = this._axes;
6801 var cameraEl = flicking.camera.element;
6802 axes.off(EVENT.HOLD, this._onAxesHold);
6803 axes.off(EVENT.CHANGE, this._onAxesChange);
6804 cameraEl.removeEventListener("click", this._preventClickWhenDragged, true);
6805 return this;
6806 };
6807 /**
6808 * Run Axes's {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#setTo setTo} using the given position
6809 * @ko Axes의 {@link https://naver.github.io/egjs-axes/release/latest/doc/eg.Axes.html#setTo setTo} 메소드를 주어진 좌표를 이용하여 수행합니다
6810 * @param {number} position A position to move<ko>이동할 좌표</ko>
6811 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
6812 * @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>
6813 * @throws {FlickingError}
6814 * |code|condition|
6815 * |---|---|
6816 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
6817 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
6818 * <ko>
6819 *
6820 * |code|condition|
6821 * |---|---|
6822 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
6823 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
6824 *
6825 * </ko>
6826 * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
6827 */
6828
6829
6830 __proto.animateTo = function (position, duration, axesEvent) {
6831 var _a;
6832
6833 var _this = this;
6834
6835 var _b;
6836
6837 var axes = this._axes;
6838 var state = this._stateMachine.state;
6839
6840 if (!axes) {
6841 return Promise.reject(new FlickingError(MESSAGE.NOT_ATTACHED_TO_FLICKING, CODE.NOT_ATTACHED_TO_FLICKING));
6842 }
6843
6844 var startPos = axes.get([POSITION_KEY])[POSITION_KEY];
6845
6846 if (startPos === position) {
6847 var flicking = getFlickingAttached(this._flicking);
6848 flicking.camera.lookAt(position);
6849
6850 if (state.targetPanel) {
6851 flicking.control.setActive(state.targetPanel, flicking.control.activePanel, (_b = axesEvent === null || axesEvent === void 0 ? void 0 : axesEvent.isTrusted) !== null && _b !== void 0 ? _b : false);
6852 }
6853
6854 return Promise.resolve();
6855 }
6856
6857 this._animatingContext = {
6858 start: startPos,
6859 end: position,
6860 offset: 0
6861 };
6862
6863 var animate = function () {
6864 var _a, _b;
6865
6866 var resetContext = function () {
6867 _this._animatingContext = {
6868 start: 0,
6869 end: 0,
6870 offset: 0
6871 };
6872 };
6873
6874 axes.once(EVENT.FINISH, resetContext);
6875
6876 if (axesEvent) {
6877 axesEvent.setTo((_a = {}, _a[POSITION_KEY] = position, _a), duration);
6878 } else {
6879 axes.setTo((_b = {}, _b[POSITION_KEY] = position, _b), duration);
6880 }
6881 };
6882
6883 if (duration === 0) {
6884 var flicking = getFlickingAttached(this._flicking);
6885 var camera = flicking.camera;
6886 animate();
6887 var newPos = flicking.circularEnabled ? circulatePosition(position, camera.range.min, camera.range.max) : position;
6888 axes.axisManager.set((_a = {}, _a[POSITION_KEY] = newPos, _a));
6889 return Promise.resolve();
6890 } else {
6891 return new Promise(function (resolve, reject) {
6892 var animationFinishHandler = function () {
6893 axes.off(EVENT.HOLD, interruptionHandler);
6894 resolve();
6895 };
6896
6897 var interruptionHandler = function () {
6898 axes.off(EVENT.FINISH, animationFinishHandler);
6899 reject(new FlickingError(MESSAGE.ANIMATION_INTERRUPTED, CODE.ANIMATION_INTERRUPTED));
6900 };
6901
6902 axes.once(EVENT.FINISH, animationFinishHandler);
6903 axes.once(EVENT.HOLD, interruptionHandler);
6904 animate();
6905 });
6906 }
6907 };
6908
6909 __proto._resetInternalValues = function () {
6910 this._flicking = null;
6911 this._axes = null;
6912 this._panInput = null;
6913 this._animatingContext = {
6914 start: 0,
6915 end: 0,
6916 offset: 0
6917 };
6918 this._dragged = false;
6919 };
6920
6921 return AxesController;
6922 }();
6923
6924 /**
6925 * A component that manages inputs and animation of Flicking
6926 * @ko Flicking의 입력 장치 & 애니메이션을 담당하는 컴포넌트
6927 */
6928
6929 var Control$1 =
6930 /*#__PURE__*/
6931 function () {
6932 /** */
6933 function Control() {
6934 this._flicking = null;
6935 this._controller = new AxesController();
6936 this._activePanel = null;
6937 }
6938
6939 var __proto = Control.prototype;
6940 Object.defineProperty(__proto, "controller", {
6941 /**
6942 * A controller that handles the {@link https://naver.github.io/egjs-axes/ @egjs/axes} events
6943 * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 이벤트를 처리하는 컨트롤러 컴포넌트
6944 * @type {AxesController}
6945 * @readonly
6946 */
6947 get: function () {
6948 return this._controller;
6949 },
6950 enumerable: false,
6951 configurable: true
6952 });
6953 Object.defineProperty(__proto, "activeIndex", {
6954 /**
6955 * Index number of the {@link Flicking#currentPanel currentPanel}
6956 * @ko {@link Flicking#currentPanel currentPanel}의 인덱스 번호
6957 * @type {number}
6958 * @default 0
6959 * @readonly
6960 */
6961 get: function () {
6962 var _a, _b;
6963
6964 return (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : -1;
6965 },
6966 enumerable: false,
6967 configurable: true
6968 });
6969 Object.defineProperty(__proto, "activePanel", {
6970 /**
6971 * An active panel
6972 * @ko 현재 선택된 패널
6973 * @type {Panel | null}
6974 * @readonly
6975 */
6976 get: function () {
6977 return this._activePanel;
6978 },
6979 enumerable: false,
6980 configurable: true
6981 });
6982 Object.defineProperty(__proto, "animating", {
6983 /**
6984 * Whether Flicking's animating
6985 * @ko 현재 애니메이션 동작 여부
6986 * @type {boolean}
6987 * @readonly
6988 */
6989 get: function () {
6990 return this._controller.state.animating;
6991 },
6992 enumerable: false,
6993 configurable: true
6994 });
6995 Object.defineProperty(__proto, "holding", {
6996 /**
6997 * Whether user is clicking or touching
6998 * @ko 현재 사용자가 클릭/터치중인지 여부
6999 * @type {boolean}
7000 * @readonly
7001 */
7002 get: function () {
7003 return this._controller.state.holding;
7004 },
7005 enumerable: false,
7006 configurable: true
7007 });
7008 /**
7009 * Initialize Control
7010 * @ko Control을 초기화합니다
7011 * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
7012 * @chainable
7013 * @return {this}
7014 */
7015
7016 __proto.init = function (flicking) {
7017 this._flicking = flicking;
7018
7019 this._controller.init(flicking);
7020
7021 return this;
7022 };
7023 /**
7024 * Destroy Control and return to initial state
7025 * @ko Control을 초기 상태로 되돌립니다
7026 * @return {void}
7027 */
7028
7029
7030 __proto.destroy = function () {
7031 this._controller.destroy();
7032
7033 this._flicking = null;
7034 this._activePanel = null;
7035 };
7036 /**
7037 * Enable input from the user (mouse/touch)
7038 * @ko 사용자의 입력(마우스/터치)를 활성화합니다
7039 * @chainable
7040 * @return {this}
7041 */
7042
7043
7044 __proto.enable = function () {
7045 this._controller.enable();
7046
7047 return this;
7048 };
7049 /**
7050 * Disable input from the user (mouse/touch)
7051 * @ko 사용자의 입력(마우스/터치)를 막습니다
7052 * @chainable
7053 * @return {this}
7054 */
7055
7056
7057 __proto.disable = function () {
7058 this._controller.disable();
7059
7060 return this;
7061 };
7062 /**
7063 * Releases ongoing user input (mouse/touch)
7064 * @ko 사용자의 현재 입력(마우스/터치)를 중단시킵니다
7065 * @chainable
7066 * @return {this}
7067 */
7068
7069
7070 __proto.release = function () {
7071 this._controller.release();
7072
7073 return this;
7074 };
7075 /**
7076 * Change the destination and duration of the animation currently playing
7077 * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
7078 * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
7079 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
7080 * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
7081 * @chainable
7082 * @throws {FlickingError}
7083 * {@link ERROR_CODE POSITION_NOT_REACHABLE} When the given panel is already removed or not in the Camera's {@link Camera#range range}
7084 * <ko>{@link ERROR_CODE POSITION_NOT_REACHABLE} 주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우</ko>
7085 * @return {this}
7086 */
7087
7088
7089 __proto.updateAnimation = function (panel, duration, direction) {
7090 var state = this._controller.state;
7091
7092 var position = this._getPosition(panel, direction !== null && direction !== void 0 ? direction : DIRECTION.NONE);
7093
7094 state.targetPanel = panel;
7095
7096 this._controller.updateAnimation(position, duration);
7097
7098 return this;
7099 };
7100 /**
7101 * Stops the animation currently playing
7102 * @ko 재생 중인 애니메이션을 중단시킵니다
7103 * @chainable
7104 * @return {this}
7105 */
7106
7107
7108 __proto.stopAnimation = function () {
7109 var state = this._controller.state;
7110 state.targetPanel = null;
7111
7112 this._controller.stopAnimation();
7113
7114 return this;
7115 };
7116 /**
7117 * Update position after resizing
7118 * @ko resize 이후에 position을 업데이트합니다
7119 * @param {number} progressInPanel Previous camera's progress in active panel before resize<ko>Resize 이전 현재 선택된 패널 내에서의 카메라 progress 값</ko>
7120 * @throws {FlickingError}
7121 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
7122 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
7123 * @chainable
7124 * @return {Promise<void>}
7125 */
7126
7127
7128 __proto.updatePosition = function (progressInPanel) {
7129 var flicking = getFlickingAttached(this._flicking);
7130 var camera = flicking.camera;
7131 var activePanel = this._activePanel;
7132
7133 if (activePanel) {
7134 camera.lookAt(camera.clampToReachablePosition(activePanel.position));
7135 }
7136 };
7137 /**
7138 * Update {@link Control#controller controller}'s state
7139 * @ko {@link Control#controller controller}의 내부 상태를 갱신합니다
7140 * @chainable
7141 * @return {this}
7142 */
7143
7144
7145 __proto.updateInput = function () {
7146 var flicking = getFlickingAttached(this._flicking);
7147 var camera = flicking.camera;
7148
7149 this._controller.update(camera.controlParams);
7150
7151 return this;
7152 };
7153 /**
7154 * Reset {@link Control#activePanel activePanel} to `null`
7155 * @ko {@link Control#activePanel activePanel}을 `null`로 초기화합니다
7156 * @chainable
7157 * @return {this}
7158 */
7159
7160
7161 __proto.resetActive = function () {
7162 this._activePanel = null;
7163 return this;
7164 };
7165 /**
7166 * Move {@link Camera} to the given panel
7167 * @ko {@link Camera}를 해당 패널 위로 이동합니다
7168 * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
7169 * @param {object} options An options object<ko>옵션 오브젝트</ko>
7170 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
7171 * @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}
7172 * <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>
7173 * @param {DIRECTION} [direction=DIRECTION.NONE] Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
7174 * @fires Flicking#moveStart
7175 * @fires Flicking#move
7176 * @fires Flicking#moveEnd
7177 * @fires Flicking#willChange
7178 * @fires Flicking#changed
7179 * @fires Flicking#willRestore
7180 * @fires Flicking#restored
7181 * @fires Flicking#needPanel
7182 * @fires Flicking#visibleChange
7183 * @fires Flicking#reachEdge
7184 * @throws {FlickingError}
7185 * |code|condition|
7186 * |---|---|
7187 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
7188 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
7189 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
7190 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
7191 * <ko>
7192 *
7193 * |code|condition|
7194 * |---|---|
7195 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
7196 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
7197 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
7198 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
7199 *
7200 * </ko>
7201 * @return {Promise<void>} A Promise which will be resolved after reaching the target panel<ko>해당 패널 도달시에 resolve되는 Promise</ko>
7202 */
7203
7204
7205 __proto.moveToPanel = function (panel, _a) {
7206 var duration = _a.duration,
7207 _b = _a.direction,
7208 direction = _b === void 0 ? DIRECTION.NONE : _b,
7209 axesEvent = _a.axesEvent;
7210 return __awaiter(this, void 0, void 0, function () {
7211 var position;
7212 return __generator(this, function (_c) {
7213 position = this._getPosition(panel, direction);
7214
7215 this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
7216
7217 return [2
7218 /*return*/
7219 , this._animateToPosition({
7220 position: position,
7221 duration: duration,
7222 newActivePanel: panel,
7223 axesEvent: axesEvent
7224 })];
7225 });
7226 });
7227 };
7228 /**
7229 * @internal
7230 */
7231
7232
7233 __proto.setActive = function (newActivePanel, prevActivePanel, isTrusted) {
7234 var _a;
7235
7236 var flicking = getFlickingAttached(this._flicking);
7237 this._activePanel = newActivePanel;
7238 flicking.camera.updateAdaptiveHeight();
7239
7240 if (newActivePanel !== prevActivePanel) {
7241 flicking.trigger(new ComponentEvent$1(EVENTS.CHANGED, {
7242 index: newActivePanel.index,
7243 panel: newActivePanel,
7244 prevIndex: (_a = prevActivePanel === null || prevActivePanel === void 0 ? void 0 : prevActivePanel.index) !== null && _a !== void 0 ? _a : -1,
7245 prevPanel: prevActivePanel,
7246 isTrusted: isTrusted,
7247 direction: prevActivePanel ? getDirection$1(prevActivePanel.position, newActivePanel.position) : DIRECTION.NONE
7248 }));
7249 } else {
7250 flicking.trigger(new ComponentEvent$1(EVENTS.RESTORED, {
7251 isTrusted: isTrusted
7252 }));
7253 }
7254 };
7255
7256 __proto._triggerIndexChangeEvent = function (panel, position, axesEvent) {
7257 var _a;
7258
7259 var flicking = getFlickingAttached(this._flicking);
7260 var triggeringEvent = panel !== this._activePanel ? EVENTS.WILL_CHANGE : EVENTS.WILL_RESTORE;
7261 var camera = flicking.camera;
7262 var activePanel = this._activePanel;
7263 var event = new ComponentEvent$1(triggeringEvent, {
7264 index: panel.index,
7265 panel: panel,
7266 isTrusted: (axesEvent === null || axesEvent === void 0 ? void 0 : axesEvent.isTrusted) || false,
7267 direction: getDirection$1((_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.position) !== null && _a !== void 0 ? _a : camera.position, position)
7268 });
7269 flicking.trigger(event);
7270
7271 if (event.isCanceled()) {
7272 throw new FlickingError(MESSAGE.STOP_CALLED_BY_USER, CODE.STOP_CALLED_BY_USER);
7273 }
7274 };
7275
7276 __proto._animateToPosition = function (_a) {
7277 var position = _a.position,
7278 duration = _a.duration,
7279 newActivePanel = _a.newActivePanel,
7280 axesEvent = _a.axesEvent;
7281 return __awaiter(this, void 0, void 0, function () {
7282 var flicking, animate, state;
7283
7284 var _this = this;
7285
7286 return __generator(this, function (_b) {
7287 flicking = getFlickingAttached(this._flicking);
7288
7289 animate = function () {
7290 return _this._controller.animateTo(position, duration, axesEvent);
7291 };
7292
7293 state = this._controller.state;
7294 state.targetPanel = newActivePanel;
7295
7296 if (duration <= 0) {
7297 return [2
7298 /*return*/
7299 , animate()];
7300 } else {
7301 return [2
7302 /*return*/
7303 , animate().then(function () {
7304 return __awaiter(_this, void 0, void 0, function () {
7305 return __generator(this, function (_a) {
7306 switch (_a.label) {
7307 case 0:
7308 return [4
7309 /*yield*/
7310 , flicking.renderer.render()];
7311
7312 case 1:
7313 _a.sent();
7314
7315 return [2
7316 /*return*/
7317 ];
7318 }
7319 });
7320 });
7321 }).catch(function (err) {
7322 if (axesEvent && err instanceof FlickingError && err.code === CODE.ANIMATION_INTERRUPTED) return;
7323 throw err;
7324 })];
7325 }
7326 });
7327 });
7328 };
7329
7330 __proto._getPosition = function (panel, direction) {
7331 if (direction === void 0) {
7332 direction = DIRECTION.NONE;
7333 }
7334
7335 var flicking = getFlickingAttached(this._flicking);
7336 var camera = flicking.camera;
7337 var position = panel.position;
7338 var nearestAnchor = camera.findNearestAnchor(position);
7339
7340 if (panel.removed || !nearestAnchor) {
7341 throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE);
7342 }
7343
7344 if (!camera.canReach(panel)) {
7345 // Override position & panel if that panel is not reachable
7346 position = nearestAnchor.position;
7347 panel = nearestAnchor.panel;
7348 } else if (flicking.circularEnabled) {
7349 // Circular mode is enabled, find nearest distance to panel
7350 var camPos_1 = this._controller.position; // Actual position of the Axes
7351
7352 var camRangeDiff = camera.rangeDiff;
7353 var possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
7354 if (direction === DIRECTION.NONE) return true;
7355 return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
7356 });
7357 position = possiblePositions.reduce(function (nearestPosition, pos) {
7358 if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
7359 return pos;
7360 } else {
7361 return nearestPosition;
7362 }
7363 }, Infinity);
7364 }
7365
7366 return position;
7367 };
7368
7369 return Control;
7370 }();
7371
7372 /**
7373 * A data component that has actual position where the camera should be stopped at
7374 * @ko 카메라가 정지해야하는 실제 위치를 담고 있는 데이터 컴포넌트
7375 */
7376 var AnchorPoint =
7377 /*#__PURE__*/
7378 function () {
7379 /**
7380 * @param {object} options An options object<ko>옵션 객체</ko>
7381 * @param {number} [options.index] Index of AnchorPoint<ko>AnchorPoint의 인덱스</ko>
7382 * @param {number} [options.position] Position of AnchorPoint<ko>AnchorPoint의 좌표</ko>
7383 * @param {Panel} [options.panel] A {@link Panel} instance AnchorPoint is referencing to<ko>AnchorPoint가 참조하고 있는 {@link Panel}</ko>
7384 */
7385 function AnchorPoint(_a) {
7386 var index = _a.index,
7387 position = _a.position,
7388 panel = _a.panel;
7389 this._index = index;
7390 this._pos = position;
7391 this._panel = panel;
7392 }
7393
7394 var __proto = AnchorPoint.prototype;
7395 Object.defineProperty(__proto, "index", {
7396 /**
7397 * Index of AnchorPoint
7398 * @ko AnchorPoint의 인덱스
7399 * @type {number}
7400 * @readonly
7401 */
7402 get: function () {
7403 return this._index;
7404 },
7405 enumerable: false,
7406 configurable: true
7407 });
7408 Object.defineProperty(__proto, "position", {
7409 /**
7410 * Position of AnchorPoint
7411 * @ko AnchorPoint의 좌표
7412 * @type {number}
7413 * @readonly
7414 */
7415 get: function () {
7416 return this._pos;
7417 },
7418 enumerable: false,
7419 configurable: true
7420 });
7421 Object.defineProperty(__proto, "panel", {
7422 /**
7423 * A {@link Panel} instance AnchorPoint is referencing to
7424 * @ko AnchorPoint가 참조하고 있는 {@link Panel}
7425 * @type {Panel}
7426 * @readonly
7427 */
7428 get: function () {
7429 return this._panel;
7430 },
7431 enumerable: false,
7432 configurable: true
7433 });
7434 return AnchorPoint;
7435 }();
7436
7437 /**
7438 * A {@link Control} that uses a release momentum to choose destination panel
7439 * @ko 입력을 중단한 시점의 가속도에 영향받아 도달할 패널을 계산하는 이동 방식을 사용하는 {@link Control}
7440 */
7441
7442 var SnapControl =
7443 /*#__PURE__*/
7444 function (_super) {
7445 __extends$2(SnapControl, _super);
7446 /** */
7447
7448
7449 function SnapControl(_a) {
7450 var _b = (_a === void 0 ? {} : _a).count,
7451 count = _b === void 0 ? Infinity : _b;
7452
7453 var _this = _super.call(this) || this;
7454
7455 _this._count = count;
7456 return _this;
7457 }
7458
7459 var __proto = SnapControl.prototype;
7460 Object.defineProperty(__proto, "count", {
7461 /**
7462 * Maximum number of panels can go after release
7463 * @ko 입력 중단 이후 통과하여 이동할 수 있는 패널의 최대 갯수
7464 * @type {number}
7465 * @default Infinity
7466 */
7467 get: function () {
7468 return this._count;
7469 },
7470 set: function (val) {
7471 this._count = val;
7472 },
7473 enumerable: false,
7474 configurable: true
7475 });
7476 /**
7477 * Move {@link Camera} to the given position
7478 * @ko {@link Camera}를 주어진 좌표로 이동합니다
7479 * @param {number} position The target position to move<ko>이동할 좌표</ko>
7480 * @param {number} duration Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
7481 * @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}
7482 * <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>
7483 * @fires Flicking#moveStart
7484 * @fires Flicking#move
7485 * @fires Flicking#moveEnd
7486 * @fires Flicking#willChange
7487 * @fires Flicking#changed
7488 * @fires Flicking#willRestore
7489 * @fires Flicking#restored
7490 * @fires Flicking#needPanel
7491 * @fires Flicking#visibleChange
7492 * @fires Flicking#reachEdge
7493 * @throws {FlickingError}
7494 * |code|condition|
7495 * |---|---|
7496 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
7497 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
7498 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
7499 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
7500 * <ko>
7501 *
7502 * |code|condition|
7503 * |---|---|
7504 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
7505 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
7506 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
7507 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
7508 *
7509 * </ko>
7510 * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
7511 */
7512
7513 __proto.moveToPosition = function (position, duration, axesEvent) {
7514 var flicking = getFlickingAttached(this._flicking);
7515 var camera = flicking.camera;
7516 var activeAnchor = camera.findActiveAnchor();
7517 var anchorAtCamera = camera.findNearestAnchor(camera.position);
7518 var state = this._controller.state;
7519
7520 if (!activeAnchor || !anchorAtCamera) {
7521 return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
7522 }
7523
7524 var snapThreshold = this._calcSnapThreshold(position, activeAnchor);
7525
7526 var posDelta = flicking.animating ? state.delta : position - camera.position;
7527 var absPosDelta = Math.abs(posDelta);
7528 var snapDelta = axesEvent && axesEvent.delta[POSITION_KEY] !== 0 ? Math.abs(axesEvent.delta[POSITION_KEY]) : absPosDelta;
7529 var targetAnchor;
7530
7531 if (snapDelta >= snapThreshold && snapDelta > 0) {
7532 // Move to anchor at position
7533 targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
7534 } else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
7535 // Move to the adjacent panel
7536 targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
7537 } else {
7538 // Restore to active panel
7539 return this.moveToPanel(activeAnchor.panel, {
7540 duration: duration,
7541 axesEvent: axesEvent
7542 });
7543 }
7544
7545 this._triggerIndexChangeEvent(targetAnchor.panel, position, axesEvent);
7546
7547 return this._animateToPosition({
7548 position: camera.clampToReachablePosition(targetAnchor.position),
7549 duration: duration,
7550 newActivePanel: targetAnchor.panel,
7551 axesEvent: axesEvent
7552 });
7553 };
7554
7555 __proto._findSnappedAnchor = function (position, anchorAtCamera) {
7556 var flicking = getFlickingAttached(this._flicking);
7557 var camera = flicking.camera;
7558 var count = this._count;
7559 var currentPos = camera.position;
7560 var clampedPosition = camera.clampToReachablePosition(position);
7561 var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
7562
7563 if (!anchorAtCamera || !anchorAtPosition) {
7564 throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE);
7565 }
7566
7567 if (!isFinite(count)) {
7568 return anchorAtPosition;
7569 }
7570
7571 var panelCount = flicking.panelCount;
7572 var anchors = camera.anchorPoints;
7573 var loopCount = Math.sign(position - currentPos) * Math.floor(Math.abs(position - currentPos) / camera.rangeDiff);
7574
7575 if (position > currentPos && anchorAtPosition.index < anchorAtCamera.index || anchorAtPosition.position > anchorAtCamera.position && anchorAtPosition.index === anchorAtCamera.index) {
7576 loopCount += 1;
7577 } else if (position < currentPos && anchorAtPosition.index > anchorAtCamera.index || anchorAtPosition.position < anchorAtCamera.position && anchorAtPosition.index === anchorAtCamera.index) {
7578 loopCount -= 1;
7579 }
7580
7581 var circularIndexOffset = loopCount * panelCount;
7582 var anchorAtPositionIndex = anchorAtPosition.index + circularIndexOffset;
7583
7584 if (Math.abs(anchorAtPositionIndex - anchorAtCamera.index) <= count) {
7585 var anchor = anchors[anchorAtPosition.index];
7586 return new AnchorPoint({
7587 index: anchor.index,
7588 position: anchor.position + loopCount * camera.rangeDiff,
7589 panel: anchor.panel
7590 });
7591 }
7592
7593 if (flicking.circularEnabled) {
7594 var targetAnchor = anchors[circulateIndex(anchorAtCamera.index + Math.sign(position - currentPos) * count, panelCount)];
7595 var loop = Math.floor(count / panelCount);
7596
7597 if (position > currentPos && targetAnchor.index < anchorAtCamera.index) {
7598 loop += 1;
7599 } else if (position < currentPos && targetAnchor.index > anchorAtCamera.index) {
7600 loop -= 1;
7601 }
7602
7603 return new AnchorPoint({
7604 index: targetAnchor.index,
7605 position: targetAnchor.position + loop * camera.rangeDiff,
7606 panel: targetAnchor.panel
7607 });
7608 } else {
7609 return anchors[clamp$1(anchorAtCamera.index + Math.sign(position - currentPos) * count, 0, anchors.length - 1)];
7610 }
7611 };
7612
7613 __proto._findAdjacentAnchor = function (position, posDelta, anchorAtCamera) {
7614 var _a;
7615
7616 var flicking = getFlickingAttached(this._flicking);
7617 var camera = flicking.camera;
7618
7619 if (camera.circularEnabled) {
7620 var anchorIncludePosition = camera.findAnchorIncludePosition(position);
7621
7622 if (anchorIncludePosition && anchorIncludePosition.position !== anchorAtCamera.position) {
7623 return anchorIncludePosition;
7624 }
7625 }
7626
7627 var adjacentAnchor = (_a = posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) !== null && _a !== void 0 ? _a : anchorAtCamera;
7628 return adjacentAnchor;
7629 };
7630
7631 __proto._calcSnapThreshold = function (position, activeAnchor) {
7632 var isNextDirection = position > activeAnchor.position;
7633 var panel = activeAnchor.panel;
7634 var panelSize = panel.size;
7635 var alignPos = panel.alignPosition; // Minimum distance needed to decide prev/next panel as nearest
7636
7637 /*
7638 * | Prev | Next |
7639 * |<------>|<------------>|
7640 * [ |<-Anchor ]
7641 */
7642
7643 return isNextDirection ? panelSize - alignPos + panel.margin.next : alignPos + panel.margin.prev;
7644 };
7645
7646 return SnapControl;
7647 }(Control$1);
7648
7649 /**
7650 * A {@link Control} that can be scrolled freely without alignment
7651 * @ko 패널이 정해진 지점에 정렬되지 않고, 자유롭게 스크롤할 수 있는 이동 방식을 사용하는 {@link Control}
7652 */
7653
7654 var FreeControl =
7655 /*#__PURE__*/
7656 function (_super) {
7657 __extends$2(FreeControl, _super);
7658 /** */
7659
7660
7661 function FreeControl(_a) {
7662 var _b = (_a === void 0 ? {} : _a).stopAtEdge,
7663 stopAtEdge = _b === void 0 ? true : _b;
7664
7665 var _this = _super.call(this) || this;
7666
7667 _this._stopAtEdge = stopAtEdge;
7668 return _this;
7669 }
7670
7671 var __proto = FreeControl.prototype;
7672 Object.defineProperty(__proto, "stopAtEdge", {
7673 /**
7674 * Make scroll animation to stop at the start/end of the scroll area, not going out the bounce area
7675 * @ko 스크롤 애니메이션을 스크롤 영역의 시작과 끝부분에서 멈추도록 하여, 바운스 영역을 넘어가지 않도록 합니다
7676 * @type {boolean}
7677 * @default true
7678 */
7679 get: function () {
7680 return this._stopAtEdge;
7681 },
7682 set: function (val) {
7683 this._stopAtEdge = val;
7684 },
7685 enumerable: false,
7686 configurable: true
7687 });
7688 /**
7689 * Update position after resizing
7690 * @ko resize 이후에 position을 업데이트합니다
7691 * @param {number} progressInPanel Previous camera's progress in active panel before resize<ko>Resize 이전 현재 선택된 패널 내에서의 카메라 progress 값</ko>
7692 * @throws {FlickingError}
7693 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
7694 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
7695 * @chainable
7696 * @return {Promise<void>}
7697 */
7698
7699 __proto.updatePosition = function (progressInPanel) {
7700 var flicking = getFlickingAttached(this._flicking);
7701 var camera = flicking.camera;
7702 var activePanel = this._activePanel;
7703
7704 if (activePanel) {
7705 var panelRange = activePanel.range;
7706 var newPosition = panelRange.min + (panelRange.max - panelRange.min) * progressInPanel;
7707 camera.lookAt(camera.clampToReachablePosition(newPosition));
7708 }
7709 };
7710 /**
7711 * Move {@link Camera} to the given position
7712 * @ko {@link Camera}를 주어진 좌표로 이동합니다
7713 * @param {number} position The target position to move<ko>이동할 좌표</ko>
7714 * @param {number} duration Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
7715 * @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}
7716 * <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>
7717 * @fires Flicking#moveStart
7718 * @fires Flicking#move
7719 * @fires Flicking#moveEnd
7720 * @fires Flicking#willChange
7721 * @fires Flicking#changed
7722 * @fires Flicking#willRestore
7723 * @fires Flicking#restored
7724 * @fires Flicking#needPanel
7725 * @fires Flicking#visibleChange
7726 * @fires Flicking#reachEdge
7727 * @throws {FlickingError}
7728 * |code|condition|
7729 * |---|---|
7730 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
7731 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
7732 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
7733 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
7734 * <ko>
7735 *
7736 * |code|condition|
7737 * |---|---|
7738 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
7739 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
7740 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
7741 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
7742 *
7743 * </ko>
7744 * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
7745 */
7746
7747
7748 __proto.moveToPosition = function (position, duration, axesEvent) {
7749 var flicking = getFlickingAttached(this._flicking);
7750 var camera = flicking.camera;
7751 var targetPos = camera.clampToReachablePosition(position);
7752 var anchorAtPosition = camera.findAnchorIncludePosition(targetPos);
7753
7754 if (!anchorAtPosition) {
7755 return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
7756 }
7757
7758 var targetPanel = anchorAtPosition.panel; // Trigger only change event
7759
7760 if (targetPanel !== this._activePanel) {
7761 this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
7762 }
7763
7764 return this._animateToPosition({
7765 position: this._stopAtEdge ? targetPos : position,
7766 duration: duration,
7767 newActivePanel: targetPanel,
7768 axesEvent: axesEvent
7769 });
7770 };
7771
7772 return FreeControl;
7773 }(Control$1);
7774
7775 /**
7776 * A {@link Control} that allow you to select the maximum number of panels to move at a time
7777 * @ko 한번에 최대로 이동할 패널의 개수를 선택 가능한 {@link Control}
7778 */
7779
7780 var StrictControl =
7781 /*#__PURE__*/
7782 function (_super) {
7783 __extends$2(StrictControl, _super);
7784 /** */
7785
7786
7787 function StrictControl(_a) {
7788 var _b = (_a === void 0 ? {} : _a).count,
7789 count = _b === void 0 ? 1 : _b;
7790
7791 var _this = _super.call(this) || this;
7792
7793 _this.setActive = function (newActivePanel, prevActivePanel, isTrusted) {
7794 _super.prototype.setActive.call(_this, newActivePanel, prevActivePanel, isTrusted);
7795
7796 _this.updateInput();
7797 };
7798
7799 _this._count = count;
7800
7801 _this._resetIndexRange();
7802
7803 return _this;
7804 }
7805
7806 var __proto = StrictControl.prototype;
7807 Object.defineProperty(__proto, "count", {
7808 /**
7809 * Maximum number of panels that can be moved at a time
7810 * @ko 최대로 움직일 수 있는 패널의 개수
7811 * @type {number}
7812 * @default 1
7813 */
7814 get: function () {
7815 return this._count;
7816 },
7817 set: function (val) {
7818 this._count = val;
7819 },
7820 enumerable: false,
7821 configurable: true
7822 });
7823 /**
7824 * Destroy Control and return to initial state
7825 * @ko Control을 초기 상태로 되돌립니다
7826 * @return {void}
7827 */
7828
7829 __proto.destroy = function () {
7830 _super.prototype.destroy.call(this);
7831
7832 this._resetIndexRange();
7833 };
7834 /**
7835 * Update {@link Control#controller controller}'s state
7836 * @ko {@link Control#controller controller}의 내부 상태를 갱신합니다
7837 * @chainable
7838 * @return {this}
7839 */
7840
7841
7842 __proto.updateInput = function () {
7843 var _a;
7844
7845 var flicking = getFlickingAttached(this._flicking);
7846 var camera = flicking.camera;
7847 var renderer = flicking.renderer;
7848 var controller = this._controller;
7849 var controlParams = camera.controlParams;
7850 var count = this._count;
7851 var activePanel = controller.state.animating ? (_a = camera.findNearestAnchor(camera.position)) === null || _a === void 0 ? void 0 : _a.panel : this._activePanel;
7852
7853 if (!activePanel) {
7854 controller.update(controlParams);
7855
7856 this._resetIndexRange();
7857
7858 return this;
7859 }
7860
7861 var cameraRange = controlParams.range;
7862 var currentPos = activePanel.position;
7863 var currentIndex = activePanel.index;
7864 var panelCount = renderer.panelCount;
7865 var prevPanelIndex = currentIndex - count;
7866 var nextPanelIndex = currentIndex + count;
7867
7868 if (prevPanelIndex < 0) {
7869 prevPanelIndex = flicking.circularEnabled ? getMinusCompensatedIndex((prevPanelIndex + 1) % panelCount - 1, panelCount) : clamp$1(prevPanelIndex, 0, panelCount - 1);
7870 }
7871
7872 if (nextPanelIndex >= panelCount) {
7873 nextPanelIndex = flicking.circularEnabled ? nextPanelIndex % panelCount : clamp$1(nextPanelIndex, 0, panelCount - 1);
7874 }
7875
7876 var prevPanel = renderer.panels[prevPanelIndex];
7877 var nextPanel = renderer.panels[nextPanelIndex];
7878 var prevPos = Math.max(prevPanel.position, cameraRange.min);
7879 var nextPos = Math.min(nextPanel.position, cameraRange.max);
7880
7881 if (prevPos > currentPos) {
7882 prevPos -= camera.rangeDiff;
7883 }
7884
7885 if (nextPos < currentPos) {
7886 nextPos += camera.rangeDiff;
7887 }
7888
7889 controlParams.range = {
7890 min: prevPos,
7891 max: nextPos
7892 };
7893
7894 if (controlParams.circular) {
7895 if (controlParams.position < prevPos) {
7896 controlParams.position += camera.rangeDiff;
7897 }
7898
7899 if (controlParams.position > nextPos) {
7900 controlParams.position -= camera.rangeDiff;
7901 }
7902 }
7903
7904 controlParams.circular = false;
7905 controller.update(controlParams);
7906 this._indexRange = {
7907 min: prevPanel.index,
7908 max: nextPanel.index
7909 };
7910 return this;
7911 };
7912
7913 __proto.moveToPanel = function (panel, options) {
7914 return __awaiter(this, void 0, void 0, function () {
7915 var flicking, camera, controller;
7916 return __generator(this, function (_a) {
7917 flicking = getFlickingAttached(this._flicking);
7918 camera = flicking.camera;
7919 controller = this._controller;
7920 controller.update(camera.controlParams);
7921 return [2
7922 /*return*/
7923 , _super.prototype.moveToPanel.call(this, panel, options)];
7924 });
7925 });
7926 };
7927 /**
7928 * Move {@link Camera} to the given position
7929 * @ko {@link Camera}를 주어진 좌표로 이동합니다
7930 * @param {number} position The target position to move<ko>이동할 좌표</ko>
7931 * @param {number} duration Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
7932 * @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}
7933 * <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>
7934 * @fires Flicking#moveStart
7935 * @fires Flicking#move
7936 * @fires Flicking#moveEnd
7937 * @fires Flicking#willChange
7938 * @fires Flicking#changed
7939 * @fires Flicking#willRestore
7940 * @fires Flicking#restored
7941 * @fires Flicking#needPanel
7942 * @fires Flicking#visibleChange
7943 * @fires Flicking#reachEdge
7944 * @throws {FlickingError}
7945 * |code|condition|
7946 * |---|---|
7947 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|When the given panel is already removed or not in the Camera's {@link Camera#range range}|
7948 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|When {@link Control#init init} is not called before|
7949 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
7950 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the animation is interrupted by user input|
7951 * <ko>
7952 *
7953 * |code|condition|
7954 * |---|---|
7955 * |{@link ERROR_CODE POSITION_NOT_REACHABLE}|주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우|
7956 * |{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING}|{@link Control#init init}이 이전에 호출되지 않은 경우|
7957 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
7958 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
7959 *
7960 * </ko>
7961 * @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
7962 */
7963
7964
7965 __proto.moveToPosition = function (position, duration, axesEvent) {
7966 var flicking = getFlickingAttached(this._flicking);
7967 var camera = flicking.camera;
7968 var activePanel = this._activePanel;
7969 var axesRange = this._controller.range;
7970 var indexRange = this._indexRange;
7971 var cameraRange = camera.range;
7972 var state = this._controller.state;
7973 var clampedPosition = clamp$1(camera.clampToReachablePosition(position), axesRange[0], axesRange[1]);
7974 var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
7975
7976 if (!anchorAtPosition || !activePanel) {
7977 return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
7978 }
7979
7980 var prevPos = activePanel.position;
7981 var posDelta = flicking.animating ? state.delta : position - camera.position;
7982 var isOverThreshold = Math.abs(posDelta) >= flicking.threshold;
7983 var adjacentAnchor = position > prevPos ? camera.getNextAnchor(anchorAtPosition) : camera.getPrevAnchor(anchorAtPosition);
7984 var targetPos;
7985 var targetPanel;
7986 var anchors = camera.anchorPoints;
7987 var firstAnchor = anchors[0];
7988 var lastAnchor = anchors[anchors.length - 1];
7989 var shouldBounceToFirst = position <= cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
7990 var shouldBounceToLast = position >= cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
7991 var isAdjacent = adjacentAnchor && (indexRange.min <= indexRange.max ? isBetween(adjacentAnchor.index, indexRange.min, indexRange.max) : adjacentAnchor.index >= indexRange.min || adjacentAnchor.index <= indexRange.max);
7992
7993 if (shouldBounceToFirst || shouldBounceToLast) {
7994 // In bounce area
7995 var targetAnchor = position < cameraRange.min ? firstAnchor : lastAnchor;
7996 targetPanel = targetAnchor.panel;
7997 targetPos = targetAnchor.position;
7998 } else if (isOverThreshold && anchorAtPosition.position !== activePanel.position) {
7999 // Move to anchor at position
8000 targetPanel = anchorAtPosition.panel;
8001 targetPos = anchorAtPosition.position;
8002 } else if (isOverThreshold && isAdjacent) {
8003 // Move to adjacent anchor
8004 targetPanel = adjacentAnchor.panel;
8005 targetPos = adjacentAnchor.position;
8006 } else {
8007 // Restore to active panel
8008 targetPos = camera.clampToReachablePosition(activePanel.position);
8009 targetPanel = activePanel;
8010 }
8011
8012 this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
8013
8014 return this._animateToPosition({
8015 position: targetPos,
8016 duration: duration,
8017 newActivePanel: targetPanel,
8018 axesEvent: axesEvent
8019 });
8020 };
8021
8022 __proto._resetIndexRange = function () {
8023 this._indexRange = {
8024 min: 0,
8025 max: 0
8026 };
8027 };
8028
8029 return StrictControl;
8030 }(Control$1);
8031
8032 /*
8033 * Copyright (c) 2015 NAVER Corp.
8034 * egjs projects are licensed under the MIT license
8035 */
8036
8037 var Control = {
8038 __proto__: null,
8039 Control: Control$1,
8040 SnapControl: SnapControl,
8041 FreeControl: FreeControl,
8042 StrictControl: StrictControl,
8043 AxesController: AxesController,
8044 State: State,
8045 IdleState: IdleState,
8046 HoldingState: HoldingState,
8047 DraggingState: DraggingState,
8048 AnimatingState: AnimatingState,
8049 DisabledState: DisabledState,
8050 StateMachine: StateMachine
8051 };
8052
8053 /**
8054 * A mode of camera
8055 */
8056
8057 var CameraMode =
8058 /*#__PURE__*/
8059 function () {
8060 /** */
8061 function CameraMode(flicking) {
8062 this._flicking = flicking;
8063 }
8064
8065 var __proto = CameraMode.prototype;
8066
8067 __proto.getAnchors = function () {
8068 var panels = this._flicking.renderer.panels;
8069 return panels.map(function (panel, index) {
8070 return new AnchorPoint({
8071 index: index,
8072 position: panel.position,
8073 panel: panel
8074 });
8075 });
8076 };
8077
8078 __proto.findAnchorIncludePosition = function (position) {
8079 var anchors = this._flicking.camera.anchorPoints;
8080 var anchorsIncludingPosition = anchors.filter(function (anchor) {
8081 return anchor.panel.includePosition(position, true);
8082 });
8083 return anchorsIncludingPosition.reduce(function (nearest, anchor) {
8084 if (!nearest) return anchor;
8085 return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
8086 }, null);
8087 };
8088
8089 __proto.findNearestAnchor = function (position) {
8090 var anchors = this._flicking.camera.anchorPoints;
8091 if (anchors.length <= 0) return null;
8092 var prevDist = Infinity;
8093
8094 for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
8095 var anchor = anchors[anchorIdx];
8096 var dist = Math.abs(anchor.position - position);
8097
8098 if (dist > prevDist) {
8099 // Return previous anchor
8100 return anchors[anchorIdx - 1];
8101 }
8102
8103 prevDist = dist;
8104 } // Return last anchor
8105
8106
8107 return anchors[anchors.length - 1];
8108 };
8109
8110 __proto.clampToReachablePosition = function (position) {
8111 var camera = this._flicking.camera;
8112 var range = camera.range;
8113 return clamp$1(position, range.min, range.max);
8114 };
8115
8116 __proto.getCircularOffset = function () {
8117 return 0;
8118 };
8119
8120 __proto.canReach = function (panel) {
8121 var camera = this._flicking.camera;
8122 var range = camera.range;
8123 if (panel.removed) return false;
8124 var panelPos = panel.position;
8125 return panelPos >= range.min && panelPos <= range.max;
8126 };
8127
8128 __proto.canSee = function (panel) {
8129 var camera = this._flicking.camera;
8130 var visibleRange = camera.visibleRange; // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
8131
8132 return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
8133 };
8134
8135 return CameraMode;
8136 }();
8137
8138 var LinearCameraMode =
8139 /*#__PURE__*/
8140 function (_super) {
8141 __extends$2(LinearCameraMode, _super);
8142
8143 function LinearCameraMode() {
8144 return _super !== null && _super.apply(this, arguments) || this;
8145 }
8146
8147 var __proto = LinearCameraMode.prototype;
8148
8149 __proto.checkAvailability = function () {
8150 // It's always available
8151 return true;
8152 };
8153
8154 __proto.getRange = function () {
8155 var _a, _b;
8156
8157 var renderer = this._flicking.renderer;
8158 var firstPanel = renderer.getPanel(0);
8159 var lastPanel = renderer.getPanel(renderer.panelCount - 1);
8160 return {
8161 min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
8162 max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
8163 };
8164 };
8165
8166 return LinearCameraMode;
8167 }(CameraMode);
8168
8169 /**
8170 * A {@link Camera} mode that connects the last panel and the first panel, enabling continuous loop
8171 * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera} 모드
8172 */
8173
8174 var CircularCameraMode =
8175 /*#__PURE__*/
8176 function (_super) {
8177 __extends$2(CircularCameraMode, _super);
8178
8179 function CircularCameraMode() {
8180 return _super !== null && _super.apply(this, arguments) || this;
8181 }
8182
8183 var __proto = CircularCameraMode.prototype;
8184
8185 __proto.checkAvailability = function () {
8186 var flicking = this._flicking;
8187 var renderer = flicking.renderer;
8188 var panels = renderer.panels;
8189
8190 if (panels.length <= 0) {
8191 return false;
8192 }
8193
8194 var firstPanel = panels[0];
8195 var lastPanel = panels[panels.length - 1];
8196 var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
8197 var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
8198 var visibleSize = flicking.camera.size;
8199 var panelSizeSum = lastPanelNext - firstPanelPrev;
8200 var canSetCircularMode = panels.every(function (panel) {
8201 return panelSizeSum - panel.size >= visibleSize;
8202 });
8203 return canSetCircularMode;
8204 };
8205
8206 __proto.getRange = function () {
8207 var flicking = this._flicking;
8208 var panels = flicking.renderer.panels;
8209
8210 if (panels.length <= 0) {
8211 return {
8212 min: 0,
8213 max: 0
8214 };
8215 }
8216
8217 var firstPanel = panels[0];
8218 var lastPanel = panels[panels.length - 1];
8219 var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
8220 var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
8221 return {
8222 min: firstPanelPrev,
8223 max: lastPanelNext
8224 };
8225 };
8226
8227 __proto.getAnchors = function () {
8228 var flicking = this._flicking;
8229 var panels = flicking.renderer.panels;
8230 return panels.map(function (panel, index) {
8231 return new AnchorPoint({
8232 index: index,
8233 position: panel.position,
8234 panel: panel
8235 });
8236 });
8237 };
8238
8239 __proto.findNearestAnchor = function (position) {
8240 var camera = this._flicking.camera;
8241 var anchors = camera.anchorPoints;
8242 if (anchors.length <= 0) return null;
8243 var camRange = camera.range;
8244 var minDist = Infinity;
8245 var minDistIndex = -1;
8246
8247 for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
8248 var anchor = anchors[anchorIdx];
8249 var dist = Math.min(Math.abs(anchor.position - position), Math.abs(anchor.position - camRange.min + camRange.max - position), Math.abs(position - camRange.min + camRange.max - anchor.position));
8250
8251 if (dist < minDist) {
8252 minDist = dist;
8253 minDistIndex = anchorIdx;
8254 }
8255 } // Return last anchor
8256
8257
8258 return anchors[minDistIndex];
8259 };
8260
8261 __proto.findAnchorIncludePosition = function (position) {
8262 var camera = this._flicking.camera;
8263 var range = camera.range;
8264 var anchors = camera.anchorPoints;
8265 var rangeDiff = camera.rangeDiff;
8266 var anchorCount = anchors.length;
8267 var positionInRange = circulatePosition(position, range.min, range.max);
8268
8269 var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
8270
8271 if (anchorCount > 0 && (position === range.min || position === range.max)) {
8272 var possibleAnchors = [anchorInRange, new AnchorPoint({
8273 index: 0,
8274 position: anchors[0].position + rangeDiff,
8275 panel: anchors[0].panel
8276 }), new AnchorPoint({
8277 index: anchorCount - 1,
8278 position: anchors[anchorCount - 1].position - rangeDiff,
8279 panel: anchors[anchorCount - 1].panel
8280 })].filter(function (anchor) {
8281 return !!anchor;
8282 });
8283 anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
8284 if (!nearest) return anchor;
8285 return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
8286 }, null);
8287 }
8288
8289 if (!anchorInRange) return null;
8290
8291 if (position < range.min) {
8292 var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
8293 return new AnchorPoint({
8294 index: anchorInRange.index,
8295 position: anchorInRange.position + rangeDiff * loopCount,
8296 panel: anchorInRange.panel
8297 });
8298 } else if (position > range.max) {
8299 var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
8300 return new AnchorPoint({
8301 index: anchorInRange.index,
8302 position: anchorInRange.position + rangeDiff * loopCount,
8303 panel: anchorInRange.panel
8304 });
8305 }
8306
8307 return anchorInRange;
8308 };
8309
8310 __proto.getCircularOffset = function () {
8311 var flicking = this._flicking;
8312 var camera = flicking.camera;
8313 if (!camera.circularEnabled) return 0;
8314 var toggled = flicking.panels.filter(function (panel) {
8315 return panel.toggled;
8316 });
8317 var toggledPrev = toggled.filter(function (panel) {
8318 return panel.toggleDirection === DIRECTION.PREV;
8319 });
8320 var toggledNext = toggled.filter(function (panel) {
8321 return panel.toggleDirection === DIRECTION.NEXT;
8322 });
8323 return this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
8324 };
8325
8326 __proto.clampToReachablePosition = function (position) {
8327 // Basically all position is reachable for circular camera
8328 return position;
8329 };
8330
8331 __proto.canReach = function (panel) {
8332 if (panel.removed) return false; // Always reachable on circular mode
8333
8334 return true;
8335 };
8336
8337 __proto.canSee = function (panel) {
8338 var camera = this._flicking.camera;
8339 var range = camera.range;
8340 var rangeDiff = camera.rangeDiff;
8341 var visibleRange = camera.visibleRange;
8342
8343 var visibleInCurrentRange = _super.prototype.canSee.call(this, panel); // Check looped visible area for circular case
8344
8345
8346 if (visibleRange.min < range.min) {
8347 return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
8348 } else if (visibleRange.max > range.max) {
8349 return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
8350 }
8351
8352 return visibleInCurrentRange;
8353 };
8354
8355 __proto._calcPanelAreaSum = function (panels) {
8356 return panels.reduce(function (sum, panel) {
8357 return sum + panel.sizeIncludingMargin;
8358 }, 0);
8359 };
8360
8361 return CircularCameraMode;
8362 }(CameraMode);
8363
8364 var BoundCameraMode =
8365 /*#__PURE__*/
8366 function (_super) {
8367 __extends$2(BoundCameraMode, _super);
8368
8369 function BoundCameraMode() {
8370 return _super !== null && _super.apply(this, arguments) || this;
8371 }
8372
8373 var __proto = BoundCameraMode.prototype;
8374
8375 __proto.checkAvailability = function () {
8376 var flicking = this._flicking;
8377 var renderer = flicking.renderer;
8378 var firstPanel = renderer.getPanel(0);
8379 var lastPanel = renderer.getPanel(renderer.panelCount - 1);
8380
8381 if (!firstPanel || !lastPanel) {
8382 return false;
8383 }
8384
8385 var viewportSize = flicking.camera.size;
8386 var firstPanelPrev = firstPanel.range.min;
8387 var lastPanelNext = lastPanel.range.max;
8388 var panelAreaSize = lastPanelNext - firstPanelPrev;
8389 var isBiggerThanViewport = viewportSize < panelAreaSize;
8390 return isBiggerThanViewport;
8391 };
8392
8393 __proto.getRange = function () {
8394 var flicking = this._flicking;
8395 var renderer = flicking.renderer;
8396 var alignPos = flicking.camera.alignPosition;
8397 var firstPanel = renderer.getPanel(0);
8398 var lastPanel = renderer.getPanel(renderer.panelCount - 1);
8399
8400 if (!firstPanel || !lastPanel) {
8401 return {
8402 min: 0,
8403 max: 0
8404 };
8405 }
8406
8407 var viewportSize = flicking.camera.size;
8408 var firstPanelPrev = firstPanel.range.min;
8409 var lastPanelNext = lastPanel.range.max;
8410 var panelAreaSize = lastPanelNext - firstPanelPrev;
8411 var isBiggerThanViewport = viewportSize < panelAreaSize;
8412 var firstPos = firstPanelPrev + alignPos;
8413 var lastPos = lastPanelNext - viewportSize + alignPos;
8414
8415 if (isBiggerThanViewport) {
8416 return {
8417 min: firstPos,
8418 max: lastPos
8419 };
8420 } else {
8421 var align = flicking.camera.align;
8422 var alignVal = typeof align === "object" ? align.camera : align;
8423 var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
8424 return {
8425 min: pos,
8426 max: pos
8427 };
8428 }
8429 };
8430
8431 __proto.getAnchors = function () {
8432 var flicking = this._flicking;
8433 var camera = flicking.camera;
8434 var panels = flicking.renderer.panels;
8435
8436 if (panels.length <= 0) {
8437 return [];
8438 }
8439
8440 var range = flicking.camera.range;
8441 var reachablePanels = panels.filter(function (panel) {
8442 return camera.canReach(panel);
8443 });
8444
8445 if (reachablePanels.length > 0) {
8446 var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
8447 var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
8448 var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
8449 var newAnchors = reachablePanels.map(function (panel, idx) {
8450 return new AnchorPoint({
8451 index: idx + indexOffset_1,
8452 position: panel.position,
8453 panel: panel
8454 });
8455 });
8456
8457 if (shouldPrependBoundAnchor) {
8458 newAnchors.splice(0, 0, new AnchorPoint({
8459 index: 0,
8460 position: range.min,
8461 panel: panels[reachablePanels[0].index - 1]
8462 }));
8463 }
8464
8465 if (shouldAppendBoundAnchor) {
8466 newAnchors.push(new AnchorPoint({
8467 index: newAnchors.length,
8468 position: range.max,
8469 panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
8470 }));
8471 }
8472
8473 return newAnchors;
8474 } else if (range.min !== range.max) {
8475 // There're more than 2 panels
8476 var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
8477
8478 var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
8479 var panelAtMax = panelAtMin.next();
8480 return [new AnchorPoint({
8481 index: 0,
8482 position: range.min,
8483 panel: panelAtMin
8484 }), new AnchorPoint({
8485 index: 1,
8486 position: range.max,
8487 panel: panelAtMax
8488 })];
8489 } else {
8490 return [new AnchorPoint({
8491 index: 0,
8492 position: range.min,
8493 panel: this._findNearestPanel(range.min, panels)
8494 })];
8495 }
8496 };
8497
8498 __proto.findAnchorIncludePosition = function (position) {
8499 var camera = this._flicking.camera;
8500 var range = camera.range;
8501 var anchors = camera.anchorPoints;
8502 if (anchors.length <= 0) return null;
8503
8504 if (position <= range.min) {
8505 return anchors[0];
8506 } else if (position >= range.max) {
8507 return anchors[anchors.length - 1];
8508 } else {
8509 return _super.prototype.findAnchorIncludePosition.call(this, position);
8510 }
8511 };
8512
8513 __proto._findNearestPanel = function (pos, panels) {
8514 var prevDist = Infinity;
8515
8516 for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
8517 var panel = panels[panelIdx];
8518 var dist = Math.abs(panel.position - pos);
8519
8520 if (dist > prevDist) {
8521 // Return previous anchor
8522 return panels[panelIdx - 1];
8523 }
8524
8525 prevDist = dist;
8526 } // Return last anchor
8527
8528
8529 return panels[panels.length - 1];
8530 };
8531
8532 return BoundCameraMode;
8533 }(CameraMode);
8534
8535 /**
8536 * A component that manages actual movement inside the viewport
8537 * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
8538 */
8539
8540 var Camera$1 =
8541 /*#__PURE__*/
8542 function () {
8543 /** */
8544 function Camera(flicking, _a) {
8545 var _this = this;
8546
8547 var _b = (_a === void 0 ? {} : _a).align,
8548 align = _b === void 0 ? ALIGN.CENTER : _b;
8549
8550 this._checkTranslateSupport = function () {
8551 var e_1, _a;
8552
8553 var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
8554 var supportedStyle = document.documentElement.style;
8555 var transformName = "";
8556
8557 try {
8558 for (var transforms_1 = __values$1(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
8559 var prefixedTransform = transforms_1_1.value;
8560
8561 if (prefixedTransform in supportedStyle) {
8562 transformName = prefixedTransform;
8563 }
8564 }
8565 } catch (e_1_1) {
8566 e_1 = {
8567 error: e_1_1
8568 };
8569 } finally {
8570 try {
8571 if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
8572 } finally {
8573 if (e_1) throw e_1.error;
8574 }
8575 }
8576
8577 if (!transformName) {
8578 throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
8579 }
8580
8581 _this._transform = transformName;
8582 };
8583
8584 this._flicking = flicking;
8585
8586 this._resetInternalValues(); // Options
8587
8588
8589 this._align = align;
8590 }
8591
8592 var __proto = Camera.prototype;
8593 Object.defineProperty(__proto, "element", {
8594 // Internal states getter
8595
8596 /**
8597 * The camera element(`.flicking-camera`)
8598 * @ko 카메라 엘리먼트(`.flicking-camera`)
8599 * @type {HTMLElement}
8600 * @readonly
8601 */
8602 get: function () {
8603 return this._el;
8604 },
8605 enumerable: false,
8606 configurable: true
8607 });
8608 Object.defineProperty(__proto, "children", {
8609 /**
8610 * An array of the child elements of the camera element(`.flicking-camera`)
8611 * @ko 카메라 엘리먼트(`.flicking-camera`)의 자식 엘리먼트 배열
8612 * @type {HTMLElement[]}
8613 * @readonly
8614 */
8615 get: function () {
8616 return toArray$2(this._el.children);
8617 },
8618 enumerable: false,
8619 configurable: true
8620 });
8621 Object.defineProperty(__proto, "position", {
8622 /**
8623 * Current position of the camera
8624 * @ko Camera의 현재 좌표
8625 * @type {number}
8626 * @readonly
8627 */
8628 get: function () {
8629 return this._position;
8630 },
8631 enumerable: false,
8632 configurable: true
8633 });
8634 Object.defineProperty(__proto, "alignPosition", {
8635 /**
8636 * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
8637 * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
8638 * @type {number}
8639 * @readonly
8640 */
8641 get: function () {
8642 return this._alignPos;
8643 },
8644 enumerable: false,
8645 configurable: true
8646 });
8647 Object.defineProperty(__proto, "offset", {
8648 /**
8649 * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
8650 * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
8651 * @type {number}
8652 * @default 0
8653 * @readonly
8654 */
8655 get: function () {
8656 return this._offset - this._circularOffset;
8657 },
8658 enumerable: false,
8659 configurable: true
8660 });
8661 Object.defineProperty(__proto, "circularEnabled", {
8662 /**
8663 * Whether the `circular` option is enabled.
8664 * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
8665 * @ko {@link Flicking#circular circular} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
8666 * {@link Flicking#circular circular} 옵션은 패널의 크기의 합이 충분하지 않을 경우 비활성화됩니다.
8667 * @type {boolean}
8668 * @default false
8669 * @readonly
8670 */
8671 get: function () {
8672 return this._circularEnabled;
8673 },
8674 enumerable: false,
8675 configurable: true
8676 });
8677 Object.defineProperty(__proto, "mode", {
8678 /**
8679 * A current camera mode
8680 * @type {CameraMode}
8681 * @readonly
8682 */
8683 get: function () {
8684 return this._mode;
8685 },
8686 enumerable: false,
8687 configurable: true
8688 });
8689 Object.defineProperty(__proto, "range", {
8690 /**
8691 * A range that Camera's {@link Camera#position position} can reach
8692 * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
8693 * @type {object}
8694 * @property {number} min A minimum position<ko>최소 위치</ko>
8695 * @property {number} max A maximum position<ko>최대 위치</ko>
8696 * @readonly
8697 */
8698 get: function () {
8699 return this._range;
8700 },
8701 enumerable: false,
8702 configurable: true
8703 });
8704 Object.defineProperty(__proto, "rangeDiff", {
8705 /**
8706 * A difference between Camera's minimum and maximum position that can reach
8707 * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
8708 * @type {number}
8709 * @readonly
8710 */
8711 get: function () {
8712 return this._range.max - this._range.min;
8713 },
8714 enumerable: false,
8715 configurable: true
8716 });
8717 Object.defineProperty(__proto, "visiblePanels", {
8718 /**
8719 * An array of visible panels from the current position
8720 * @ko 현재 보이는 패널들의 배열
8721 * @type {Panel[]}
8722 * @readonly
8723 */
8724 get: function () {
8725 return this._visiblePanels;
8726 },
8727 enumerable: false,
8728 configurable: true
8729 });
8730 Object.defineProperty(__proto, "visibleRange", {
8731 /**
8732 * A range of the visible area from the current position
8733 * @ko 현재 위치에서 보이는 범위
8734 * @type {object}
8735 * @property {number} min A minimum position<ko>최소 위치</ko>
8736 * @property {number} min A maximum position<ko>최대 위치</ko>
8737 * @readonly
8738 */
8739 get: function () {
8740 return {
8741 min: this._position - this._alignPos,
8742 max: this._position - this._alignPos + this.size
8743 };
8744 },
8745 enumerable: false,
8746 configurable: true
8747 });
8748 Object.defineProperty(__proto, "anchorPoints", {
8749 /**
8750 * An array of {@link AnchorPoint}s that Camera can be stopped at
8751 * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
8752 * @type {AnchorPoint[]}
8753 * @readonly
8754 */
8755 get: function () {
8756 return this._anchors;
8757 },
8758 enumerable: false,
8759 configurable: true
8760 });
8761 Object.defineProperty(__proto, "controlParams", {
8762 /**
8763 * A current parameters of the Camera for updating {@link AxesController}
8764 * @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
8765 * @type {ControlParams}
8766 * @readonly
8767 */
8768 get: function () {
8769 return {
8770 range: this._range,
8771 position: this._position,
8772 circular: this._circularEnabled
8773 };
8774 },
8775 enumerable: false,
8776 configurable: true
8777 });
8778 Object.defineProperty(__proto, "atEdge", {
8779 /**
8780 * A Boolean value indicating whether Camera's over the minimum or maximum position reachable
8781 * @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
8782 * @type {boolean}
8783 * @readonly
8784 */
8785 get: function () {
8786 return this._position <= this._range.min || this._position >= this._range.max;
8787 },
8788 enumerable: false,
8789 configurable: true
8790 });
8791 Object.defineProperty(__proto, "size", {
8792 /**
8793 * Return the size of the viewport
8794 * @ko 뷰포트 크기를 반환합니다
8795 * @type {number}
8796 * @readonly
8797 */
8798 get: function () {
8799 var flicking = this._flicking;
8800 return flicking ? flicking.horizontal ? flicking.viewport.width : flicking.viewport.height : 0;
8801 },
8802 enumerable: false,
8803 configurable: true
8804 });
8805 Object.defineProperty(__proto, "progress", {
8806 /**
8807 * Return the camera's position progress from the first panel to last panel
8808 * Range is from 0 to last panel's index
8809 * @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
8810 * 범위는 0부터 마지막 패널의 인덱스까지입니다
8811 * @type {number}
8812 * @readonly
8813 */
8814 get: function () {
8815 var flicking = this._flicking;
8816 var position = this._position + this._offset;
8817 var nearestAnchor = this.findNearestAnchor(this._position);
8818
8819 if (!flicking || !nearestAnchor) {
8820 return NaN;
8821 }
8822
8823 var nearestPanel = nearestAnchor.panel;
8824 var panelPos = nearestPanel.position + nearestPanel.offset;
8825 var bounceSize = flicking.control.controller.bounce;
8826 var _a = this.range,
8827 prevRange = _a.min,
8828 nextRange = _a.max;
8829 var rangeDiff = this.rangeDiff;
8830
8831 if (position === panelPos) {
8832 return nearestPanel.index;
8833 }
8834
8835 if (position < panelPos) {
8836 var prevPanel = nearestPanel.prev();
8837 var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
8838
8839 if (prevPosition > panelPos) {
8840 prevPosition -= rangeDiff;
8841 }
8842
8843 return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
8844 } else {
8845 var nextPanel = nearestPanel.next();
8846 var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1]; // Looped
8847
8848 if (nextPosition < panelPos) {
8849 nextPosition += rangeDiff;
8850 }
8851
8852 return nearestPanel.index + getProgress(position, panelPos, nextPosition);
8853 }
8854 },
8855 enumerable: false,
8856 configurable: true
8857 });
8858 Object.defineProperty(__proto, "align", {
8859 // Options Getter
8860
8861 /**
8862 * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
8863 * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
8864 * @type {ALIGN | string | number}
8865 */
8866 get: function () {
8867 return this._align;
8868 },
8869 // Options Setter
8870 set: function (val) {
8871 this._align = val;
8872 },
8873 enumerable: false,
8874 configurable: true
8875 });
8876 /**
8877 * Initialize Camera
8878 * @ko Camera를 초기화합니다
8879 * @throws {FlickingError}
8880 * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
8881 * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
8882 * @return {this}
8883 */
8884
8885 __proto.init = function () {
8886 var viewportEl = this._flicking.viewport.element;
8887 checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
8888 this._el = viewportEl.firstElementChild;
8889
8890 this._checkTranslateSupport();
8891
8892 this._updateMode();
8893
8894 return this;
8895 };
8896 /**
8897 * Destroy Camera and return to initial state
8898 * @ko Camera를 초기 상태로 되돌립니다
8899 * @return {void}
8900 */
8901
8902
8903 __proto.destroy = function () {
8904 this._resetInternalValues();
8905
8906 return this;
8907 };
8908 /**
8909 * Move to the given position and apply CSS transform
8910 * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
8911 * @param {number} pos A new position<ko>움직일 위치</ko>
8912 * @throws {FlickingError}
8913 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
8914 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
8915 * @return {this}
8916 */
8917
8918
8919 __proto.lookAt = function (pos) {
8920 var _this = this;
8921
8922 var flicking = getFlickingAttached(this._flicking);
8923 var prevPos = this._position;
8924 this._position = pos;
8925
8926 var toggled = this._togglePanels(prevPos, pos);
8927
8928 this._refreshVisiblePanels();
8929
8930 this._checkNeedPanel();
8931
8932 this._checkReachEnd(prevPos, pos);
8933
8934 if (toggled) {
8935 void flicking.renderer.render().then(function () {
8936 _this.updateOffset();
8937 });
8938 } else {
8939 this.applyTransform();
8940 }
8941 };
8942 /**
8943 * Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
8944 * If it does not exist, return `null` instead
8945 * @ko 주어진 {@link AnchorPoint}의 이전 {@link AnchorPoint}를 반환합니다
8946 * 존재하지 않을 경우 `null`을 반환합니다
8947 * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
8948 * @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
8949 */
8950
8951
8952 __proto.getPrevAnchor = function (anchor) {
8953 if (!this._circularEnabled || anchor.index !== 0) {
8954 return this._anchors[anchor.index - 1] || null;
8955 } else {
8956 var anchors = this._anchors;
8957 var rangeDiff = this.rangeDiff;
8958 var lastAnchor = anchors[anchors.length - 1];
8959 return new AnchorPoint({
8960 index: lastAnchor.index,
8961 position: lastAnchor.position - rangeDiff,
8962 panel: lastAnchor.panel
8963 });
8964 }
8965 };
8966 /**
8967 * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
8968 * If it does not exist, return `null` instead
8969 * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
8970 * 존재하지 않을 경우 `null`을 반환합니다
8971 * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
8972 * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
8973 */
8974
8975
8976 __proto.getNextAnchor = function (anchor) {
8977 var anchors = this._anchors;
8978
8979 if (!this._circularEnabled || anchor.index !== anchors.length - 1) {
8980 return anchors[anchor.index + 1] || null;
8981 } else {
8982 var rangeDiff = this.rangeDiff;
8983 var firstAnchor = anchors[0];
8984 return new AnchorPoint({
8985 index: firstAnchor.index,
8986 position: firstAnchor.position + rangeDiff,
8987 panel: firstAnchor.panel
8988 });
8989 }
8990 };
8991 /**
8992 * Return the camera's position progress in the panel below
8993 * Value is from 0 to 1 when the camera's inside panel
8994 * Value can be lower than 0 or bigger than 1 when it's in the margin area
8995 * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
8996 * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
8997 * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
8998 */
8999
9000
9001 __proto.getProgressInPanel = function (panel) {
9002 var panelRange = panel.range;
9003 return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
9004 };
9005 /**
9006 * Return {@link AnchorPoint} that includes given position
9007 * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
9008 * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
9009 * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
9010 * @param {number} position A position to check<ko>확인할 좌표</ko>
9011 * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
9012 */
9013
9014
9015 __proto.findAnchorIncludePosition = function (position) {
9016 return this._mode.findAnchorIncludePosition(position);
9017 };
9018 /**
9019 * Return {@link AnchorPoint} nearest to given position
9020 * If there're no {@link AnchorPoint}s, return `null` instead
9021 * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
9022 * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
9023 * @param {number} position A position to check<ko>확인할 좌표</ko>
9024 * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
9025 */
9026
9027
9028 __proto.findNearestAnchor = function (position) {
9029 return this._mode.findNearestAnchor(position);
9030 };
9031 /**
9032 * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
9033 * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
9034 * @return {AnchorPoint | null}
9035 */
9036
9037
9038 __proto.findActiveAnchor = function () {
9039 var flicking = getFlickingAttached(this._flicking);
9040 var activeIndex = flicking.control.activeIndex;
9041 return find$1(this._anchors, function (anchor) {
9042 return anchor.panel.index === activeIndex;
9043 });
9044 };
9045 /**
9046 * Clamp the given position between camera's range
9047 * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
9048 * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
9049 * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
9050 */
9051
9052
9053 __proto.clampToReachablePosition = function (position) {
9054 return this._mode.clampToReachablePosition(position);
9055 };
9056 /**
9057 * Check whether the given panel is inside of the Camera's range
9058 * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
9059 * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
9060 * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
9061 */
9062
9063
9064 __proto.canReach = function (panel) {
9065 return this._mode.canReach(panel);
9066 };
9067 /**
9068 * Check whether the given panel element is visible at the current position
9069 * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
9070 * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
9071 * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
9072 */
9073
9074
9075 __proto.canSee = function (panel) {
9076 return this._mode.canSee(panel);
9077 };
9078 /**
9079 * Update {@link Camera#range range} of Camera
9080 * @ko Camera의 {@link Camera#range range}를 업데이트합니다
9081 * @method
9082 * @abstract
9083 * @memberof Camera
9084 * @instance
9085 * @name updateRange
9086 * @chainable
9087 * @throws {FlickingError}
9088 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
9089 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
9090 * @return {this}
9091 */
9092
9093
9094 __proto.updateRange = function () {
9095 var flicking = getFlickingAttached(this._flicking);
9096 var renderer = flicking.renderer;
9097 var panels = renderer.panels;
9098
9099 this._updateMode();
9100
9101 this._range = this._mode.getRange();
9102
9103 if (this._circularEnabled) {
9104 panels.forEach(function (panel) {
9105 return panel.updateCircularToggleDirection();
9106 });
9107 }
9108
9109 return this;
9110 };
9111 /**
9112 * Update Camera's {@link Camera#alignPosition alignPosition}
9113 * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
9114 * @chainable
9115 * @return {this}
9116 */
9117
9118
9119 __proto.updateAlignPos = function () {
9120 var align = this._align;
9121 var alignVal = typeof align === "object" ? align.camera : align;
9122 this._alignPos = parseAlign$1(alignVal, this.size);
9123 return this;
9124 };
9125 /**
9126 * Update Camera's {@link Camera#anchorPoints anchorPoints}
9127 * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
9128 * @throws {FlickingError}
9129 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
9130 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
9131 * @chainable
9132 * @return {this}
9133 */
9134
9135
9136 __proto.updateAnchors = function () {
9137 this._anchors = this._mode.getAnchors();
9138 return this;
9139 };
9140 /**
9141 * Update Viewport's height to active panel's height
9142 * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
9143 * @throws {FlickingError}
9144 * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
9145 * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
9146 * @chainable
9147 * @return {this}
9148 */
9149
9150
9151 __proto.updateAdaptiveHeight = function () {
9152 var flicking = getFlickingAttached(this._flicking);
9153 var activePanel = flicking.control.activePanel;
9154 if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
9155 flicking.viewport.setSize({
9156 height: activePanel.height
9157 });
9158 };
9159 /**
9160 * Update current offset of the camera
9161 * @ko 현재 카메라의 오프셋을 업데이트합니다
9162 * @chainable
9163 * @return {this}
9164 */
9165
9166
9167 __proto.updateOffset = function () {
9168 var flicking = getFlickingAttached(this._flicking);
9169 var position = this._position;
9170 var unRenderedPanels = flicking.panels.filter(function (panel) {
9171 return !panel.rendered;
9172 });
9173 this._offset = unRenderedPanels.filter(function (panel) {
9174 return panel.position + panel.offset < position;
9175 }).reduce(function (offset, panel) {
9176 return offset + panel.sizeIncludingMargin;
9177 }, 0);
9178 this._circularOffset = this._mode.getCircularOffset();
9179 this.applyTransform();
9180 return this;
9181 };
9182 /**
9183 * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
9184 * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
9185 * @chainable
9186 * @return {this}
9187 */
9188
9189
9190 __proto.resetNeedPanelHistory = function () {
9191 this._needPanelTriggered = {
9192 prev: false,
9193 next: false
9194 };
9195 return this;
9196 };
9197 /**
9198 * Apply "transform" style with the current position to camera element
9199 * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
9200 * @return {this}
9201 */
9202
9203
9204 __proto.applyTransform = function () {
9205 var el = this._el;
9206 var flicking = getFlickingAttached(this._flicking);
9207 var renderer = flicking.renderer;
9208 if (renderer.rendering) return this;
9209 var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
9210 el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
9211 return this;
9212 };
9213
9214 __proto._resetInternalValues = function () {
9215 this._position = 0;
9216 this._alignPos = 0;
9217 this._offset = 0;
9218 this._circularOffset = 0;
9219 this._circularEnabled = false;
9220 this._range = {
9221 min: 0,
9222 max: 0
9223 };
9224 this._visiblePanels = [];
9225 this._anchors = [];
9226 this._needPanelTriggered = {
9227 prev: false,
9228 next: false
9229 };
9230 };
9231
9232 __proto._refreshVisiblePanels = function () {
9233 var _this = this;
9234
9235 var flicking = getFlickingAttached(this._flicking);
9236 var panels = flicking.renderer.panels;
9237 var newVisiblePanels = panels.filter(function (panel) {
9238 return _this.canSee(panel);
9239 });
9240 var prevVisiblePanels = this._visiblePanels;
9241 this._visiblePanels = newVisiblePanels;
9242 var added = newVisiblePanels.filter(function (panel) {
9243 return !includes(prevVisiblePanels, panel);
9244 });
9245 var removed = prevVisiblePanels.filter(function (panel) {
9246 return !includes(newVisiblePanels, panel);
9247 });
9248
9249 if (added.length > 0 || removed.length > 0) {
9250 void flicking.renderer.render().then(function () {
9251 flicking.trigger(new ComponentEvent$1(EVENTS.VISIBLE_CHANGE, {
9252 added: added,
9253 removed: removed,
9254 visiblePanels: newVisiblePanels
9255 }));
9256 });
9257 }
9258 };
9259
9260 __proto._checkNeedPanel = function () {
9261 var needPanelTriggered = this._needPanelTriggered;
9262 if (needPanelTriggered.prev && needPanelTriggered.next) return;
9263 var flicking = getFlickingAttached(this._flicking);
9264 var panels = flicking.renderer.panels;
9265
9266 if (panels.length <= 0) {
9267 if (!needPanelTriggered.prev) {
9268 flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
9269 direction: DIRECTION.PREV
9270 }));
9271 needPanelTriggered.prev = true;
9272 }
9273
9274 if (!needPanelTriggered.next) {
9275 flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
9276 direction: DIRECTION.NEXT
9277 }));
9278 needPanelTriggered.next = true;
9279 }
9280
9281 return;
9282 }
9283
9284 var cameraPosition = this._position;
9285 var cameraSize = this.size;
9286 var cameraRange = this._range;
9287 var needPanelThreshold = flicking.needPanelThreshold;
9288 var cameraPrev = cameraPosition - this._alignPos;
9289 var cameraNext = cameraPrev + cameraSize;
9290 var firstPanel = panels[0];
9291 var lastPanel = panels[panels.length - 1];
9292
9293 if (!needPanelTriggered.prev) {
9294 var firstPanelPrev = firstPanel.range.min;
9295
9296 if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
9297 flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
9298 direction: DIRECTION.PREV
9299 }));
9300 needPanelTriggered.prev = true;
9301 }
9302 }
9303
9304 if (!needPanelTriggered.next) {
9305 var lastPanelNext = lastPanel.range.max;
9306
9307 if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
9308 flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
9309 direction: DIRECTION.NEXT
9310 }));
9311 needPanelTriggered.next = true;
9312 }
9313 }
9314 };
9315
9316 __proto._checkReachEnd = function (prevPos, newPos) {
9317 var flicking = getFlickingAttached(this._flicking);
9318 var range = this._range;
9319 var wasBetweenRange = prevPos > range.min && prevPos < range.max;
9320 var isBetweenRange = newPos > range.min && newPos < range.max;
9321 if (!wasBetweenRange || isBetweenRange) return;
9322 var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
9323 flicking.trigger(new ComponentEvent$1(EVENTS.REACH_EDGE, {
9324 direction: direction
9325 }));
9326 };
9327
9328 __proto._updateMode = function () {
9329 var flicking = getFlickingAttached(this._flicking);
9330
9331 if (flicking.circular) {
9332 var circularMode = new CircularCameraMode(flicking);
9333 var canSetCircularMode = circularMode.checkAvailability();
9334
9335 if (canSetCircularMode) {
9336 this._mode = circularMode;
9337 } else {
9338 var fallbackMode = flicking.circularFallback;
9339 this._mode = fallbackMode === CIRCULAR_FALLBACK.BOUND ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
9340 }
9341
9342 this._circularEnabled = canSetCircularMode;
9343 } else {
9344 this._mode = flicking.bound ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
9345 }
9346 };
9347
9348 __proto._togglePanels = function (prevPos, pos) {
9349 if (pos === prevPos) return false;
9350 var flicking = getFlickingAttached(this._flicking);
9351 var panels = flicking.renderer.panels;
9352 var toggled = panels.map(function (panel) {
9353 return panel.toggle(prevPos, pos);
9354 });
9355 return toggled.some(function (isToggled) {
9356 return isToggled;
9357 });
9358 };
9359
9360 return Camera;
9361 }();
9362
9363 /*
9364 * Copyright (c) 2015 NAVER Corp.
9365 * egjs projects are licensed under the MIT license
9366 */
9367
9368 var Camera = {
9369 __proto__: null,
9370 Camera: Camera$1,
9371 LinearCameraMode: LinearCameraMode,
9372 CircularCameraMode: CircularCameraMode,
9373 BoundCameraMode: BoundCameraMode
9374 };
9375
9376 /*
9377 Copyright (c) 2020-present NAVER Corp.
9378 name: @egjs/imready
9379 license: MIT
9380 author: NAVER Corp.
9381 repository: https://github.com/naver/egjs-imready
9382 version: 1.3.0
9383 */
9384
9385 /*! *****************************************************************************
9386 Copyright (c) Microsoft Corporation.
9387
9388 Permission to use, copy, modify, and/or distribute this software for any
9389 purpose with or without fee is hereby granted.
9390
9391 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9392 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9393 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9394 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
9395 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
9396 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
9397 PERFORMANCE OF THIS SOFTWARE.
9398 ***************************************************************************** */
9399
9400 /* global Reflect, Promise */
9401 var extendStatics = function (d, b) {
9402 extendStatics = Object.setPrototypeOf || {
9403 __proto__: []
9404 } instanceof Array && function (d, b) {
9405 d.__proto__ = b;
9406 } || function (d, b) {
9407 for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
9408 };
9409
9410 return extendStatics(d, b);
9411 };
9412
9413 function __extends(d, b) {
9414 extendStatics(d, b);
9415
9416 function __() {
9417 this.constructor = d;
9418 }
9419
9420 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9421 }
9422 var __assign = function () {
9423 __assign = Object.assign || function __assign(t) {
9424 for (var s, i = 1, n = arguments.length; i < n; i++) {
9425 s = arguments[i];
9426
9427 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9428 }
9429
9430 return t;
9431 };
9432
9433 return __assign.apply(this, arguments);
9434 };
9435 function __spreadArrays() {
9436 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
9437
9438 for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
9439
9440 return r;
9441 }
9442
9443 /*
9444 egjs-imready
9445 Copyright (c) 2020-present NAVER Corp.
9446 MIT license
9447 */
9448 var isWindow = typeof window !== "undefined";
9449 var ua = isWindow ? window.navigator.userAgent : "";
9450 var SUPPORT_COMPUTEDSTYLE = isWindow ? !!("getComputedStyle" in window) : false;
9451 var IS_IE = /MSIE|Trident|Windows Phone|Edge/.test(ua);
9452 var SUPPORT_ADDEVENTLISTENER = isWindow ? !!("addEventListener" in document) : false;
9453 var WIDTH = "width";
9454 var HEIGHT = "height";
9455
9456 function getAttribute(el, name) {
9457 return el.getAttribute(name) || "";
9458 }
9459 function toArray(arr) {
9460 return [].slice.call(arr);
9461 }
9462 function hasSizeAttribute(target, prefix) {
9463 if (prefix === void 0) {
9464 prefix = "data-";
9465 }
9466
9467 return !!target.getAttribute(prefix + "width");
9468 }
9469 function hasLoadingAttribute(target, prefix) {
9470 if (prefix === void 0) {
9471 prefix = "data-";
9472 }
9473
9474 return "loading" in target && target.getAttribute("loading") === "lazy" || !!target.getAttribute(prefix + "lazy");
9475 }
9476 function hasSkipAttribute(target, prefix) {
9477 if (prefix === void 0) {
9478 prefix = "data-";
9479 }
9480
9481 return !!target.getAttribute(prefix + "skip");
9482 }
9483 function addEvent(element, type, handler) {
9484 if (SUPPORT_ADDEVENTLISTENER) {
9485 element.addEventListener(type, handler, false);
9486 } else if (element.attachEvent) {
9487 element.attachEvent("on" + type, handler);
9488 } else {
9489 element["on" + type] = handler;
9490 }
9491 }
9492 function removeEvent(element, type, handler) {
9493 if (element.removeEventListener) {
9494 element.removeEventListener(type, handler, false);
9495 } else if (element.detachEvent) {
9496 element.detachEvent("on" + type, handler);
9497 } else {
9498 element["on" + type] = null;
9499 }
9500 }
9501 function innerWidth(el) {
9502 return getSize(el, "Width");
9503 }
9504 function innerHeight(el) {
9505 return getSize(el, "Height");
9506 }
9507 function getStyles(el) {
9508 return (SUPPORT_COMPUTEDSTYLE ? window.getComputedStyle(el) : el.currentStyle) || {};
9509 }
9510
9511 function getSize(el, name) {
9512 var size = el["client" + name] || el["offset" + name];
9513 return parseFloat(size || getStyles(el)[name.toLowerCase()]) || 0;
9514 }
9515
9516 function getContentElements(element, tags, prefix) {
9517 var skipElements = toArray(element.querySelectorAll(__spreadArrays(["[" + prefix + "skip] [" + prefix + "width]"], tags.map(function (tag) {
9518 return ["[" + prefix + "skip] " + tag, tag + "[" + prefix + "skip]", "[" + prefix + "width] " + tag].join(", ");
9519 })).join(", ")));
9520 return toArray(element.querySelectorAll("[" + prefix + "width], " + tags.join(", "))).filter(function (el) {
9521 return skipElements.indexOf(el) === -1;
9522 });
9523 }
9524
9525 /*
9526 egjs-imready
9527 Copyright (c) 2020-present NAVER Corp.
9528 MIT license
9529 */
9530 var elements = [];
9531 function addAutoSizer(element, prefix) {
9532 !elements.length && addEvent(window, "resize", resizeAllAutoSizers);
9533 element.__PREFIX__ = prefix;
9534 elements.push(element);
9535 resize(element);
9536 }
9537 function removeAutoSizer(element, prefix) {
9538 var index = elements.indexOf(element);
9539
9540 if (index < 0) {
9541 return;
9542 }
9543
9544 var fixed = getAttribute(element, prefix + "fixed");
9545 delete element.__PREFIX__;
9546 element.style[fixed === HEIGHT ? WIDTH : HEIGHT] = "";
9547 elements.splice(index, 1);
9548 !elements.length && removeEvent(window, "resize", resizeAllAutoSizers);
9549 }
9550
9551 function resize(element, prefix) {
9552 if (prefix === void 0) {
9553 prefix = "data-";
9554 }
9555
9556 var elementPrefix = element.__PREFIX__ || prefix;
9557 var dataWidth = parseInt(getAttribute(element, "" + elementPrefix + WIDTH), 10) || 0;
9558 var dataHeight = parseInt(getAttribute(element, "" + elementPrefix + HEIGHT), 10) || 0;
9559 var fixed = getAttribute(element, elementPrefix + "fixed");
9560
9561 if (fixed === HEIGHT) {
9562 var size = innerHeight(element) || dataHeight;
9563 element.style[WIDTH] = dataWidth / dataHeight * size + "px";
9564 } else {
9565 var size = innerWidth(element) || dataWidth;
9566 element.style[HEIGHT] = dataHeight / dataWidth * size + "px";
9567 }
9568 }
9569
9570 function resizeAllAutoSizers() {
9571 elements.forEach(function (element) {
9572 resize(element);
9573 });
9574 }
9575
9576 var Loader =
9577 /*#__PURE__*/
9578 function (_super) {
9579 __extends(Loader, _super);
9580
9581 function Loader(element, options) {
9582 if (options === void 0) {
9583 options = {};
9584 }
9585
9586 var _this = _super.call(this) || this;
9587
9588 _this.isReady = false;
9589 _this.isPreReady = false;
9590 _this.hasDataSize = false;
9591 _this.hasLoading = false;
9592 _this.isSkip = false;
9593
9594 _this.onCheck = function (e) {
9595 _this.clear();
9596
9597 if (e && e.type === "error") {
9598 _this.onError(_this.element);
9599 }
9600
9601 if (_this.hasLoading && _this.checkElement()) {
9602 // I'm not ready
9603 return;
9604 } // I'm pre-ready and ready!
9605
9606
9607 var withPreReady = !_this.hasDataSize && !_this.hasLoading;
9608
9609 _this.onReady(withPreReady);
9610 };
9611
9612 _this.options = __assign({
9613 prefix: "data-"
9614 }, options);
9615 _this.element = element;
9616 var prefix = _this.options.prefix;
9617 _this.hasDataSize = hasSizeAttribute(element, prefix);
9618 _this.isSkip = hasSkipAttribute(element, prefix);
9619 _this.hasLoading = hasLoadingAttribute(element, prefix);
9620 return _this;
9621 }
9622
9623 var __proto = Loader.prototype;
9624
9625 __proto.check = function () {
9626 if (this.isSkip || !this.checkElement()) {
9627 // I'm Ready
9628 this.onAlreadyReady(true);
9629 return false;
9630 }
9631
9632 if (this.hasDataSize) {
9633 addAutoSizer(this.element, this.options.prefix);
9634 }
9635
9636 if (this.hasDataSize || this.hasLoading) {
9637 // I'm Pre Ready
9638 this.onAlreadyPreReady();
9639 } // Wati Pre Ready, Ready
9640
9641
9642 return true;
9643 };
9644
9645 __proto.addEvents = function () {
9646 var _this = this;
9647
9648 var element = this.element;
9649 this.constructor.EVENTS.forEach(function (name) {
9650 addEvent(element, name, _this.onCheck);
9651 });
9652 };
9653
9654 __proto.clear = function () {
9655 var _this = this;
9656
9657 var element = this.element;
9658 this.constructor.EVENTS.forEach(function (name) {
9659 removeEvent(element, name, _this.onCheck);
9660 });
9661 this.removeAutoSizer();
9662 };
9663
9664 __proto.destroy = function () {
9665 this.clear();
9666 this.off();
9667 };
9668
9669 __proto.removeAutoSizer = function () {
9670 if (this.hasDataSize) {
9671 // I'm already ready.
9672 var prefix = this.options.prefix;
9673 removeAutoSizer(this.element, prefix);
9674 }
9675 };
9676
9677 __proto.onError = function (target) {
9678 this.trigger("error", {
9679 element: this.element,
9680 target: target
9681 });
9682 };
9683
9684 __proto.onPreReady = function () {
9685 if (this.isPreReady) {
9686 return;
9687 }
9688
9689 this.isPreReady = true;
9690 this.trigger("preReady", {
9691 element: this.element,
9692 hasLoading: this.hasLoading,
9693 isSkip: this.isSkip
9694 });
9695 };
9696
9697 __proto.onReady = function (withPreReady) {
9698 if (this.isReady) {
9699 return;
9700 }
9701
9702 withPreReady = !this.isPreReady && withPreReady;
9703
9704 if (withPreReady) {
9705 this.isPreReady = true;
9706 }
9707
9708 this.removeAutoSizer();
9709 this.isReady = true;
9710 this.trigger("ready", {
9711 element: this.element,
9712 withPreReady: withPreReady,
9713 hasLoading: this.hasLoading,
9714 isSkip: this.isSkip
9715 });
9716 };
9717
9718 __proto.onAlreadyError = function (target) {
9719 var _this = this;
9720
9721 setTimeout(function () {
9722 _this.onError(target);
9723 });
9724 };
9725
9726 __proto.onAlreadyPreReady = function () {
9727 var _this = this;
9728
9729 setTimeout(function () {
9730 _this.onPreReady();
9731 });
9732 };
9733
9734 __proto.onAlreadyReady = function (withPreReady) {
9735 var _this = this;
9736
9737 setTimeout(function () {
9738 _this.onReady(withPreReady);
9739 });
9740 };
9741
9742 Loader.EVENTS = [];
9743 return Loader;
9744 }(Component);
9745
9746 var ElementLoader =
9747 /*#__PURE__*/
9748 function (_super) {
9749 __extends(ElementLoader, _super);
9750
9751 function ElementLoader() {
9752 return _super !== null && _super.apply(this, arguments) || this;
9753 }
9754
9755 var __proto = ElementLoader.prototype;
9756
9757 __proto.setHasLoading = function (hasLoading) {
9758 this.hasLoading = hasLoading;
9759 };
9760
9761 __proto.check = function () {
9762 if (this.isSkip) {
9763 // I'm Ready
9764 this.onAlreadyReady(true);
9765 return false;
9766 }
9767
9768 if (this.hasDataSize) {
9769 addAutoSizer(this.element, this.options.prefix);
9770 this.onAlreadyPreReady();
9771 } else {
9772 // has not data size
9773 this.trigger("requestChildren");
9774 }
9775
9776 return true;
9777 };
9778
9779 __proto.checkElement = function () {
9780 return true;
9781 };
9782
9783 __proto.destroy = function () {
9784 this.clear();
9785 this.trigger("requestDestroy");
9786 this.off();
9787 };
9788
9789 __proto.onAlreadyPreReady = function () {
9790 // has data size
9791 _super.prototype.onAlreadyPreReady.call(this);
9792
9793 this.trigger("reqeustReadyChildren");
9794 };
9795
9796 ElementLoader.EVENTS = [];
9797 return ElementLoader;
9798 }(Loader);
9799
9800 /**
9801 * @alias eg.ImReady
9802 * @extends eg.Component
9803 */
9804
9805 var ImReadyManager =
9806 /*#__PURE__*/
9807 function (_super) {
9808 __extends(ImReadyManager, _super);
9809 /**
9810 * @param - ImReady's options
9811 */
9812
9813
9814 function ImReadyManager(options) {
9815 if (options === void 0) {
9816 options = {};
9817 }
9818
9819 var _this = _super.call(this) || this;
9820
9821 _this.readyCount = 0;
9822 _this.preReadyCount = 0;
9823 _this.totalCount = 0;
9824 _this.totalErrorCount = 0;
9825 _this.isPreReadyOver = true;
9826 _this.elementInfos = [];
9827 _this.options = __assign({
9828 loaders: {},
9829 prefix: "data-"
9830 }, options);
9831 return _this;
9832 }
9833 /**
9834 * Checks whether elements are in the ready state.
9835 * @ko 엘리먼트가 준비 상태인지 체크한다.
9836 * @elements - Elements to check ready status. <ko> 준비 상태를 체크할 엘리먼트들.</ko>
9837 * @example
9838 * ```html
9839 * <div>
9840 * <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/>
9841 * <img src="./2.jpg" data-width="1280" data-height="853"/>
9842 * <img src="ERR" data-width="1280" data-height="853"/>
9843 * </div>
9844 * ```
9845 * ## Javascript
9846 * ```js
9847 * import ImReady from "@egjs/imready";
9848 *
9849 * const im = new ImReady(); // umd: eg.ImReady
9850 * im.check(document.querySelectorAll("img")).on({
9851 * preReadyElement: e => {
9852 * // 1, 3
9853 * // 2, 3
9854 * // 3, 3
9855 * console.log(e.preReadyCount, e.totalCount),
9856 * },
9857 * });
9858 * ```
9859 */
9860
9861
9862 var __proto = ImReadyManager.prototype;
9863
9864 __proto.check = function (elements) {
9865 var _this = this;
9866
9867 var prefix = this.options.prefix;
9868 this.clear();
9869 this.elementInfos = toArray(elements).map(function (element, index) {
9870 var loader = _this.getLoader(element, {
9871 prefix: prefix
9872 });
9873
9874 loader.check();
9875 loader.on("error", function (e) {
9876 _this.onError(index, e.target);
9877 }).on("preReady", function (e) {
9878 var info = _this.elementInfos[index];
9879 info.hasLoading = e.hasLoading;
9880 info.isSkip = e.isSkip;
9881
9882 var isPreReady = _this.checkPreReady(index);
9883
9884 _this.onPreReadyElement(index);
9885
9886 isPreReady && _this.onPreReady();
9887 }).on("ready", function (_a) {
9888 var withPreReady = _a.withPreReady,
9889 hasLoading = _a.hasLoading,
9890 isSkip = _a.isSkip;
9891 var info = _this.elementInfos[index];
9892 info.hasLoading = hasLoading;
9893 info.isSkip = isSkip;
9894
9895 var isPreReady = withPreReady && _this.checkPreReady(index);
9896
9897 var isReady = _this.checkReady(index); // Pre-ready and ready occur simultaneously
9898
9899
9900 withPreReady && _this.onPreReadyElement(index);
9901
9902 _this.onReadyElement(index);
9903
9904 isPreReady && _this.onPreReady();
9905 isReady && _this.onReady();
9906 });
9907 return {
9908 loader: loader,
9909 element: element,
9910 hasLoading: false,
9911 hasError: false,
9912 isPreReady: false,
9913 isReady: false,
9914 isSkip: false
9915 };
9916 });
9917 var length = this.elementInfos.length;
9918 this.totalCount = length;
9919
9920 if (!length) {
9921 setTimeout(function () {
9922 _this.onPreReady();
9923
9924 _this.onReady();
9925 });
9926 }
9927
9928 return this;
9929 };
9930 /**
9931 * Gets the total count of elements to be checked.
9932 * @ko 체크하는 element의 총 개수를 가져온다.
9933 */
9934
9935
9936 __proto.getTotalCount = function () {
9937 return this.totalCount;
9938 };
9939 /**
9940 * Whether the elements are all pre-ready. (all sizes are known)
9941 * @ko 엘리먼트들이 모두 사전 준비가 됐는지 (사이즈를 전부 알 수 있는지) 여부.
9942 */
9943
9944
9945 __proto.isPreReady = function () {
9946 return this.elementInfos.every(function (info) {
9947 return info.isPreReady;
9948 });
9949 };
9950 /**
9951 * Whether the elements are all ready.
9952 * @ko 엘리먼트들이 모두 준비가 됐는지 여부.
9953 */
9954
9955
9956 __proto.isReady = function () {
9957 return this.elementInfos.every(function (info) {
9958 return info.isReady;
9959 });
9960 };
9961 /**
9962 * Whether an error has occurred in the elements in the current state.
9963 * @ko 현재 상태에서 엘리먼트들이 에러가 발생했는지 여부.
9964 */
9965
9966
9967 __proto.hasError = function () {
9968 return this.totalErrorCount > 0;
9969 };
9970 /**
9971 * Clears events of elements being checked.
9972 * @ko 체크 중인 엘리먼트들의 이벤트를 해제 한다.
9973 */
9974
9975
9976 __proto.clear = function () {
9977 this.isPreReadyOver = false;
9978 this.totalCount = 0;
9979 this.preReadyCount = 0;
9980 this.readyCount = 0;
9981 this.totalErrorCount = 0;
9982 this.elementInfos.forEach(function (info) {
9983 if (!info.isReady && info.loader) {
9984 info.loader.destroy();
9985 }
9986 });
9987 this.elementInfos = [];
9988 };
9989 /**
9990 * Destory all events.
9991 * @ko 모든 이벤트를 해제 한다.
9992 */
9993
9994
9995 __proto.destroy = function () {
9996 this.clear();
9997 this.off();
9998 };
9999
10000 __proto.getLoader = function (element, options) {
10001 var _this = this;
10002
10003 var tagName = element.tagName.toLowerCase();
10004 var loaders = this.options.loaders;
10005 var prefix = options.prefix;
10006 var tags = Object.keys(loaders);
10007
10008 if (loaders[tagName]) {
10009 return new loaders[tagName](element, options);
10010 }
10011
10012 var loader = new ElementLoader(element, options);
10013 var children = toArray(element.querySelectorAll(tags.join(", ")));
10014 loader.setHasLoading(children.some(function (el) {
10015 return hasLoadingAttribute(el, prefix);
10016 }));
10017 var withPreReady = false;
10018 var childrenImReady = this.clone().on("error", function (e) {
10019 loader.onError(e.target);
10020 }).on("ready", function () {
10021 loader.onReady(withPreReady);
10022 });
10023 loader.on("requestChildren", function () {
10024 // has not data size
10025 var contentElements = getContentElements(element, tags, _this.options.prefix);
10026 childrenImReady.check(contentElements).on("preReady", function (e) {
10027 withPreReady = e.isReady;
10028
10029 if (!withPreReady) {
10030 loader.onPreReady();
10031 }
10032 });
10033 }).on("reqeustReadyChildren", function () {
10034 // has data size
10035 // loader call preReady
10036 // check only video, image elements
10037 childrenImReady.check(children);
10038 }).on("requestDestroy", function () {
10039 childrenImReady.destroy();
10040 });
10041 return loader;
10042 };
10043
10044 __proto.clone = function () {
10045 return new ImReadyManager(__assign({}, this.options));
10046 };
10047
10048 __proto.checkPreReady = function (index) {
10049 this.elementInfos[index].isPreReady = true;
10050 ++this.preReadyCount;
10051
10052 if (this.preReadyCount < this.totalCount) {
10053 return false;
10054 }
10055
10056 return true;
10057 };
10058
10059 __proto.checkReady = function (index) {
10060 this.elementInfos[index].isReady = true;
10061 ++this.readyCount;
10062
10063 if (this.readyCount < this.totalCount) {
10064 return false;
10065 }
10066
10067 return true;
10068 };
10069
10070 __proto.onError = function (index, target) {
10071 var info = this.elementInfos[index];
10072 info.hasError = true;
10073 /**
10074 * An event occurs if the image, video fails to load.
10075 * @ko 이미지, 비디오가 로딩에 실패하면 이벤트가 발생한다.
10076 * @event eg.ImReady#error
10077 * @param {eg.ImReady.OnError} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
10078 * @example
10079 * ```html
10080 * <div>
10081 * <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/>
10082 * <img src="./2.jpg"/>
10083 * <img src="ERR"/>
10084 * </div>
10085 * ```
10086 * ## Javascript
10087 * ```js
10088 * import ImReady from "@egjs/imready";
10089 *
10090 * const im = new ImReady(); // umd: eg.ImReady
10091 * im.check([document.querySelector("div")]).on({
10092 * error: e => {
10093 * // <div>...</div>, 0, <img src="ERR"/>
10094 * console.log(e.element, e.index, e.target),
10095 * },
10096 * });
10097 * ```
10098 */
10099
10100 this.trigger(new ComponentEvent$1("error", {
10101 element: info.element,
10102 index: index,
10103 target: target,
10104 errorCount: this.getErrorCount(),
10105 totalErrorCount: ++this.totalErrorCount
10106 }));
10107 };
10108
10109 __proto.onPreReadyElement = function (index) {
10110 var info = this.elementInfos[index];
10111 /**
10112 * An event occurs when the element is pre-ready (when the loading attribute is applied or the size is known)
10113 * @ko 해당 엘리먼트가 사전 준비되었을 때(loading 속성이 적용되었거나 사이즈를 알 수 있을 때) 이벤트가 발생한다.
10114 * @event eg.ImReady#preReadyElement
10115 * @param {eg.ImReady.OnPreReadyElement} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
10116 * @example
10117 * ```html
10118 * <div>
10119 * <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/>
10120 * <img src="./2.jpg" data-width="1280" data-height="853"/>
10121 * <img src="ERR" data-width="1280" data-height="853"/>
10122 * </div>
10123 * ```
10124 * ## Javascript
10125 * ```js
10126 * import ImReady from "@egjs/imready";
10127 *
10128 * const im = new ImReady(); // umd: eg.ImReady
10129 * im.check(document.querySelectorAll("img")).on({
10130 * preReadyElement: e => {
10131 * // 1, 3
10132 * // 2, 3
10133 * // 3, 3
10134 * console.log(e.preReadyCount, e.totalCount),
10135 * },
10136 * });
10137 * ```
10138 */
10139
10140 this.trigger(new ComponentEvent$1("preReadyElement", {
10141 element: info.element,
10142 index: index,
10143 preReadyCount: this.preReadyCount,
10144 readyCount: this.readyCount,
10145 totalCount: this.totalCount,
10146 isPreReady: this.isPreReady(),
10147 isReady: this.isReady(),
10148 hasLoading: info.hasLoading,
10149 isSkip: info.isSkip
10150 }));
10151 };
10152
10153 __proto.onPreReady = function () {
10154 this.isPreReadyOver = true;
10155 /**
10156 * An event occurs when all element are pre-ready (When all elements have the loading attribute applied or the size is known)
10157 * @ko 모든 엘리먼트들이 사전 준비된 경우 (모든 엘리먼트들이 loading 속성이 적용되었거나 사이즈를 알 수 있는 경우) 이벤트가 발생한다.
10158 * @event eg.ImReady#preReady
10159 * @param {eg.ImReady.OnPreReady} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
10160 * @example
10161 * ```html
10162 * <div>
10163 * <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/>
10164 * <img src="./2.jpg" data-width="1280" data-height="853"/>
10165 * <img src="ERR" data-width="1280" data-height="853"/>
10166 * </div>
10167 * ```
10168 * ## Javascript
10169 * ```js
10170 * import ImReady from "@egjs/imready";
10171 *
10172 * const im = new ImReady(); // umd: eg.ImReady
10173 * im.check(document.querySelectorAll("img")).on({
10174 * preReady: e => {
10175 * // 0, 3
10176 * console.log(e.readyCount, e.totalCount),
10177 * },
10178 * });
10179 * ```
10180 */
10181
10182 this.trigger(new ComponentEvent$1("preReady", {
10183 readyCount: this.readyCount,
10184 totalCount: this.totalCount,
10185 isReady: this.isReady(),
10186 hasLoading: this.hasLoading()
10187 }));
10188 };
10189
10190 __proto.onReadyElement = function (index) {
10191 var info = this.elementInfos[index];
10192 /**
10193 * An event occurs when the element is ready
10194 * @ko 해당 엘리먼트가 준비가 되었을 때 이벤트가 발생한다.
10195 * @event eg.ImReady#readyElement
10196 * @param {eg.ImReady.OnReadyElement} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
10197 * @example
10198 * ```html
10199 * <div>
10200 * <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/>
10201 * <img src="./2.jpg" data-width="1280" data-height="853"/>
10202 * <img src="ERR" data-width="1280" data-height="853"/>
10203 * </div>
10204 * ```
10205 * ## Javascript
10206 * ```js
10207 * import ImReady from "@egjs/imready";
10208 *
10209 * const im = new ImReady(); // umd: eg.ImReady
10210 * im.check(document.querySelectorAll("img")).on({
10211 * readyElement: e => {
10212 * // 1, 0, false, 3
10213 * // 2, 1, false, 3
10214 * // 3, 2, true, 3
10215 * console.log(e.readyCount, e.index, e.hasError, e.totalCount),
10216 * },
10217 * });
10218 * ```
10219 */
10220
10221 this.trigger(new ComponentEvent$1("readyElement", {
10222 index: index,
10223 element: info.element,
10224 hasError: info.hasError,
10225 errorCount: this.getErrorCount(),
10226 totalErrorCount: this.totalErrorCount,
10227 preReadyCount: this.preReadyCount,
10228 readyCount: this.readyCount,
10229 totalCount: this.totalCount,
10230 isPreReady: this.isPreReady(),
10231 isReady: this.isReady(),
10232 hasLoading: info.hasLoading,
10233 isPreReadyOver: this.isPreReadyOver,
10234 isSkip: info.isSkip
10235 }));
10236 };
10237
10238 __proto.onReady = function () {
10239 /**
10240 * An event occurs when all element are ready
10241 * @ko 모든 엘리먼트들이 준비된 경우 이벤트가 발생한다.
10242 * @event eg.ImReady#ready
10243 * @param {eg.ImReady.OnReady} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
10244 * @example
10245 * ```html
10246 * <div>
10247 * <img src="./1.jpg" data-width="1280" data-height="853" style="width:100%"/>
10248 * <img src="./2.jpg" data-width="1280" data-height="853"/>
10249 * <img src="ERR" data-width="1280" data-height="853"/>
10250 * </div>
10251 * ```
10252 * ## Javascript
10253 * ```js
10254 * import ImReady from "@egjs/imready";
10255 *
10256 * const im = new ImReady(); // umd: eg.ImReady
10257 * im.check(document.querySelectorAll("img")).on({
10258 * preReady: e => {
10259 * // 0, 3
10260 * console.log(e.readyCount, e.totalCount),
10261 * },
10262 * ready: e => {
10263 * // 1, 3
10264 * console.log(e.errorCount, e.totalCount),
10265 * },
10266 * });
10267 * ```
10268 */
10269 this.trigger(new ComponentEvent$1("ready", {
10270 errorCount: this.getErrorCount(),
10271 totalErrorCount: this.totalErrorCount,
10272 totalCount: this.totalCount
10273 }));
10274 };
10275
10276 __proto.getErrorCount = function () {
10277 return this.elementInfos.filter(function (info) {
10278 return info.hasError;
10279 }).length;
10280 };
10281
10282 __proto.hasLoading = function () {
10283 return this.elementInfos.some(function (info) {
10284 return info.hasLoading;
10285 });
10286 };
10287
10288 return ImReadyManager;
10289 }(Component);
10290
10291 var ImageLoader =
10292 /*#__PURE__*/
10293 function (_super) {
10294 __extends(ImageLoader, _super);
10295
10296 function ImageLoader() {
10297 return _super !== null && _super.apply(this, arguments) || this;
10298 }
10299
10300 var __proto = ImageLoader.prototype;
10301
10302 __proto.checkElement = function () {
10303 var element = this.element;
10304 var src = element.getAttribute("src");
10305
10306 if (element.complete) {
10307 if (src) {
10308 // complete
10309 if (!element.naturalWidth) {
10310 this.onAlreadyError(element);
10311 }
10312
10313 return false;
10314 } else {
10315 // Using an external lazy loading module
10316 this.onAlreadyPreReady();
10317 }
10318 }
10319
10320 this.addEvents();
10321 IS_IE && element.setAttribute("src", src);
10322 return true;
10323 };
10324
10325 ImageLoader.EVENTS = ["load", "error"];
10326 return ImageLoader;
10327 }(Loader);
10328
10329 var VideoLoader =
10330 /*#__PURE__*/
10331 function (_super) {
10332 __extends(VideoLoader, _super);
10333
10334 function VideoLoader() {
10335 return _super !== null && _super.apply(this, arguments) || this;
10336 }
10337
10338 var __proto = VideoLoader.prototype;
10339
10340 __proto.checkElement = function () {
10341 var element = this.element; // HAVE_NOTHING: 0, no information whether or not the audio/video is ready
10342 // HAVE_METADATA: 1, HAVE_METADATA - metadata for the audio/video is ready
10343 // HAVE_CURRENT_DATA: 2, data for the current playback position is available, but not enough data to play next frame/millisecond
10344 // HAVE_FUTURE_DATA: 3, data for the current and at least the next frame is available
10345 // HAVE_ENOUGH_DATA: 4, enough data available to start playing
10346
10347 if (element.readyState >= 1) {
10348 return false;
10349 }
10350
10351 if (element.error) {
10352 this.onAlreadyError(element);
10353 return false;
10354 }
10355
10356 this.addEvents();
10357 return true;
10358 };
10359
10360 VideoLoader.EVENTS = ["loadedmetadata", "error"];
10361 return VideoLoader;
10362 }(Loader);
10363
10364 var ImReady =
10365 /*#__PURE__*/
10366 function (_super) {
10367 __extends(ImReady, _super);
10368
10369 function ImReady(options) {
10370 if (options === void 0) {
10371 options = {};
10372 }
10373
10374 return _super.call(this, __assign({
10375 loaders: {
10376 img: ImageLoader,
10377 video: VideoLoader
10378 }
10379 }, options)) || this;
10380 }
10381
10382 return ImReady;
10383 }(ImReadyManager);
10384
10385 /*
10386 egjs-imready
10387 Copyright (c) 2020-present NAVER Corp.
10388 MIT license
10389 */
10390
10391 var ImReady$1 = ImReady;
10392
10393 /**
10394 * A component that manages {@link Panel} and its elements
10395 * @ko {@link Panel}과 그 엘리먼트들을 관리하는 컴포넌트
10396 */
10397
10398 var Renderer$1 =
10399 /*#__PURE__*/
10400 function () {
10401 /**
10402 * @param {object} options An options object<ko>옵션 오브젝트</ko>
10403 * @param {Constants.ALIGN | string | number} [options.align="center"] An {@link Flicking#align align} value that will be applied to all panels<ko>전체 패널에 적용될 {@link Flicking#align align} 값</ko>
10404 * @param {object} [options.strategy] An instance of RenderingStrategy(internal module)<ko>RenderingStrategy의 인스턴스(내부 모듈)</ko>
10405 */
10406 function Renderer(_a) {
10407 var _b = _a.align,
10408 align = _b === void 0 ? ALIGN.CENTER : _b,
10409 strategy = _a.strategy;
10410 this._flicking = null;
10411 this._panels = [];
10412 this._rendering = false; // Bind options
10413
10414 this._align = align;
10415 this._strategy = strategy;
10416 }
10417
10418 var __proto = Renderer.prototype;
10419 Object.defineProperty(__proto, "panels", {
10420 // Internal states Getter
10421
10422 /**
10423 * Array of panels
10424 * @ko 전체 패널들의 배열
10425 * @type {Panel[]}
10426 * @readonly
10427 * @see Panel
10428 */
10429 get: function () {
10430 return this._panels;
10431 },
10432 enumerable: false,
10433 configurable: true
10434 });
10435 Object.defineProperty(__proto, "rendering", {
10436 /**
10437 * A boolean value indicating whether rendering is in progress
10438 * @ko 현재 렌더링이 시작되어 끝나기 전까지의 상태인지의 여부
10439 * @type {boolean}
10440 * @readonly
10441 * @internal
10442 */
10443 get: function () {
10444 return this._rendering;
10445 },
10446 enumerable: false,
10447 configurable: true
10448 });
10449 Object.defineProperty(__proto, "panelCount", {
10450 /**
10451 * Count of panels
10452 * @ko 전체 패널의 개수
10453 * @type {number}
10454 * @readonly
10455 */
10456 get: function () {
10457 return this._panels.length;
10458 },
10459 enumerable: false,
10460 configurable: true
10461 });
10462 Object.defineProperty(__proto, "strategy", {
10463 /**
10464 * @internal
10465 */
10466 get: function () {
10467 return this._strategy;
10468 },
10469 enumerable: false,
10470 configurable: true
10471 });
10472 Object.defineProperty(__proto, "align", {
10473 // Options Getter
10474
10475 /**
10476 * A {@link Panel}'s {@link Panel#align align} value that applied to all panels
10477 * @ko {@link Panel}에 공통적으로 적용할 {@link Panel#align align} 값
10478 * @type {Constants.ALIGN | string | number}
10479 */
10480 get: function () {
10481 return this._align;
10482 },
10483 // Options Setter
10484 set: function (val) {
10485 this._align = val;
10486 var panelAlign = parsePanelAlign(val);
10487
10488 this._panels.forEach(function (panel) {
10489 panel.align = panelAlign;
10490 });
10491 },
10492 enumerable: false,
10493 configurable: true
10494 });
10495 /**
10496 * Initialize Renderer
10497 * @ko Renderer를 초기화합니다
10498 * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
10499 * @chainable
10500 * @return {this}
10501 */
10502
10503 __proto.init = function (flicking) {
10504 this._flicking = flicking;
10505
10506 this._collectPanels();
10507
10508 return this;
10509 };
10510 /**
10511 * Destroy Renderer and return to initial state
10512 * @ko Renderer를 초기 상태로 되돌립니다
10513 * @return {void}
10514 */
10515
10516
10517 __proto.destroy = function () {
10518 this._flicking = null;
10519 this._panels = [];
10520 };
10521 /**
10522 * Return the {@link Panel} at the given index. `null` if it doesn't exists.
10523 * @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
10524 * @return {Panel | null} Panel at the given index<ko>주어진 인덱스에 해당하는 패널</ko>
10525 * @see Panel
10526 */
10527
10528
10529 __proto.getPanel = function (index) {
10530 return this._panels[index] || null;
10531 };
10532
10533 __proto.forceRenderAllPanels = function () {
10534 this._panels.forEach(function (panel) {
10535 return panel.markForShow();
10536 });
10537
10538 return Promise.resolve();
10539 };
10540 /**
10541 * Update all panel sizes
10542 * @ko 모든 패널의 크기를 업데이트합니다
10543 * @chainable
10544 * @return {this}
10545 */
10546
10547
10548 __proto.updatePanelSize = function () {
10549 var flicking = getFlickingAttached(this._flicking);
10550 var panels = this._panels;
10551 if (panels.length <= 0) return this;
10552
10553 if (flicking.panelsPerView > 0) {
10554 var firstPanel = panels[0];
10555 firstPanel.resize();
10556
10557 this._updatePanelSizeByGrid(firstPanel, panels);
10558 } else {
10559 flicking.panels.forEach(function (panel) {
10560 return panel.resize();
10561 });
10562 }
10563
10564 return this;
10565 };
10566 /**
10567 * Insert new panels at given index
10568 * This will increase index of panels after by the number of panels added
10569 * @ko 주어진 인덱스에 새로운 패널들을 추가합니다
10570 * 해당 인덱스보다 같거나 큰 인덱스를 가진 기존 패널들은 추가한 패널의 개수만큼 인덱스가 증가합니다.
10571 * @param {Array<object>} items An array of items to insert<ko>추가할 아이템들의 배열</ko>
10572 * @param {number} [items.index] Index to insert new panels at<ko>새로 패널들을 추가할 인덱스</ko>
10573 * @param {any[]} [items.elements] An array of element or framework component with element in it<ko>엘리먼트의 배열 혹은 프레임워크에서 엘리먼트를 포함한 컴포넌트들의 배열</ko>
10574 * @param {boolean} [items.hasDOMInElements] Whether it contains actual DOM elements. If set to true, renderer will add them to the camera element<ko>내부에 실제 DOM 엘리먼트들을 포함하고 있는지 여부. true로 설정할 경우, 렌더러는 해당 엘리먼트들을 카메라 엘리먼트 내부에 추가합니다</ko>
10575 * @return {Panel[]} An array of prepended panels<ko>추가된 패널들의 배열</ko>
10576 */
10577
10578
10579 __proto.batchInsert = function () {
10580 var items = [];
10581
10582 for (var _i = 0; _i < arguments.length; _i++) {
10583 items[_i] = arguments[_i];
10584 }
10585
10586 var allPanelsInserted = this.batchInsertDefer.apply(this, __spread$1(items));
10587 if (allPanelsInserted.length <= 0) return [];
10588 this.updateAfterPanelChange(allPanelsInserted, []);
10589 return allPanelsInserted;
10590 };
10591 /**
10592 * Defers update
10593 * camera position & others will be updated after calling updateAfterPanelChange
10594 * @internal
10595 */
10596
10597
10598 __proto.batchInsertDefer = function () {
10599 var _this = this;
10600
10601 var items = [];
10602
10603 for (var _i = 0; _i < arguments.length; _i++) {
10604 items[_i] = arguments[_i];
10605 }
10606
10607 var panels = this._panels;
10608 var flicking = getFlickingAttached(this._flicking);
10609 var prevFirstPanel = panels[0];
10610 var align = parsePanelAlign(this._align);
10611 var allPanelsInserted = items.reduce(function (addedPanels, item) {
10612 var _a;
10613
10614 var insertingIdx = getMinusCompensatedIndex(item.index, panels.length);
10615 var panelsPushed = panels.slice(insertingIdx);
10616 var panelsInserted = item.elements.map(function (el, idx) {
10617 return _this._createPanel(el, {
10618 index: insertingIdx + idx,
10619 align: align,
10620 flicking: flicking
10621 });
10622 });
10623 panels.splice.apply(panels, __spread$1([insertingIdx, 0], panelsInserted));
10624
10625 if (item.hasDOMInElements) {
10626 // Insert the actual elements as camera element's children
10627 _this._insertPanelElements(panelsInserted, (_a = panelsPushed[0]) !== null && _a !== void 0 ? _a : null);
10628 } // Resize the newly added panels
10629
10630
10631 if (flicking.panelsPerView > 0) {
10632 var firstPanel = prevFirstPanel || panelsInserted[0].resize();
10633
10634 _this._updatePanelSizeByGrid(firstPanel, panelsInserted);
10635 } else {
10636 panelsInserted.forEach(function (panel) {
10637 return panel.resize();
10638 });
10639 } // Update panel indexes & positions
10640
10641
10642 panelsPushed.forEach(function (panel) {
10643 panel.increaseIndex(panelsInserted.length);
10644 panel.updatePosition();
10645 });
10646 return __spread$1(addedPanels, panelsInserted);
10647 }, []);
10648 return allPanelsInserted;
10649 };
10650 /**
10651 * Remove the panel at the given index
10652 * This will decrease index of panels after by the number of panels removed
10653 * @ko 주어진 인덱스의 패널을 제거합니다
10654 * 해당 인덱스보다 큰 인덱스를 가진 기존 패널들은 제거한 패널의 개수만큼 인덱스가 감소합니다
10655 * @param {Array<object>} items An array of items to remove<ko>제거할 아이템들의 배열</ko>
10656 * @param {number} [items.index] Index of panel to remove<ko>제거할 패널의 인덱스</ko>
10657 * @param {number} [items.deleteCount=1] Number of panels to remove from index<ko>`index` 이후로 제거할 패널의 개수</ko>
10658 * @param {boolean} [items.hasDOMInElements=1] Whether it contains actual DOM elements. If set to true, renderer will remove them from the camera element<ko>내부에 실제 DOM 엘리먼트들을 포함하고 있는지 여부. true로 설정할 경우, 렌더러는 해당 엘리먼트들을 카메라 엘리먼트 내부에서 제거합니다</ko>
10659 * @return An array of removed panels<ko>제거된 패널들의 배열</ko>
10660 */
10661
10662
10663 __proto.batchRemove = function () {
10664 var items = [];
10665
10666 for (var _i = 0; _i < arguments.length; _i++) {
10667 items[_i] = arguments[_i];
10668 }
10669
10670 var allPanelsRemoved = this.batchRemoveDefer.apply(this, __spread$1(items));
10671 if (allPanelsRemoved.length <= 0) return [];
10672 this.updateAfterPanelChange([], allPanelsRemoved);
10673 return allPanelsRemoved;
10674 };
10675 /**
10676 * Defers update
10677 * camera position & others will be updated after calling updateAfterPanelChange
10678 * @internal
10679 */
10680
10681
10682 __proto.batchRemoveDefer = function () {
10683 var _this = this;
10684
10685 var items = [];
10686
10687 for (var _i = 0; _i < arguments.length; _i++) {
10688 items[_i] = arguments[_i];
10689 }
10690
10691 var panels = this._panels;
10692 var flicking = getFlickingAttached(this._flicking);
10693 var control = flicking.control;
10694 var activePanel = control.activePanel;
10695 var allPanelsRemoved = items.reduce(function (removed, item) {
10696 var index = item.index,
10697 deleteCount = item.deleteCount;
10698 var removingIdx = getMinusCompensatedIndex(index, panels.length);
10699 var panelsPulled = panels.slice(removingIdx + deleteCount);
10700 var panelsRemoved = panels.splice(removingIdx, deleteCount);
10701 if (panelsRemoved.length <= 0) return []; // Update panel indexes & positions
10702
10703 panelsPulled.forEach(function (panel) {
10704 panel.decreaseIndex(panelsRemoved.length);
10705 panel.updatePosition();
10706 });
10707
10708 if (item.hasDOMInElements) {
10709 _this._removePanelElements(panelsRemoved);
10710 } // Remove panel elements
10711
10712
10713 panelsRemoved.forEach(function (panel) {
10714 return panel.destroy();
10715 });
10716
10717 if (includes(panelsRemoved, activePanel)) {
10718 control.resetActive();
10719 }
10720
10721 return __spread$1(removed, panelsRemoved);
10722 }, []);
10723 return allPanelsRemoved;
10724 };
10725 /**
10726 * @internal
10727 */
10728
10729
10730 __proto.updateAfterPanelChange = function (panelsAdded, panelsRemoved) {
10731 var _a;
10732
10733 var flicking = getFlickingAttached(this._flicking);
10734 var camera = flicking.camera,
10735 control = flicking.control;
10736 var panels = this._panels;
10737 var activePanel = control.activePanel; // Update camera & control
10738
10739 this._updateCameraAndControl();
10740
10741 void this.render();
10742
10743 if (!flicking.animating) {
10744 if (!activePanel || activePanel.removed) {
10745 if (panels.length <= 0) {
10746 // All panels removed
10747 camera.lookAt(0);
10748 } else {
10749 var targetIndex = (_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.index) !== null && _a !== void 0 ? _a : 0;
10750
10751 if (targetIndex > panels.length - 1) {
10752 targetIndex = panels.length - 1;
10753 }
10754
10755 void control.moveToPanel(panels[targetIndex], {
10756 duration: 0
10757 }).catch(function () {
10758 return void 0;
10759 });
10760 }
10761 } else {
10762 void control.moveToPanel(activePanel, {
10763 duration: 0
10764 }).catch(function () {
10765 return void 0;
10766 });
10767 }
10768 }
10769
10770 flicking.camera.updateOffset();
10771
10772 if (panelsAdded.length > 0 || panelsRemoved.length > 0) {
10773 flicking.trigger(new ComponentEvent$1(EVENTS.PANEL_CHANGE, {
10774 added: panelsAdded,
10775 removed: panelsRemoved
10776 }));
10777 this.checkPanelContentsReady(__spread$1(panelsAdded, panelsRemoved));
10778 }
10779 };
10780 /**
10781 * @internal
10782 */
10783
10784
10785 __proto.checkPanelContentsReady = function (checkingPanels) {
10786 var _this = this;
10787
10788 var flicking = getFlickingAttached(this._flicking);
10789 var resizeOnContentsReady = flicking.resizeOnContentsReady;
10790 var panels = this._panels;
10791 if (!resizeOnContentsReady || flicking.virtualEnabled) return;
10792
10793 var hasContents = function (panel) {
10794 return panel.element && !!panel.element.querySelector("img, video");
10795 };
10796
10797 checkingPanels = checkingPanels.filter(function (panel) {
10798 return hasContents(panel);
10799 });
10800 if (checkingPanels.length <= 0) return;
10801 var contentsReadyChecker = new ImReady$1();
10802 checkingPanels.forEach(function (panel) {
10803 panel.loading = true;
10804 });
10805 contentsReadyChecker.on("readyElement", function (e) {
10806 if (!_this._flicking) {
10807 // Renderer's destroy() is called before
10808 contentsReadyChecker.destroy();
10809 return;
10810 }
10811
10812 var panel = checkingPanels[e.index];
10813 var camera = flicking.camera;
10814 var control = flicking.control;
10815 var prevProgressInPanel = control.activePanel ? camera.getProgressInPanel(control.activePanel) : 0;
10816 panel.loading = false;
10817 panel.resize();
10818 panels.slice(panel.index + 1).forEach(function (panelBehind) {
10819 return panelBehind.updatePosition();
10820 });
10821 if (!flicking.initialized) return;
10822 camera.updateRange();
10823 camera.updateOffset();
10824 camera.updateAnchors();
10825
10826 if (control.animating) ; else {
10827 control.updatePosition(prevProgressInPanel);
10828 control.updateInput();
10829 }
10830 });
10831 contentsReadyChecker.on("preReady", function (e) {
10832 if (_this._flicking) {
10833 void _this.render();
10834 }
10835
10836 if (e.readyCount === e.totalCount) {
10837 contentsReadyChecker.destroy();
10838 }
10839 });
10840 contentsReadyChecker.on("ready", function () {
10841 if (_this._flicking) {
10842 void _this.render();
10843 }
10844
10845 contentsReadyChecker.destroy();
10846 });
10847 contentsReadyChecker.check(checkingPanels.map(function (panel) {
10848 return panel.element;
10849 }));
10850 };
10851
10852 __proto._updateCameraAndControl = function () {
10853 var flicking = getFlickingAttached(this._flicking);
10854 var camera = flicking.camera,
10855 control = flicking.control;
10856 camera.updateRange();
10857 camera.updateOffset();
10858 camera.updateAnchors();
10859 camera.resetNeedPanelHistory();
10860 control.updateInput();
10861 };
10862
10863 __proto._showOnlyVisiblePanels = function (flicking) {
10864 var panels = flicking.renderer.panels;
10865 var camera = flicking.camera;
10866 var visibleIndexes = camera.visiblePanels.reduce(function (visibles, panel) {
10867 visibles[panel.index] = true;
10868 return visibles;
10869 }, {});
10870 panels.forEach(function (panel) {
10871 if (panel.index in visibleIndexes || panel.loading) {
10872 panel.markForShow();
10873 } else if (!flicking.holding) {
10874 // During the input sequence,
10875 // Do not remove panel elements as it won't trigger touchend event.
10876 panel.markForHide();
10877 }
10878 });
10879 };
10880
10881 __proto._updatePanelSizeByGrid = function (referencePanel, panels) {
10882 var flicking = getFlickingAttached(this._flicking);
10883 var panelsPerView = flicking.panelsPerView;
10884
10885 if (panelsPerView <= 0) {
10886 throw new FlickingError(MESSAGE.WRONG_OPTION("panelsPerView", panelsPerView), CODE.WRONG_OPTION);
10887 }
10888
10889 if (panels.length <= 0) return;
10890 var viewportSize = flicking.camera.size;
10891 var gap = referencePanel.margin.prev + referencePanel.margin.next;
10892 var panelSize = (viewportSize - gap * (panelsPerView - 1)) / panelsPerView;
10893 var panelSizeObj = flicking.horizontal ? {
10894 width: panelSize
10895 } : {
10896 height: panelSize
10897 };
10898
10899 var firstPanelSizeObj = __assign$2({
10900 size: panelSize,
10901 margin: referencePanel.margin
10902 }, !flicking.horizontal && {
10903 height: referencePanel.height
10904 });
10905
10906 if (!flicking.noPanelStyleOverride) {
10907 this._strategy.updatePanelSizes(flicking, panelSizeObj);
10908 }
10909
10910 flicking.panels.forEach(function (panel) {
10911 return panel.resize(firstPanelSizeObj);
10912 });
10913 };
10914
10915 __proto._removeAllChildsFromCamera = function () {
10916 var flicking = getFlickingAttached(this._flicking);
10917 var cameraElement = flicking.camera.element; // Remove other elements
10918
10919 while (cameraElement.firstChild) {
10920 cameraElement.removeChild(cameraElement.firstChild);
10921 }
10922 };
10923
10924 __proto._insertPanelElements = function (panels, nextSibling) {
10925 if (nextSibling === void 0) {
10926 nextSibling = null;
10927 }
10928
10929 var flicking = getFlickingAttached(this._flicking);
10930 var camera = flicking.camera;
10931 var cameraElement = camera.element;
10932 var nextSiblingElement = (nextSibling === null || nextSibling === void 0 ? void 0 : nextSibling.element) || null;
10933 var fragment = document.createDocumentFragment();
10934 panels.forEach(function (panel) {
10935 return fragment.appendChild(panel.element);
10936 });
10937 cameraElement.insertBefore(fragment, nextSiblingElement);
10938 };
10939
10940 __proto._removePanelElements = function (panels) {
10941 var flicking = getFlickingAttached(this._flicking);
10942 var cameraElement = flicking.camera.element;
10943 panels.forEach(function (panel) {
10944 cameraElement.removeChild(panel.element);
10945 });
10946 };
10947
10948 return Renderer;
10949 }();
10950
10951 /**
10952 *
10953 */
10954
10955 var VanillaRenderer =
10956 /*#__PURE__*/
10957 function (_super) {
10958 __extends$2(VanillaRenderer, _super);
10959
10960 function VanillaRenderer() {
10961 return _super !== null && _super.apply(this, arguments) || this;
10962 } // eslint-disable-next-line @typescript-eslint/require-await
10963
10964
10965 var __proto = VanillaRenderer.prototype;
10966
10967 __proto.render = function () {
10968 return __awaiter(this, void 0, void 0, function () {
10969 var flicking, strategy;
10970 return __generator(this, function (_a) {
10971 flicking = getFlickingAttached(this._flicking);
10972 strategy = this._strategy;
10973 strategy.updateRenderingPanels(flicking);
10974 strategy.renderPanels(flicking);
10975
10976 this._resetPanelElementOrder();
10977
10978 return [2
10979 /*return*/
10980 ];
10981 });
10982 });
10983 };
10984
10985 __proto._collectPanels = function () {
10986 var flicking = getFlickingAttached(this._flicking);
10987 var camera = flicking.camera;
10988
10989 this._removeAllTextNodes();
10990
10991 this._panels = this._strategy.collectPanels(flicking, camera.children);
10992 };
10993
10994 __proto._createPanel = function (el, options) {
10995 return this._strategy.createPanel(el, options);
10996 };
10997
10998 __proto._resetPanelElementOrder = function () {
10999 var flicking = getFlickingAttached(this._flicking);
11000 var cameraEl = flicking.camera.element; // We're using reversed panels here as last panel should be the last element of camera element
11001
11002 var reversedElements = this._strategy.getRenderingElementsByOrder(flicking).reverse();
11003
11004 reversedElements.forEach(function (el, idx) {
11005 var nextEl = reversedElements[idx - 1] ? reversedElements[idx - 1] : null;
11006
11007 if (el.nextElementSibling !== nextEl) {
11008 cameraEl.insertBefore(el, nextEl);
11009 }
11010 });
11011 };
11012
11013 __proto._removeAllTextNodes = function () {
11014 var flicking = getFlickingAttached(this._flicking);
11015 var cameraElement = flicking.camera.element; // Remove all text nodes in the camera element
11016
11017 toArray$2(cameraElement.childNodes).forEach(function (node) {
11018 if (node.nodeType === Node.TEXT_NODE) {
11019 cameraElement.removeChild(node);
11020 }
11021 });
11022 };
11023
11024 return VanillaRenderer;
11025 }(Renderer$1);
11026
11027 /**
11028 * @internal
11029 */
11030
11031 var ExternalRenderer =
11032 /*#__PURE__*/
11033 function (_super) {
11034 __extends$2(ExternalRenderer, _super);
11035
11036 function ExternalRenderer() {
11037 return _super !== null && _super.apply(this, arguments) || this;
11038 }
11039 /* eslint-disable @typescript-eslint/no-unused-vars */
11040
11041
11042 var __proto = ExternalRenderer.prototype;
11043
11044 __proto._removePanelElements = function (panels) {// DO NOTHING, overrided to prevent an unexpected error
11045 };
11046
11047 __proto._removeAllChildsFromCamera = function () {// DO NOTHING, overrided to prevent an unexpected error
11048 };
11049
11050 return ExternalRenderer;
11051 }(Renderer$1);
11052
11053 /**
11054 * A slide data component that holds information of a single HTMLElement
11055 * @ko 슬라이드 데이터 컴포넌트로, 단일 HTMLElement의 정보를 갖고 있습니다
11056 */
11057
11058 var Panel =
11059 /*#__PURE__*/
11060 function () {
11061 /**
11062 * @param {object} options An options object<ko>옵션 오브젝트</ko>
11063 * @param {number} [options.index] An initial index of the panel<ko>패널의 초기 인덱스</ko>
11064 * @param {Constants.ALIGN | string | number} [options.align] An initial {@link Flicking#align align} value of the panel<ko>패널의 초기 {@link Flicking#align align}값</ko>
11065 * @param {Flicking} [options.flicking] A Flicking instance panel's referencing<ko>패널이 참조하는 {@link Flicking} 인스턴스</ko>
11066 * @param {Flicking} [options.elementProvider] A provider instance that redirects elements<ko>실제 엘리먼트를 반환하는 엘리먼트 공급자의 인스턴스</ko>
11067 */
11068 function Panel(_a) {
11069 var index = _a.index,
11070 align = _a.align,
11071 flicking = _a.flicking,
11072 elementProvider = _a.elementProvider;
11073 this._index = index;
11074 this._flicking = flicking;
11075 this._elProvider = elementProvider;
11076 this._align = align;
11077 this._removed = false;
11078 this._rendered = true;
11079 this._loading = false;
11080
11081 this._resetInternalStates();
11082 }
11083
11084 var __proto = Panel.prototype;
11085 Object.defineProperty(__proto, "element", {
11086 // Internal States Getter
11087
11088 /**
11089 * `HTMLElement` that panel's referencing
11090 * @ko 패널이 참조하고 있는 `HTMLElement`
11091 * @type {HTMLElement}
11092 * @readonly
11093 */
11094 get: function () {
11095 return this._elProvider.element;
11096 },
11097 enumerable: false,
11098 configurable: true
11099 });
11100 Object.defineProperty(__proto, "elementProvider", {
11101 /**
11102 * @internal
11103 * @readonly
11104 */
11105 get: function () {
11106 return this._elProvider;
11107 },
11108 enumerable: false,
11109 configurable: true
11110 });
11111 Object.defineProperty(__proto, "index", {
11112 /**
11113 * Index of the panel
11114 * @ko 패널의 인덱스
11115 * @type {number}
11116 * @readonly
11117 */
11118 get: function () {
11119 return this._index;
11120 },
11121 enumerable: false,
11122 configurable: true
11123 });
11124 Object.defineProperty(__proto, "position", {
11125 /**
11126 * Position of the panel, including {@link Panel#alignPosition alignPosition}
11127 * @ko 패널의 현재 좌표, {@link Panel#alignPosition alignPosition}을 포함하고 있습니다
11128 * @type {number}
11129 * @readonly
11130 */
11131 get: function () {
11132 return this._pos + this._alignPos;
11133 },
11134 enumerable: false,
11135 configurable: true
11136 });
11137 Object.defineProperty(__proto, "size", {
11138 /**
11139 * Cached size of the panel element
11140 * This is equal to {@link Panel#element element}'s `offsetWidth` if {@link Flicking#horizontal horizontal} is `true`, and `offsetHeight` else
11141 * @ko 패널 엘리먼트의 캐시된 크기
11142 * 이 값은 {@link Flicking#horizontal horizontal}이 `true`일 경우 {@link Panel#element element}의 `offsetWidth`와 동일하고, `false`일 경우 `offsetHeight`와 동일합니다
11143 * @type {number}
11144 * @readonly
11145 */
11146 get: function () {
11147 return this._size;
11148 },
11149 enumerable: false,
11150 configurable: true
11151 });
11152 Object.defineProperty(__proto, "sizeIncludingMargin", {
11153 /**
11154 * Panel's size including CSS `margin`
11155 * This value includes {@link Panel#element element}'s margin left/right if {@link Flicking#horizontal horizontal} is `true`, and margin top/bottom else
11156 * @ko CSS `margin`을 포함한 패널의 크기
11157 * 이 값은 {@link Flicking#horizontal horizontal}이 `true`일 경우 margin left/right을 포함하고, `false`일 경우 margin top/bottom을 포함합니다
11158 * @type {number}
11159 * @readonly
11160 */
11161 get: function () {
11162 return this._size + this._margin.prev + this._margin.next;
11163 },
11164 enumerable: false,
11165 configurable: true
11166 });
11167 Object.defineProperty(__proto, "height", {
11168 /**
11169 * Height of the panel element
11170 * @ko 패널 엘리먼트의 높이
11171 * @type {number}
11172 * @readonly
11173 */
11174 get: function () {
11175 return this._height;
11176 },
11177 enumerable: false,
11178 configurable: true
11179 });
11180 Object.defineProperty(__proto, "margin", {
11181 /**
11182 * Cached CSS `margin` value of the panel element
11183 * @ko 패널 엘리먼트의 CSS `margin` 값
11184 * @type {object}
11185 * @property {number} prev CSS `margin-left` when the {@link Flicking#horizontal horizontal} is `true`, and `margin-top` else
11186 * <ko>{@link Flicking#horizontal horizontal}이 `true`일 경우 `margin-left`, `false`일 경우 `margin-top`에 해당하는 값</ko>
11187 * @property {number} next CSS `margin-right` when the {@link Flicking#horizontal horizontal} is `true`, and `margin-bottom` else
11188 * <ko>{@link Flicking#horizontal horizontal}이 `true`일 경우 `margin-right`, `false`일 경우 `margin-bottom`에 해당하는 값</ko>
11189 * @readonly
11190 */
11191 get: function () {
11192 return this._margin;
11193 },
11194 enumerable: false,
11195 configurable: true
11196 });
11197 Object.defineProperty(__proto, "alignPosition", {
11198 /**
11199 * Align position inside the panel where {@link Camera}'s {@link Camera#alignPosition alignPosition} inside viewport should be located at
11200 * @ko 패널의 정렬 기준 위치. {@link Camera}의 뷰포트 내에서의 {@link Camera#alignPosition alignPosition}이 위치해야 하는 곳입니다
11201 * @type {number}
11202 * @readonly
11203 */
11204 get: function () {
11205 return this._alignPos;
11206 },
11207 enumerable: false,
11208 configurable: true
11209 });
11210 Object.defineProperty(__proto, "removed", {
11211 /**
11212 * A value indicating whether the panel's {@link Flicking#remove remove}d
11213 * @ko 패널이 {@link Flicking#remove remove}되었는지 여부를 나타내는 값
11214 * @type {boolean}
11215 * @readonly
11216 */
11217 get: function () {
11218 return this._removed;
11219 },
11220 enumerable: false,
11221 configurable: true
11222 });
11223 Object.defineProperty(__proto, "rendered", {
11224 /**
11225 * A value indicating whether the panel's element is being rendered on the screen
11226 * @ko 패널의 엘리먼트가 화면상에 렌더링되고있는지 여부를 나타내는 값
11227 * @type {boolean}
11228 * @readonly
11229 */
11230 get: function () {
11231 return this._rendered;
11232 },
11233 enumerable: false,
11234 configurable: true
11235 });
11236 Object.defineProperty(__proto, "loading", {
11237 /**
11238 * A value indicating whether the panel's image/video is not loaded and waiting for resize
11239 * @ko 패널 내부의 이미지/비디오가 아직 로드되지 않아 {@link Panel#resize resize}될 것인지를 나타내는 값
11240 * @type {boolean}
11241 * @readonly
11242 */
11243 get: function () {
11244 return this._loading;
11245 },
11246 set: function (val) {
11247 this._loading = val;
11248 },
11249 enumerable: false,
11250 configurable: true
11251 });
11252 Object.defineProperty(__proto, "range", {
11253 /**
11254 * Panel element's range of the bounding box
11255 * @ko 패널 엘리먼트의 Bounding box 범위
11256 * @type {object}
11257 * @property {number} [min] Bounding box's left({@link Flicking#horizontal horizontal}: true) / top({@link Flicking#horizontal horizontal}: false)
11258 * @property {number} [max] Bounding box's right({@link Flicking#horizontal horizontal}: true) / bottom({@link Flicking#horizontal horizontal}: false)
11259 * @readonly
11260 */
11261 get: function () {
11262 return {
11263 min: this._pos,
11264 max: this._pos + this._size
11265 };
11266 },
11267 enumerable: false,
11268 configurable: true
11269 });
11270 Object.defineProperty(__proto, "toggled", {
11271 /**
11272 * A value indicating whether the panel's position is toggled by circular behavior
11273 * @ko 패널의 위치가 circular 동작에 의해 토글되었는지 여부를 나타내는 값
11274 * @type {boolean}
11275 * @readonly
11276 */
11277 get: function () {
11278 return this._toggled;
11279 },
11280 enumerable: false,
11281 configurable: true
11282 });
11283 Object.defineProperty(__proto, "toggleDirection", {
11284 /**
11285 * A direction where the panel's position is toggled
11286 * @ko 패널의 위치가 circular 동작에 의해 토글되는 방향
11287 * @type {DIRECTION}
11288 * @readonly
11289 */
11290 get: function () {
11291 return this._toggleDirection;
11292 },
11293 enumerable: false,
11294 configurable: true
11295 });
11296 Object.defineProperty(__proto, "offset", {
11297 /**
11298 * Actual position offset determined by {@link Panel#order}
11299 * @ko {@link Panel#order}에 의한 실제 위치 변경값
11300 * @type {number}
11301 * @readonly
11302 */
11303 get: function () {
11304 var toggleDirection = this._toggleDirection;
11305 var cameraRangeDiff = this._flicking.camera.rangeDiff;
11306 return toggleDirection === DIRECTION.NONE || !this._toggled ? 0 : toggleDirection === DIRECTION.PREV ? -cameraRangeDiff : cameraRangeDiff;
11307 },
11308 enumerable: false,
11309 configurable: true
11310 });
11311 Object.defineProperty(__proto, "progress", {
11312 /**
11313 * Progress of movement between previous or next panel relative to current panel
11314 * @ko 이 패널로부터 이전/다음 패널으로의 이동 진행률
11315 * @type {number}
11316 * @readonly
11317 */
11318 get: function () {
11319 var flicking = this._flicking;
11320 return this.index - flicking.camera.progress;
11321 },
11322 enumerable: false,
11323 configurable: true
11324 });
11325 Object.defineProperty(__proto, "outsetProgress", {
11326 /**
11327 * Progress of movement between points that panel is completely invisible outside of viewport(prev direction: -1, selected point: 0, next direction: 1)
11328 * @ko 현재 패널이 뷰포트 영역 밖으로 완전히 사라지는 지점을 기준으로 하는 진행도(prev방향: -1, 선택 지점: 0, next방향: 1)
11329 * @type {number}
11330 * @readonly
11331 */
11332 get: function () {
11333 var position = this.position + this.offset;
11334 var alignPosition = this._alignPos;
11335 var camera = this._flicking.camera;
11336 var camPos = camera.position;
11337
11338 if (camPos === position) {
11339 return 0;
11340 }
11341
11342 if (camPos < position) {
11343 var disappearPosNext = position + (camera.size - camera.alignPosition) + alignPosition;
11344 return -getProgress(camPos, position, disappearPosNext);
11345 } else {
11346 var disappearPosPrev = position - (camera.alignPosition + this._size - alignPosition);
11347 return 1 - getProgress(camPos, disappearPosPrev, position);
11348 }
11349 },
11350 enumerable: false,
11351 configurable: true
11352 });
11353 Object.defineProperty(__proto, "visibleRatio", {
11354 /**
11355 * Percentage of area where panel is visible in the viewport
11356 * @ko 뷰포트 안에서 패널이 보이는 영역의 비율
11357 * @type {number}
11358 * @readonly
11359 */
11360 get: function () {
11361 var range = this.range;
11362 var size = this._size;
11363 var offset = this.offset;
11364 var visibleRange = this._flicking.camera.visibleRange;
11365 var checkingRange = {
11366 min: range.min + offset,
11367 max: range.max + offset
11368 };
11369
11370 if (checkingRange.max <= visibleRange.min || checkingRange.min >= visibleRange.max) {
11371 return 0;
11372 }
11373
11374 var visibleSize = size;
11375
11376 if (visibleRange.min > checkingRange.min) {
11377 visibleSize -= visibleRange.min - checkingRange.min;
11378 }
11379
11380 if (visibleRange.max < checkingRange.max) {
11381 visibleSize -= checkingRange.max - visibleRange.max;
11382 }
11383
11384 return visibleSize / size;
11385 },
11386 enumerable: false,
11387 configurable: true
11388 });
11389 Object.defineProperty(__proto, "align", {
11390 // Options Getter
11391
11392 /**
11393 * A value indicating where the {@link Panel#alignPosition alignPosition} should be located at inside the panel element
11394 * @ko {@link Panel#alignPosition alignPosition}이 패널 내의 어디에 위치해야 하는지를 나타내는 값
11395 * @type {Constants.ALIGN | string | number}
11396 */
11397 get: function () {
11398 return this._align;
11399 },
11400 // Options Setter
11401 set: function (val) {
11402 this._align = val;
11403 },
11404 enumerable: false,
11405 configurable: true
11406 });
11407 /**
11408 * Mark panel element to be appended on the camera element
11409 * @internal
11410 */
11411
11412 __proto.markForShow = function () {
11413 this._rendered = true;
11414
11415 this._elProvider.show(this._flicking);
11416 };
11417 /**
11418 * Mark panel element to be removed from the camera element
11419 * @internal
11420 */
11421
11422
11423 __proto.markForHide = function () {
11424 this._rendered = false;
11425
11426 this._elProvider.hide(this._flicking);
11427 };
11428 /**
11429 * Update size of the panel
11430 * @ko 패널의 크기를 갱신합니다
11431 * @param {object} cached Predefined cached size of the panel<ko>사전에 캐시된 패널의 크기 정보</ko>
11432 * @chainable
11433 * @return {this}
11434 */
11435
11436
11437 __proto.resize = function (cached) {
11438 var _a;
11439
11440 var el = this.element;
11441 var flicking = this._flicking;
11442 var horizontal = flicking.horizontal,
11443 useFractionalSize = flicking.useFractionalSize;
11444
11445 if (cached) {
11446 this._size = cached.size;
11447 this._margin = __assign$2({}, cached.margin);
11448 this._height = (_a = cached.height) !== null && _a !== void 0 ? _a : getElementSize({
11449 el: el,
11450 horizontal: false,
11451 useFractionalSize: useFractionalSize,
11452 useOffset: true,
11453 style: getStyle(el)
11454 });
11455 } else {
11456 var elStyle = getStyle(el);
11457 this._size = getElementSize({
11458 el: el,
11459 horizontal: horizontal,
11460 useFractionalSize: useFractionalSize,
11461 useOffset: true,
11462 style: elStyle
11463 });
11464 this._margin = horizontal ? {
11465 prev: parseFloat(elStyle.marginLeft || "0"),
11466 next: parseFloat(elStyle.marginRight || "0")
11467 } : {
11468 prev: parseFloat(elStyle.marginTop || "0"),
11469 next: parseFloat(elStyle.marginBottom || "0")
11470 };
11471 this._height = horizontal ? getElementSize({
11472 el: el,
11473 horizontal: false,
11474 useFractionalSize: useFractionalSize,
11475 useOffset: true,
11476 style: elStyle
11477 }) : this._size;
11478 }
11479
11480 this.updatePosition();
11481
11482 this._updateAlignPos();
11483
11484 return this;
11485 };
11486 /**
11487 * Change panel's size. This will change the actual size of the panel element by changing its CSS width/height property
11488 * @ko 패널 크기를 변경합니다. 패널 엘리먼트에 해당 크기의 CSS width/height를 적용합니다
11489 * @param {object} [size] New panel size<ko>새 패널 크기</ko>
11490 * @param {number|string} [size.width] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
11491 * @param {number|string} [size.height] CSS string or number(in px)<ko>CSS 문자열 또는 숫자(px)</ko>
11492 * @chainable
11493 * @return {this}
11494 */
11495
11496
11497 __proto.setSize = function (size) {
11498 setSize(this.element, size);
11499 return this;
11500 };
11501 /**
11502 * Check whether the given element is inside of this panel's {@link Panel#element element}
11503 * @ko 해당 엘리먼트가 이 패널의 {@link Panel#element element} 내에 포함되어 있는지를 반환합니다
11504 * @param {HTMLElement} element The HTMLElement to check<ko>확인하고자 하는 HTMLElement</ko>
11505 * @return {boolean} A Boolean value indicating the element is inside of this panel {@link Panel#element element}<ko>패널의 {@link Panel#element element}내에 해당 엘리먼트 포함 여부</ko>
11506 */
11507
11508
11509 __proto.contains = function (element) {
11510 var _a;
11511
11512 return !!((_a = this.element) === null || _a === void 0 ? void 0 : _a.contains(element));
11513 };
11514 /**
11515 * Reset internal state and set {@link Panel#removed removed} to `true`
11516 * @ko 내부 상태를 초기화하고 {@link Panel#removed removed}를 `true`로 설정합니다.
11517 * @return {void}
11518 */
11519
11520
11521 __proto.destroy = function () {
11522 this._resetInternalStates();
11523
11524 this._removed = true;
11525 };
11526 /**
11527 * Check whether the given position is inside of this panel's {@link Panel#range range}
11528 * @ko 주어진 좌표가 현재 패널의 {@link Panel#range range}내에 속해있는지를 반환합니다.
11529 * @param {number} pos A position to check<ko>확인하고자 하는 좌표</ko>
11530 * @param {boolean} [includeMargin=false] Include {@link Panel#margin margin} to the range<ko>패널 영역에 {@link Panel#margin margin}값을 포함시킵니다</ko>
11531 * @return {boolean} A Boolean value indicating whether the given position is included in the panel range<ko>해당 좌표가 패널 영역 내에 속해있는지 여부</ko>
11532 */
11533
11534
11535 __proto.includePosition = function (pos, includeMargin) {
11536 if (includeMargin === void 0) {
11537 includeMargin = false;
11538 }
11539
11540 return this.includeRange(pos, pos, includeMargin);
11541 };
11542 /**
11543 * Check whether the given range is fully included in this panel's area (inclusive)
11544 * @ko 주어진 범위가 이 패널 내부에 완전히 포함되는지를 반환합니다
11545 * @param {number} min Minimum value of the range to check<ko>확인하고자 하는 최소 범위</ko>
11546 * @param {number} max Maximum value of the range to check<ko>확인하고자 하는 최대 범위</ko>
11547 * @param {boolean} [includeMargin=false] Include {@link Panel#margin margin} to the range<ko>패널 영역에 {@link Panel#margin margin}값을 포함시킵니다</ko>
11548 * @returns {boolean} A Boolean value indicating whether the given range is fully included in the panel range<ko>해당 범위가 패널 영역 내에 완전히 속해있는지 여부</ko>
11549 */
11550
11551
11552 __proto.includeRange = function (min, max, includeMargin) {
11553 if (includeMargin === void 0) {
11554 includeMargin = false;
11555 }
11556
11557 var margin = this._margin;
11558 var panelRange = this.range;
11559
11560 if (includeMargin) {
11561 panelRange.min -= margin.prev;
11562 panelRange.max += margin.next;
11563 }
11564
11565 return max >= panelRange.min && min <= panelRange.max;
11566 };
11567 /**
11568 * Check whether the panel is visble in the given range (exclusive)
11569 * @ko 주어진 범위 내에서 이 패널의 일부가 보여지는지를 반환합니다
11570 * @param {number} min Minimum value of the range to check<ko>확인하고자 하는 최소 범위</ko>
11571 * @param {number} max Maximum value of the range to check<ko>확인하고자 하는 최대 범위</ko>
11572 * @returns {boolean} A Boolean value indicating whether the panel is visible<ko>해당 범위 내에서 패널을 볼 수 있는지 여부</ko>
11573 */
11574
11575
11576 __proto.isVisibleOnRange = function (min, max) {
11577 var panelRange = this.range;
11578 return max > panelRange.min && min < panelRange.max;
11579 };
11580 /**
11581 * Move {@link Camera} to this panel
11582 * @ko {@link Camera}를 이 패널로 이동합니다
11583 * @param {number} [duration] Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
11584 * @returns {Promise<void>} A Promise which will be resolved after reaching the panel<ko>패널 도달시에 resolve되는 Promise</ko>
11585 */
11586
11587
11588 __proto.focus = function (duration) {
11589 return this._flicking.moveTo(this._index, duration);
11590 };
11591 /**
11592 * Get previous(`index - 1`) panel. When the previous panel does not exist, this will return `null` instead
11593 * If the {@link Flicking#circularEnabled circular} is enabled, this will return the last panel if called from the first panel
11594 * @ko 이전(`index - 1`) 패널을 반환합니다. 이전 패널이 없을 경우 `null`을 반환합니다
11595 * {@link Flicking#circularEnabled circular} 모드가 활성화되었을 때 첫번째 패널에서 이 메소드를 호출할 경우 마지막 패널을 반환합니다
11596 * @returns {Panel | null} The previous panel<ko>이전 패널</ko>
11597 */
11598
11599
11600 __proto.prev = function () {
11601 var index = this._index;
11602 var flicking = this._flicking;
11603 var renderer = flicking.renderer;
11604 var panelCount = renderer.panelCount;
11605 if (panelCount === 1) return null;
11606 return flicking.circularEnabled ? renderer.getPanel(index === 0 ? panelCount - 1 : index - 1) : renderer.getPanel(index - 1);
11607 };
11608 /**
11609 * Get next(`index + 1`) panel. When the next panel does not exist, this will return `null` instead
11610 * If the {@link Flicking#circularEnabled circular} is enabled, this will return the first panel if called from the last panel
11611 * @ko 다음(`index + 1`) 패널을 반환합니다. 다음 패널이 없을 경우 `null`을 반환합니다
11612 * {@link Flicking#circularEnabled circular} 모드가 활성화되었을 때 마지막 패널에서 이 메소드를 호출할 경우 첫번째 패널을 반환합니다
11613 * @returns {Panel | null} The previous panel<ko>다음 패널</ko>
11614 */
11615
11616
11617 __proto.next = function () {
11618 var index = this._index;
11619 var flicking = this._flicking;
11620 var renderer = flicking.renderer;
11621 var panelCount = renderer.panelCount;
11622 if (panelCount === 1) return null;
11623 return flicking.circularEnabled ? renderer.getPanel(index === panelCount - 1 ? 0 : index + 1) : renderer.getPanel(index + 1);
11624 };
11625 /**
11626 * Increase panel's index by the given value
11627 * @ko 패널의 인덱스를 주어진 값만큼 증가시킵니다
11628 * @internal
11629 * @chainable
11630 * @param val An integer greater than or equal to 0<ko>0보다 같거나 큰 정수</ko>
11631 * @returns {this}
11632 */
11633
11634
11635 __proto.increaseIndex = function (val) {
11636 this._index += Math.max(val, 0);
11637 return this;
11638 };
11639 /**
11640 * Decrease panel's index by the given value
11641 * @ko 패널의 인덱스를 주어진 값만큼 감소시킵니다
11642 * @internal
11643 * @chainable
11644 * @param val An integer greater than or equal to 0<ko>0보다 같거나 큰 정수</ko>
11645 * @returns {this}
11646 */
11647
11648
11649 __proto.decreaseIndex = function (val) {
11650 this._index -= Math.max(val, 0);
11651 return this;
11652 };
11653 /**
11654 * @internal
11655 */
11656
11657
11658 __proto.updatePosition = function () {
11659 var prevPanel = this._flicking.renderer.panels[this._index - 1];
11660 this._pos = prevPanel ? prevPanel.range.max + prevPanel.margin.next + this._margin.prev : this._margin.prev;
11661 return this;
11662 };
11663 /**
11664 * @internal
11665 * @return {boolean} toggled
11666 */
11667
11668
11669 __proto.toggle = function (prevPos, newPos) {
11670 var toggleDirection = this._toggleDirection;
11671 var togglePosition = this._togglePosition;
11672 if (toggleDirection === DIRECTION.NONE || newPos === prevPos) return false;
11673 var prevToggled = this._toggled;
11674
11675 if (newPos > prevPos) {
11676 if (togglePosition >= prevPos && togglePosition <= newPos) {
11677 this._toggled = toggleDirection === DIRECTION.NEXT;
11678 }
11679 } else {
11680 if (togglePosition <= prevPos && togglePosition >= newPos) {
11681 this._toggled = toggleDirection !== DIRECTION.NEXT;
11682 }
11683 }
11684
11685 return prevToggled !== this._toggled;
11686 };
11687 /**
11688 * @internal
11689 */
11690
11691
11692 __proto.updateCircularToggleDirection = function () {
11693 var flicking = this._flicking;
11694
11695 if (!flicking.circularEnabled) {
11696 this._toggleDirection = DIRECTION.NONE;
11697 this._toggled = false;
11698 return this;
11699 }
11700
11701 var camera = flicking.camera;
11702 var camRange = camera.range;
11703 var camAlignPosition = camera.alignPosition;
11704 var camVisibleRange = camera.visibleRange;
11705 var camVisibleSize = camVisibleRange.max - camVisibleRange.min;
11706 var minimumVisible = camRange.min - camAlignPosition;
11707 var maximumVisible = camRange.max - camAlignPosition + camVisibleSize;
11708 var shouldBeVisibleAtMin = this.includeRange(maximumVisible - camVisibleSize, maximumVisible, false);
11709 var shouldBeVisibleAtMax = this.includeRange(minimumVisible, minimumVisible + camVisibleSize, false);
11710 this._toggled = false;
11711
11712 if (shouldBeVisibleAtMin) {
11713 this._toggleDirection = DIRECTION.PREV;
11714 this._togglePosition = this.range.max + camRange.min - camRange.max + camAlignPosition;
11715 this.toggle(Infinity, camera.position);
11716 } else if (shouldBeVisibleAtMax) {
11717 this._toggleDirection = DIRECTION.NEXT;
11718 this._togglePosition = this.range.min + camRange.max - camVisibleSize + camAlignPosition;
11719 this.toggle(-Infinity, camera.position);
11720 } else {
11721 this._toggleDirection = DIRECTION.NONE;
11722 this._togglePosition = 0;
11723 }
11724
11725 return this;
11726 };
11727
11728 __proto._updateAlignPos = function () {
11729 this._alignPos = parseAlign$1(this._align, this._size);
11730 };
11731
11732 __proto._resetInternalStates = function () {
11733 this._size = 0;
11734 this._pos = 0;
11735 this._margin = {
11736 prev: 0,
11737 next: 0
11738 };
11739 this._height = 0;
11740 this._alignPos = 0;
11741 this._toggled = false;
11742 this._togglePosition = 0;
11743 this._toggleDirection = DIRECTION.NONE;
11744 };
11745
11746 return Panel;
11747 }();
11748
11749 var NormalRenderingStrategy =
11750 /*#__PURE__*/
11751 function () {
11752 function NormalRenderingStrategy(_a) {
11753 var providerCtor = _a.providerCtor;
11754 this._providerCtor = providerCtor;
11755 }
11756
11757 var __proto = NormalRenderingStrategy.prototype;
11758
11759 __proto.renderPanels = function () {// DO_NOTHING
11760 };
11761
11762 __proto.getRenderingIndexesByOrder = function (flicking) {
11763 var renderedPanels = flicking.renderer.panels.filter(function (panel) {
11764 return panel.rendered;
11765 });
11766 var toggledPrev = renderedPanels.filter(function (panel) {
11767 return panel.toggled && panel.toggleDirection === DIRECTION.PREV;
11768 });
11769 var toggledNext = renderedPanels.filter(function (panel) {
11770 return panel.toggled && panel.toggleDirection === DIRECTION.NEXT;
11771 });
11772 var notToggled = renderedPanels.filter(function (panel) {
11773 return !panel.toggled;
11774 });
11775 return __spread$1(toggledPrev, notToggled, toggledNext).map(function (panel) {
11776 return panel.index;
11777 });
11778 };
11779
11780 __proto.getRenderingElementsByOrder = function (flicking) {
11781 var panels = flicking.panels;
11782 return this.getRenderingIndexesByOrder(flicking).map(function (index) {
11783 return panels[index].element;
11784 });
11785 };
11786
11787 __proto.updateRenderingPanels = function (flicking) {
11788 if (flicking.renderOnlyVisible) {
11789 this._showOnlyVisiblePanels(flicking);
11790 } else {
11791 flicking.panels.forEach(function (panel) {
11792 return panel.markForShow();
11793 });
11794 }
11795 };
11796
11797 __proto.collectPanels = function (flicking, elements) {
11798 var _this = this;
11799
11800 var align = parsePanelAlign(flicking.renderer.align);
11801 return elements.map(function (el, index) {
11802 return new Panel({
11803 index: index,
11804 elementProvider: new _this._providerCtor(el),
11805 align: align,
11806 flicking: flicking
11807 });
11808 });
11809 };
11810
11811 __proto.createPanel = function (element, options) {
11812 return new Panel(__assign$2(__assign$2({}, options), {
11813 elementProvider: new this._providerCtor(element)
11814 }));
11815 };
11816
11817 __proto.updatePanelSizes = function (flicking, size) {
11818 flicking.panels.forEach(function (panel) {
11819 return panel.setSize(size);
11820 });
11821 };
11822
11823 __proto._showOnlyVisiblePanels = function (flicking) {
11824 var panels = flicking.renderer.panels;
11825 var camera = flicking.camera;
11826 var visibleIndexes = camera.visiblePanels.reduce(function (visibles, panel) {
11827 visibles[panel.index] = true;
11828 return visibles;
11829 }, {});
11830 panels.forEach(function (panel) {
11831 if (panel.index in visibleIndexes || panel.loading) {
11832 panel.markForShow();
11833 } else if (!flicking.holding) {
11834 // During the input sequence,
11835 // Do not remove panel elements as it won't trigger touchend event.
11836 panel.markForHide();
11837 }
11838 });
11839 camera.updateOffset();
11840 };
11841
11842 return NormalRenderingStrategy;
11843 }();
11844
11845 /**
11846 * An slide data component that holds information of a single HTMLElement
11847 * @ko 슬라이드 데이터 컴포넌트로, 단일 HTMLElement의 정보를 갖고 있습니다
11848 */
11849
11850 var VirtualPanel =
11851 /*#__PURE__*/
11852 function (_super) {
11853 __extends$2(VirtualPanel, _super);
11854 /**
11855 * @param {object} options An options object<ko>옵션 오브젝트</ko>
11856 * @param {number} [options.index] An initial index of the panel<ko>패널의 초기 인덱스</ko>
11857 * @param {Constants.ALIGN | string | number} [options.align] An initial {@link Flicking#align align} value of the panel<ko>패널의 초기 {@link Flicking#align align}값</ko>
11858 * @param {Flicking} [options.flicking] A Flicking instance panel's referencing<ko>패널이 참조하는 {@link Flicking} 인스턴스</ko>
11859 */
11860
11861
11862 function VirtualPanel(options) {
11863 var _this = _super.call(this, options) || this;
11864
11865 options.elementProvider.init(_this);
11866 _this._elProvider = options.elementProvider;
11867 _this._cachedInnerHTML = null;
11868 return _this;
11869 }
11870
11871 var __proto = VirtualPanel.prototype;
11872 Object.defineProperty(__proto, "element", {
11873 /**
11874 * `HTMLElement` that panel's referencing
11875 * @ko 패널이 참조하고 있는 `HTMLElement`
11876 * @type {HTMLElement}
11877 * @readonly
11878 */
11879 get: function () {
11880 return this._elProvider.element;
11881 },
11882 enumerable: false,
11883 configurable: true
11884 });
11885 Object.defineProperty(__proto, "cachedInnerHTML", {
11886 /**
11887 * Cached innerHTML by the previous render function
11888 * @ko 이전 렌더링에서 캐시된 innerHTML 정보
11889 * @type {string|null}
11890 * @readonly
11891 */
11892 get: function () {
11893 return this._cachedInnerHTML;
11894 },
11895 enumerable: false,
11896 configurable: true
11897 });
11898 Object.defineProperty(__proto, "elementIndex", {
11899 /**
11900 * An number for indexing which element it will be rendered on
11901 * @ko 몇 번째 엘리먼트에 렌더링될 것인지를 나타내는 숫자
11902 * @type {number}
11903 * @readonly
11904 */
11905 get: function () {
11906 var flicking = this._flicking;
11907 var virtualElCount = flicking.panelsPerView + 1;
11908 var panelCount = flicking.panelCount;
11909 var index = this._index;
11910
11911 if (this._toggled) {
11912 // To prevent element duplication
11913 index = this._toggleDirection === DIRECTION.NEXT ? index + panelCount : index - panelCount;
11914 }
11915
11916 return circulateIndex(index, virtualElCount);
11917 },
11918 enumerable: false,
11919 configurable: true
11920 });
11921
11922 __proto.cacheRenderResult = function (result) {
11923 this._cachedInnerHTML = result;
11924 };
11925
11926 __proto.uncacheRenderResult = function () {
11927 this._cachedInnerHTML = null;
11928 };
11929
11930 __proto.render = function () {
11931 var flicking = this._flicking;
11932 var _a = flicking.virtual,
11933 renderPanel = _a.renderPanel,
11934 cache = _a.cache;
11935 var element = this._elProvider.element;
11936 var newInnerHTML = this._cachedInnerHTML || renderPanel(this, this._index);
11937 if (newInnerHTML === element.innerHTML) return;
11938 element.innerHTML = newInnerHTML;
11939
11940 if (cache) {
11941 this.cacheRenderResult(newInnerHTML);
11942 }
11943 };
11944
11945 __proto.increaseIndex = function (val) {
11946 this.uncacheRenderResult();
11947 return _super.prototype.increaseIndex.call(this, val);
11948 };
11949
11950 __proto.decreaseIndex = function (val) {
11951 this.uncacheRenderResult();
11952 return _super.prototype.decreaseIndex.call(this, val);
11953 };
11954
11955 return VirtualPanel;
11956 }(Panel);
11957
11958 var VirtualRenderingStrategy =
11959 /*#__PURE__*/
11960 function () {
11961 function VirtualRenderingStrategy() {}
11962
11963 var __proto = VirtualRenderingStrategy.prototype;
11964
11965 __proto.renderPanels = function (flicking) {
11966 var virtualManager = flicking.virtual;
11967 var visiblePanels = flicking.visiblePanels;
11968 var invisibleIndexes = range(flicking.panelsPerView + 1);
11969 visiblePanels.forEach(function (panel) {
11970 var elementIndex = panel.elementIndex;
11971 panel.render();
11972 virtualManager.show(elementIndex);
11973 invisibleIndexes[elementIndex] = -1;
11974 });
11975 invisibleIndexes.filter(function (val) {
11976 return val >= 0;
11977 }).forEach(function (idx) {
11978 virtualManager.hide(idx);
11979 });
11980 };
11981
11982 __proto.getRenderingIndexesByOrder = function (flicking) {
11983 var virtualManager = flicking.virtual;
11984
11985 var visiblePanels = __spread$1(flicking.visiblePanels).filter(function (panel) {
11986 return panel.rendered;
11987 }).sort(function (panel1, panel2) {
11988 return panel1.position + panel1.offset - (panel2.position + panel2.offset);
11989 });
11990
11991 if (visiblePanels.length <= 0) return virtualManager.elements.map(function (_, idx) {
11992 return idx;
11993 });
11994 var visibleIndexes = visiblePanels.map(function (panel) {
11995 return panel.elementIndex;
11996 });
11997 var invisibleIndexes = virtualManager.elements.map(function (el, idx) {
11998 return __assign$2(__assign$2({}, el), {
11999 idx: idx
12000 });
12001 }).filter(function (el) {
12002 return !el.visible;
12003 }).map(function (el) {
12004 return el.idx;
12005 });
12006 return __spread$1(visibleIndexes, invisibleIndexes);
12007 };
12008
12009 __proto.getRenderingElementsByOrder = function (flicking) {
12010 var virtualManager = flicking.virtual;
12011 var elements = virtualManager.elements;
12012 return this.getRenderingIndexesByOrder(flicking).map(function (index) {
12013 return elements[index].nativeElement;
12014 });
12015 };
12016
12017 __proto.updateRenderingPanels = function (flicking) {
12018 var panels = flicking.renderer.panels;
12019 var camera = flicking.camera;
12020 var visibleIndexes = camera.visiblePanels.reduce(function (visibles, panel) {
12021 visibles[panel.index] = true;
12022 return visibles;
12023 }, {});
12024 panels.forEach(function (panel) {
12025 if (panel.index in visibleIndexes || panel.loading) {
12026 panel.markForShow();
12027 } else {
12028 panel.markForHide();
12029 }
12030 });
12031 camera.updateOffset();
12032 };
12033
12034 __proto.collectPanels = function (flicking) {
12035 var align = parsePanelAlign(flicking.renderer.align);
12036 return range(flicking.virtual.initialPanelCount).map(function (index) {
12037 return new VirtualPanel({
12038 index: index,
12039 elementProvider: new VirtualElementProvider(flicking),
12040 align: align,
12041 flicking: flicking
12042 });
12043 });
12044 };
12045
12046 __proto.createPanel = function (_el, options) {
12047 return new VirtualPanel(__assign$2(__assign$2({}, options), {
12048 elementProvider: new VirtualElementProvider(options.flicking)
12049 }));
12050 };
12051
12052 __proto.updatePanelSizes = function (flicking, size) {
12053 flicking.virtual.elements.forEach(function (el) {
12054 setSize(el.nativeElement, size);
12055 });
12056 flicking.panels.forEach(function (panel) {
12057 return panel.setSize(size);
12058 });
12059 };
12060
12061 return VirtualRenderingStrategy;
12062 }();
12063
12064 /*
12065 * Copyright (c) 2015 NAVER Corp.
12066 * egjs projects are licensed under the MIT license
12067 */
12068
12069 var Renderer = {
12070 __proto__: null,
12071 Renderer: Renderer$1,
12072 VanillaRenderer: VanillaRenderer,
12073 ExternalRenderer: ExternalRenderer,
12074 NormalRenderingStrategy: NormalRenderingStrategy,
12075 VirtualRenderingStrategy: VirtualRenderingStrategy
12076 };
12077
12078 /**
12079 * @extends Component
12080 * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
12081 * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
12082 * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
12083 */
12084
12085 var Flicking =
12086 /*#__PURE__*/
12087 function (_super) {
12088 __extends$2(Flicking, _super);
12089 /**
12090 * @param root A root HTMLElement to initialize Flicking on it. When it's a typeof `string`, it should be a css selector string
12091 * <ko>Flicking을 초기화할 HTMLElement로, `string` 타입으로 지정시 css 선택자 문자열을 지정해야 합니다.</ko>
12092 * @param {object} [options={}] An options object for Flicking.<ko>Flicking에 적용할 옵션 오브젝트</ko>
12093 * @throws {FlickingError}
12094 * |code|condition|
12095 * |---|---|
12096 * |{@link ERROR_CODE WRONG_TYPE}|When the root is not either string or HTMLElement|
12097 * |{@link ERROR_CODE ELEMENT_NOT_FOUND}|When the element with given CSS selector does not exist|
12098 * <ko>
12099 *
12100 * |code|조건|
12101 * |---|---|
12102 * |{@link ERROR_CODE WRONG_TYPE}|루트 엘리먼트가 string이나 HTMLElement가 아닐 경우|
12103 * |{@link ERROR_CODE ELEMENT_NOT_FOUND}|주어진 CSS selector로 엘리먼트를 찾지 못했을 경우|
12104 *
12105 * </ko>
12106 * @example
12107 * ```ts
12108 * import Flicking from "@egjs/flicking";
12109 *
12110 * // Creating new instance of Flicking with HTMLElement
12111 * const flicking = new Flicking(document.querySelector(".flicking-viewport"), { circular: true });
12112 *
12113 * // Creating new instance of Flicking with CSS selector
12114 * const flicking2 = new Flicking(".flicking-viewport", { circular: true });
12115 * ```
12116 */
12117
12118
12119 function Flicking(root, _a) {
12120 var _b = _a === void 0 ? {} : _a,
12121 _c = _b.align,
12122 align = _c === void 0 ? ALIGN.CENTER : _c,
12123 _d = _b.defaultIndex,
12124 defaultIndex = _d === void 0 ? 0 : _d,
12125 _e = _b.horizontal,
12126 horizontal = _e === void 0 ? true : _e,
12127 _f = _b.circular,
12128 circular = _f === void 0 ? false : _f,
12129 _g = _b.circularFallback,
12130 circularFallback = _g === void 0 ? CIRCULAR_FALLBACK.LINEAR : _g,
12131 _h = _b.bound,
12132 bound = _h === void 0 ? false : _h,
12133 _j = _b.adaptive,
12134 adaptive = _j === void 0 ? false : _j,
12135 _k = _b.panelsPerView,
12136 panelsPerView = _k === void 0 ? -1 : _k,
12137 _l = _b.noPanelStyleOverride,
12138 noPanelStyleOverride = _l === void 0 ? false : _l,
12139 _m = _b.resizeOnContentsReady,
12140 resizeOnContentsReady = _m === void 0 ? false : _m,
12141 _o = _b.nested,
12142 nested = _o === void 0 ? false : _o,
12143 _p = _b.needPanelThreshold,
12144 needPanelThreshold = _p === void 0 ? 0 : _p,
12145 _q = _b.preventEventsBeforeInit,
12146 preventEventsBeforeInit = _q === void 0 ? true : _q,
12147 _r = _b.deceleration,
12148 deceleration = _r === void 0 ? 0.0075 : _r,
12149 _s = _b.duration,
12150 duration = _s === void 0 ? 500 : _s,
12151 _t = _b.easing,
12152 easing = _t === void 0 ? function (x) {
12153 return 1 - Math.pow(1 - x, 3);
12154 } : _t,
12155 _u = _b.inputType,
12156 inputType = _u === void 0 ? ["mouse", "touch"] : _u,
12157 _v = _b.moveType,
12158 moveType = _v === void 0 ? "snap" : _v,
12159 _w = _b.threshold,
12160 threshold = _w === void 0 ? 40 : _w,
12161 _x = _b.interruptable,
12162 interruptable = _x === void 0 ? true : _x,
12163 _y = _b.bounce,
12164 bounce = _y === void 0 ? "20%" : _y,
12165 _z = _b.iOSEdgeSwipeThreshold,
12166 iOSEdgeSwipeThreshold = _z === void 0 ? 30 : _z,
12167 _0 = _b.preventClickOnDrag,
12168 preventClickOnDrag = _0 === void 0 ? true : _0,
12169 _1 = _b.disableOnInit,
12170 disableOnInit = _1 === void 0 ? false : _1,
12171 _2 = _b.changeOnHold,
12172 changeOnHold = _2 === void 0 ? false : _2,
12173 _3 = _b.renderOnlyVisible,
12174 renderOnlyVisible = _3 === void 0 ? false : _3,
12175 _4 = _b.virtual,
12176 virtual = _4 === void 0 ? null : _4,
12177 _5 = _b.autoInit,
12178 autoInit = _5 === void 0 ? true : _5,
12179 _6 = _b.autoResize,
12180 autoResize = _6 === void 0 ? true : _6,
12181 _7 = _b.useResizeObserver,
12182 useResizeObserver = _7 === void 0 ? true : _7,
12183 _8 = _b.resizeDebounce,
12184 resizeDebounce = _8 === void 0 ? 0 : _8,
12185 _9 = _b.maxResizeDebounce,
12186 maxResizeDebounce = _9 === void 0 ? 100 : _9,
12187 _10 = _b.useFractionalSize,
12188 useFractionalSize = _10 === void 0 ? false : _10,
12189 _11 = _b.externalRenderer,
12190 externalRenderer = _11 === void 0 ? null : _11,
12191 _12 = _b.renderExternal,
12192 renderExternal = _12 === void 0 ? null : _12;
12193
12194 var _this = _super.call(this) || this; // Internal states
12195
12196
12197 _this._initialized = false;
12198 _this._plugins = []; // Bind options
12199
12200 _this._align = align;
12201 _this._defaultIndex = defaultIndex;
12202 _this._horizontal = horizontal;
12203 _this._circular = circular;
12204 _this._circularFallback = circularFallback;
12205 _this._bound = bound;
12206 _this._adaptive = adaptive;
12207 _this._panelsPerView = panelsPerView;
12208 _this._noPanelStyleOverride = noPanelStyleOverride;
12209 _this._resizeOnContentsReady = resizeOnContentsReady;
12210 _this._nested = nested;
12211 _this._virtual = virtual;
12212 _this._needPanelThreshold = needPanelThreshold;
12213 _this._preventEventsBeforeInit = preventEventsBeforeInit;
12214 _this._deceleration = deceleration;
12215 _this._duration = duration;
12216 _this._easing = easing;
12217 _this._inputType = inputType;
12218 _this._moveType = moveType;
12219 _this._threshold = threshold;
12220 _this._interruptable = interruptable;
12221 _this._bounce = bounce;
12222 _this._iOSEdgeSwipeThreshold = iOSEdgeSwipeThreshold;
12223 _this._preventClickOnDrag = preventClickOnDrag;
12224 _this._disableOnInit = disableOnInit;
12225 _this._changeOnHold = changeOnHold;
12226 _this._renderOnlyVisible = renderOnlyVisible;
12227 _this._autoInit = autoInit;
12228 _this._autoResize = autoResize;
12229 _this._useResizeObserver = useResizeObserver;
12230 _this._resizeDebounce = resizeDebounce;
12231 _this._maxResizeDebounce = maxResizeDebounce;
12232 _this._useFractionalSize = useFractionalSize;
12233 _this._externalRenderer = externalRenderer;
12234 _this._renderExternal = renderExternal; // Create core components
12235
12236 _this._viewport = new Viewport(_this, getElement(root));
12237 _this._autoResizer = new AutoResizer(_this);
12238 _this._renderer = _this._createRenderer();
12239 _this._camera = _this._createCamera();
12240 _this._control = _this._createControl();
12241 _this._virtualManager = new VirtualManager(_this, virtual);
12242
12243 if (_this._autoInit) {
12244 void _this.init();
12245 }
12246
12247 return _this;
12248 }
12249
12250 var __proto = Flicking.prototype;
12251 Object.defineProperty(__proto, "control", {
12252 // Components
12253
12254 /**
12255 * {@link Control} instance of the Flicking
12256 * @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
12257 * @type {Control}
12258 * @default SnapControl
12259 * @readonly
12260 * @see Control
12261 * @see SnapControl
12262 * @see FreeControl
12263 */
12264 get: function () {
12265 return this._control;
12266 },
12267 enumerable: false,
12268 configurable: true
12269 });
12270 Object.defineProperty(__proto, "camera", {
12271 /**
12272 * {@link Camera} instance of the Flicking
12273 * @ko 현재 Flicking에 활성화된 {@link Camera} 인스턴스
12274 * @type {Camera}
12275 * @default LinearCamera
12276 * @readonly
12277 * @see Camera
12278 * @see LinearCamera
12279 * @see BoundCamera
12280 * @see CircularCamera
12281 */
12282 get: function () {
12283 return this._camera;
12284 },
12285 enumerable: false,
12286 configurable: true
12287 });
12288 Object.defineProperty(__proto, "renderer", {
12289 /**
12290 * {@link Renderer} instance of the Flicking
12291 * @ko 현재 Flicking에 활성화된 {@link Renderer} 인스턴스
12292 * @type {Renderer}
12293 * @default VanillaRenderer
12294 * @readonly
12295 * @see Renderer
12296 * @see VanillaRenderer
12297 * @see ExternalRenderer
12298 */
12299 get: function () {
12300 return this._renderer;
12301 },
12302 enumerable: false,
12303 configurable: true
12304 });
12305 Object.defineProperty(__proto, "viewport", {
12306 /**
12307 * A component that manages viewport size
12308 * @ko 뷰포트 크기 정보를 담당하는 컴포넌트
12309 * @type {Viewport}
12310 * @readonly
12311 * @see Viewport
12312 */
12313 get: function () {
12314 return this._viewport;
12315 },
12316 enumerable: false,
12317 configurable: true
12318 });
12319 Object.defineProperty(__proto, "initialized", {
12320 // Internal States
12321
12322 /**
12323 * Whether Flicking's {@link Flicking#init init()} is called.
12324 * This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
12325 * @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
12326 * 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
12327 * @type {boolean}
12328 * @default false
12329 * @readonly
12330 */
12331 get: function () {
12332 return this._initialized;
12333 },
12334 enumerable: false,
12335 configurable: true
12336 });
12337 Object.defineProperty(__proto, "circularEnabled", {
12338 /**
12339 * Whether the `circular` option is enabled.
12340 * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
12341 * @ko {@link Flicking#circular circular} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
12342 * {@link Flicking#circular circular} 옵션은 패널의 크기의 합이 충분하지 않을 경우 비활성화됩니다.
12343 * @type {boolean}
12344 * @default false
12345 * @readonly
12346 */
12347 get: function () {
12348 return this._camera.circularEnabled;
12349 },
12350 enumerable: false,
12351 configurable: true
12352 });
12353 Object.defineProperty(__proto, "virtualEnabled", {
12354 /**
12355 * Whether the `virtual` option is enabled.
12356 * The {@link Flicking#virtual virtual} option can't be enabled when {@link Flicking#panelsPerView panelsPerView} is less or equal than zero.
12357 * @ko {@link Flicking#virtual virtual} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
12358 * {@link Flicking#virtual virtual} 옵션은 {@link Flicking#panelsPerView panelsPerView} 옵션의 값이 0보다 같거나 작으면 비활성화됩니다.
12359 * @type {boolean}
12360 * @default false
12361 * @readonly
12362 */
12363 get: function () {
12364 return this._panelsPerView > 0 && this._virtual != null;
12365 },
12366 enumerable: false,
12367 configurable: true
12368 });
12369 Object.defineProperty(__proto, "index", {
12370 /**
12371 * Index number of the {@link Flicking#currentPanel currentPanel}
12372 * @ko {@link Flicking#currentPanel currentPanel}의 인덱스 번호
12373 * @type {number}
12374 * @default 0
12375 * @readonly
12376 */
12377 get: function () {
12378 return this._control.activeIndex;
12379 },
12380 enumerable: false,
12381 configurable: true
12382 });
12383 Object.defineProperty(__proto, "element", {
12384 /**
12385 * The root(`.flicking-viewport`) element
12386 * @ko root(`.flicking-viewport`) 엘리먼트
12387 * @type {HTMLElement}
12388 * @readonly
12389 */
12390 get: function () {
12391 return this._viewport.element;
12392 },
12393 enumerable: false,
12394 configurable: true
12395 });
12396 Object.defineProperty(__proto, "currentPanel", {
12397 /**
12398 * Currently active panel
12399 * @ko 현재 선택된 패널
12400 * @type {Panel}
12401 * @readonly
12402 * @see Panel
12403 */
12404 get: function () {
12405 return this._control.activePanel;
12406 },
12407 enumerable: false,
12408 configurable: true
12409 });
12410 Object.defineProperty(__proto, "panels", {
12411 /**
12412 * Array of panels
12413 * @ko 전체 패널들의 배열
12414 * @type {Panel[]}
12415 * @readonly
12416 * @see Panel
12417 */
12418 get: function () {
12419 return this._renderer.panels;
12420 },
12421 enumerable: false,
12422 configurable: true
12423 });
12424 Object.defineProperty(__proto, "panelCount", {
12425 /**
12426 * Count of panels
12427 * @ko 전체 패널의 개수
12428 * @type {number}
12429 * @readonly
12430 */
12431 get: function () {
12432 return this._renderer.panelCount;
12433 },
12434 enumerable: false,
12435 configurable: true
12436 });
12437 Object.defineProperty(__proto, "visiblePanels", {
12438 /**
12439 * Array of panels that is visible at the current position
12440 * @ko 현재 보이는 패널의 배열
12441 * @type {Panel[]}
12442 * @readonly
12443 * @see Panel
12444 */
12445 get: function () {
12446 return this._camera.visiblePanels;
12447 },
12448 enumerable: false,
12449 configurable: true
12450 });
12451 Object.defineProperty(__proto, "animating", {
12452 /**
12453 * Whether Flicking's animating
12454 * @ko 현재 애니메이션 동작 여부
12455 * @type {boolean}
12456 * @readonly
12457 */
12458 get: function () {
12459 return this._control.animating;
12460 },
12461 enumerable: false,
12462 configurable: true
12463 });
12464 Object.defineProperty(__proto, "holding", {
12465 /**
12466 * Whether user is clicking or touching
12467 * @ko 현재 사용자가 클릭/터치중인지 여부
12468 * @type {boolean}
12469 * @readonly
12470 */
12471 get: function () {
12472 return this._control.holding;
12473 },
12474 enumerable: false,
12475 configurable: true
12476 });
12477 Object.defineProperty(__proto, "activePlugins", {
12478 /**
12479 * A current list of activated plugins
12480 * @ko 현재 활성화된 플러그인 목록
12481 * @type {Plugin[]}
12482 * @readonly
12483 */
12484 get: function () {
12485 return this._plugins;
12486 },
12487 enumerable: false,
12488 configurable: true
12489 });
12490 Object.defineProperty(__proto, "align", {
12491 // Options Getter
12492 // UI / LAYOUT
12493
12494 /**
12495 * Align position of the panels within viewport. You can set different values each for the panel and camera
12496 * @ko 뷰포트 내에서 패널 정렬방식을 설정하는 옵션. 카메라와 패널 개별로 옵션을 설정할 수도 있습니다
12497 * @type {ALIGN | string | number | { panel: string | number, camera: string | number }}
12498 * @property {ALIGN | string | number} panel The align value for each {@link Panel}s<ko>개개의 {@link Panel}에 적용할 값</ko>
12499 * @property {ALIGN | string | number} camera The align value for {@link Camera}<ko>{@link Camera}에 적용할 값</ko>
12500 * @default "center"
12501 * @example
12502 * ```ts
12503 * const possibleOptions = [
12504 * // Literal strings
12505 * "prev", "center", "next",
12506 * // % values, applied to both panel & camera
12507 * "0%", "25%", "42%",
12508 * // px values, arithmetic calculation with (+/-) is also allowed.
12509 * "0px", "100px", "50% - 25px",
12510 * // numbers, same to number + px ("0px", "100px")
12511 * 0, 100, 1000,
12512 * // Setting a different value for panel & camera
12513 * { panel: "10%", camera: "25%" }
12514 * ];
12515 *
12516 * possibleOptions.forEach(align => {
12517 * new Flicking("#el", { align });
12518 * });
12519 * ```
12520 */
12521 get: function () {
12522 return this._align;
12523 },
12524 // Options Setter
12525 // UI / LAYOUT
12526 set: function (val) {
12527 this._align = val;
12528 this._renderer.align = val;
12529 this._camera.align = val;
12530 },
12531 enumerable: false,
12532 configurable: true
12533 });
12534 Object.defineProperty(__proto, "defaultIndex", {
12535 /**
12536 * Index of the panel to move when Flicking's {@link Flicking#init init()} is called. A zero-based integer
12537 * @ko Flicking의 {@link Flicking#init init()}이 호출될 때 이동할 디폴트 패널의 인덱스로, 0부터 시작하는 정수입니다
12538 * @type {number}
12539 * @default 0
12540 */
12541 get: function () {
12542 return this._defaultIndex;
12543 },
12544 set: function (val) {
12545 this._defaultIndex = val;
12546 },
12547 enumerable: false,
12548 configurable: true
12549 });
12550 Object.defineProperty(__proto, "horizontal", {
12551 /**
12552 * Direction of panel movement (true: horizontal, false: vertical)
12553 * @ko 패널 이동 방향 (true: 가로방향, false: 세로방향)
12554 * @type {boolean}
12555 * @default true
12556 */
12557 get: function () {
12558 return this._horizontal;
12559 },
12560 set: function (val) {
12561 this._horizontal = val;
12562 },
12563 enumerable: false,
12564 configurable: true
12565 });
12566 Object.defineProperty(__proto, "circular", {
12567 /**
12568 * Enables circular(continuous loop) mode, which connects first/last panel for continuous scrolling.
12569 * @ko 순환 모드를 활성화합니다. 순환 모드에서는 양 끝의 패널이 서로 연결되어 끊김없는 스크롤이 가능합니다.
12570 * @type {boolean}
12571 * @default false
12572 */
12573 get: function () {
12574 return this._circular;
12575 },
12576 set: function (val) {
12577 this._circular = val;
12578 },
12579 enumerable: false,
12580 configurable: true
12581 });
12582 Object.defineProperty(__proto, "circularFallback", {
12583 /**
12584 * Set panel control mode for the case when circular cannot be enabled.
12585 * "linear" will set the view's range from the top of the first panel to the top of the last panel.
12586 * "bound" will prevent the view from going out of the first/last panel, so it won't show empty spaces before/after the first/last panel.
12587 * @ko 순환 모드 사용 불가능시 사용할 패널 조작 범위 설정 방식을 변경합니다.
12588 * "linear" 사용시 시점이 첫번째 엘리먼트 위에서부터 마지막 엘리먼트 위까지 움직일 수 있도록 설정합니다.
12589 * "bound" 사용시 시점이 첫번째 엘리먼트와 마지막 엘리먼트의 끝과 끝 사이에서 움직일 수 있도록 설정합니다.
12590 * @see CIRCULAR_FALLBACK
12591 * @type {string}
12592 * @default "linear"
12593 */
12594 get: function () {
12595 return this._circularFallback;
12596 },
12597 enumerable: false,
12598 configurable: true
12599 });
12600 Object.defineProperty(__proto, "bound", {
12601 /**
12602 * 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
12603 * Only can be enabled when `circular=false`
12604 * @ko 뷰(카메라 엘리먼트)가 첫번째와 마지막 패널 밖으로 넘어가지 못하게 하여, 첫번째/마지막 패널 전/후의 빈 공간을 보이지 않도록 하는 옵션입니다
12605 * `circular=false`인 경우에만 사용할 수 있습니다
12606 * @type {boolean}
12607 * @default false
12608 */
12609 get: function () {
12610 return this._bound;
12611 },
12612 set: function (val) {
12613 this._bound = val;
12614 },
12615 enumerable: false,
12616 configurable: true
12617 });
12618 Object.defineProperty(__proto, "adaptive", {
12619 /**
12620 * Update height of the viewport element after movement same to the height of the panel below. This can be only enabled when `horizontal=true`
12621 * @ko 이동한 후 뷰포트 엘리먼트의 크기를 현재 패널의 높이와 동일하게 설정합니다. `horizontal=true`인 경우에만 사용할 수 있습니다.
12622 * @type {boolean}
12623 * @default false
12624 */
12625 get: function () {
12626 return this._adaptive;
12627 },
12628 set: function (val) {
12629 this._adaptive = val;
12630 },
12631 enumerable: false,
12632 configurable: true
12633 });
12634 Object.defineProperty(__proto, "panelsPerView", {
12635 /**
12636 * A visible number of panels on viewport. Enabling this option will automatically resize panel size
12637 * @ko 한 화면에 보이는 패널의 개수. 이 옵션을 활성화할 경우 패널의 크기를 강제로 재조정합니다
12638 * @type {number}
12639 * @default -1
12640 */
12641 get: function () {
12642 return this._panelsPerView;
12643 },
12644 set: function (val) {
12645 this._panelsPerView = val;
12646 },
12647 enumerable: false,
12648 configurable: true
12649 });
12650 Object.defineProperty(__proto, "noPanelStyleOverride", {
12651 /**
12652 * Enabling this option will not change `width/height` style of the panels if {@link Flicking#panelsPerView} is enabled.
12653 * This behavior can be useful in terms of performance when you're manually managing all panel sizes
12654 * @ko 이 옵션을 활성화할 경우, {@link Flicking#panelsPerView} 옵션이 활성화되었을 때 패널의 `width/height` 스타일을 변경하지 않도록 설정합니다.
12655 * 모든 패널들의 크기를 직접 관리하고 있을 경우, 이 옵션을 활성화하면 성능면에서 유리할 수 있습니다
12656 * @type {boolean}
12657 * @default false
12658 */
12659 get: function () {
12660 return this._noPanelStyleOverride;
12661 },
12662 set: function (val) {
12663 this._noPanelStyleOverride = val;
12664 },
12665 enumerable: false,
12666 configurable: true
12667 });
12668 Object.defineProperty(__proto, "resizeOnContentsReady", {
12669 /**
12670 * Enabling this option will automatically call {@link Flicking#resize} when all image/video inside panels are loaded.
12671 * This can be useful when you have contents inside Flicking that changes its size when it's loaded
12672 * @ko 이 옵션을 활성화할 경우, Flicking 패널 내부의 이미지/비디오들이 로드되었을 때 자동으로 {@link Flicking#resize}를 호출합니다.
12673 * 이 동작은 Flicking 내부에 로드 전/후로 크기가 변하는 콘텐츠를 포함하고 있을 때 유용하게 사용하실 수 있습니다.
12674 * @type {boolean}
12675 * @default false
12676 */
12677 get: function () {
12678 return this._resizeOnContentsReady;
12679 },
12680 set: function (val) {
12681 this._resizeOnContentsReady = val;
12682 },
12683 enumerable: false,
12684 configurable: true
12685 });
12686 Object.defineProperty(__proto, "nested", {
12687 /**
12688 * If you enable this option on child Flicking when the Flicking is placed inside the Flicking, the parent Flicking will move in the same direction after the child Flicking reaches the first/last panel.
12689 * If the parent Flicking and child Flicking have different horizontal option, you do not need to set this option.
12690 * @ko Flicking 내부에 Flicking이 배치될 때 하위 Flicking에서 이 옵션을 활성화하면 하위 Flicking이 첫/마지막 패널에 도달한 뒤부터 같은 방향으로 상위 Flicking이 움직입니다.
12691 * 만약 상위 Flicking과 하위 Flicking이 서로 다른 horizontal 옵션을 가지고 있다면 이 옵션을 설정할 필요가 없습니다.
12692 * @type {boolean}
12693 * @default false
12694 */
12695 get: function () {
12696 return this._nested;
12697 },
12698 set: function (val) {
12699 this._nested = val;
12700 },
12701 enumerable: false,
12702 configurable: true
12703 });
12704 Object.defineProperty(__proto, "needPanelThreshold", {
12705 // EVENTS
12706
12707 /**
12708 * A Threshold from viewport edge before triggering `needPanel` event
12709 * @ko `needPanel`이벤트가 발생하기 위한 뷰포트 끝으로부터의 최대 거리
12710 * @type {number}
12711 * @default 0
12712 */
12713 get: function () {
12714 return this._needPanelThreshold;
12715 },
12716 // EVENTS
12717 set: function (val) {
12718 this._needPanelThreshold = val;
12719 },
12720 enumerable: false,
12721 configurable: true
12722 });
12723 Object.defineProperty(__proto, "preventEventsBeforeInit", {
12724 /**
12725 * When enabled, events are not triggered before `ready` when initializing
12726 * @ko 활성화할 경우 초기화시 `ready` 이벤트 이전의 이벤트가 발생하지 않습니다.
12727 * @type {boolean}
12728 * @default true
12729 */
12730 get: function () {
12731 return this._preventEventsBeforeInit;
12732 },
12733 set: function (val) {
12734 this._preventEventsBeforeInit = val;
12735 },
12736 enumerable: false,
12737 configurable: true
12738 });
12739 Object.defineProperty(__proto, "deceleration", {
12740 // ANIMATION
12741
12742 /**
12743 * Deceleration value for panel movement animation which is triggered by user input. A higher value means a shorter animation time
12744 * @ko 사용자의 동작으로 가속도가 적용된 패널 이동 애니메이션의 감속도. 값이 높을수록 애니메이션 실행 시간이 짧아집니다
12745 * @type {number}
12746 * @default 0.0075
12747 */
12748 get: function () {
12749 return this._deceleration;
12750 },
12751 // ANIMATION
12752 set: function (val) {
12753 this._deceleration = val;
12754 },
12755 enumerable: false,
12756 configurable: true
12757 });
12758 Object.defineProperty(__proto, "easing", {
12759 /**
12760 * An easing function applied to the panel movement animation. Default value is `easeOutCubic`
12761 * @ko 패널 이동 애니메이션에 적용할 easing 함수. 기본값은 `easeOutCubic`이다
12762 * @type {function}
12763 * @default x => 1 - Math.pow(1 - x, 3)
12764 * @see Easing Functions Cheat Sheet {@link http://easings.net/} <ko>이징 함수 Cheat Sheet {@link http://easings.net/}</ko>
12765 */
12766 get: function () {
12767 return this._easing;
12768 },
12769 set: function (val) {
12770 this._easing = val;
12771 },
12772 enumerable: false,
12773 configurable: true
12774 });
12775 Object.defineProperty(__proto, "duration", {
12776 /**
12777 * Default duration of the animation (ms)
12778 * @ko 디폴트 애니메이션 재생 시간 (ms)
12779 * @type {number}
12780 * @default 500
12781 */
12782 get: function () {
12783 return this._duration;
12784 },
12785 set: function (val) {
12786 this._duration = val;
12787 },
12788 enumerable: false,
12789 configurable: true
12790 });
12791 Object.defineProperty(__proto, "inputType", {
12792 // INPUT
12793
12794 /**
12795 * Types of input devices to enable
12796 * @ko 활성화할 입력 장치 종류
12797 * @type {string[]}
12798 * @default ["touch", "mouse"]
12799 * @see {@link https://naver.github.io/egjs-axes/release/latest/doc/global.html#PanInputOption Possible values (PanInputOption#inputType)}
12800 * <ko>{@link https://naver.github.io/egjs-axes/release/latest/doc/global.html#PanInputOption 가능한 값들 (PanInputOption#inputType)}</ko>
12801 */
12802 get: function () {
12803 return this._inputType;
12804 },
12805 // INPUT
12806 set: function (val) {
12807 this._inputType = val;
12808 },
12809 enumerable: false,
12810 configurable: true
12811 });
12812 Object.defineProperty(__proto, "moveType", {
12813 /**
12814 * Movement style by user input. This will change instance type of {@link Flicking#control}
12815 * You can use the values of the constant {@link MOVE_TYPE}
12816 * @ko 사용자 입력에 의한 이동 방식. 이 값에 따라 {@link Flicking#control}의 인스턴스 타입이 결정됩니다
12817 * 상수 {@link MOVE_TYPE}에 정의된 값들을 이용할 수 있습니다
12818 * @type {MOVE_TYPE | Pair<string, object>}
12819 * @default "snap"
12820 * @example
12821 * |moveType|control|options|
12822 * |:---:|:---:|:---:|
12823 * |"snap"|{@link SnapControl}||
12824 * |"freeScroll"|{@link FreeControl}|{@link FreeControlOptions}|
12825 *
12826 * ```ts
12827 * import Flicking, { MOVE_TYPE } from "@egjs/flicking";
12828 *
12829 * const flicking = new Flicking({
12830 * moveType: MOVE_TYPE.SNAP
12831 * });
12832 * ```
12833 *
12834 * ```ts
12835 * const flicking = new Flicking({
12836 * // If you want more specific settings for the moveType
12837 * // [moveType, options for that moveType]
12838 * // In this case, it's ["freeScroll", FreeControlOptions]
12839 * moveType: [MOVE_TYPE.FREE_SCROLL, { stopAtEdge: true }]
12840 * });
12841 * ```
12842 */
12843 get: function () {
12844 return this._moveType;
12845 },
12846 set: function (val) {
12847 this._moveType = val;
12848 },
12849 enumerable: false,
12850 configurable: true
12851 });
12852 Object.defineProperty(__proto, "threshold", {
12853 /**
12854 * Movement threshold to change panel (unit: px). It should be dragged above the threshold to change the current panel.
12855 * @ko 패널 변경을 위한 이동 임계값 (단위: px). 주어진 값 이상으로 스크롤해야만 패널 변경이 가능하다.
12856 * @type {number}
12857 * @default 40
12858 */
12859 get: function () {
12860 return this._threshold;
12861 },
12862 set: function (val) {
12863 this._threshold = val;
12864 },
12865 enumerable: false,
12866 configurable: true
12867 });
12868 Object.defineProperty(__proto, "interruptable", {
12869 /**
12870 * Set animation to be interruptable by click/touch.
12871 * @ko 사용자의 클릭/터치로 인해 애니메이션을 도중에 멈출 수 있도록 설정합니다.
12872 * @type {boolean}
12873 * @default true
12874 */
12875 get: function () {
12876 return this._interruptable;
12877 },
12878 set: function (val) {
12879 this._interruptable = val;
12880 },
12881 enumerable: false,
12882 configurable: true
12883 });
12884 Object.defineProperty(__proto, "bounce", {
12885 /**
12886 * The size value of the bounce area. Only can be enabled when `circular=false`.
12887 * You can set different bounce value for prev/next direction by using array.
12888 * `number` for px value, and `string` for px, and % value relative to viewport size.
12889 * You have to call {@link Control#updateInput} after changing this to take effect.
12890 * @ko Flicking이 최대 영역을 넘어서 갈 수 있는 최대 크기. `circular=false`인 경우에만 사용할 수 있습니다.
12891 * 배열을 통해 prev/next 방향에 대해 서로 다른 바운스 값을 지정할 수 있습니다.
12892 * `number`를 통해 px값을, `stirng`을 통해 px 혹은 뷰포트 크기 대비 %값을 사용할 수 있습니다.
12893 * 이 값을 변경시 {@link Control#updateInput}를 호출해야 합니다.
12894 * @type {string | number | Array<string | number>}
12895 * @default "20%"
12896 * @example
12897 * ```ts
12898 * const possibleOptions = [
12899 * // % values, relative to viewport element(".flicking-viewport")'s size
12900 * "0%", "25%", "42%",
12901 * // px values, arithmetic calculation with (+/-) is also allowed.
12902 * "0px", "100px", "50% - 25px",
12903 * // numbers, same to number + px ("0px", "100px")
12904 * 0, 100, 1000
12905 * ];
12906 * ```
12907 *
12908 * @example
12909 * ```ts
12910 * const flicking = new Flicking("#el", { bounce: "20%" });
12911 *
12912 * flicking.bounce = "100%";
12913 * flicking.control.updateInput(); // Call this to update!
12914 * ```
12915 */
12916 get: function () {
12917 return this._bounce;
12918 },
12919 set: function (val) {
12920 this._bounce = val;
12921 },
12922 enumerable: false,
12923 configurable: true
12924 });
12925 Object.defineProperty(__proto, "iOSEdgeSwipeThreshold", {
12926 /**
12927 * Size of the area from the right edge in iOS safari (in px) which enables swipe-back or swipe-forward
12928 * @ko iOS Safari에서 swipe를 통한 뒤로가기/앞으로가기를 활성화하는 오른쪽 끝으로부터의 영역의 크기 (px)
12929 * @type {number}
12930 * @default 30
12931 */
12932 get: function () {
12933 return this._iOSEdgeSwipeThreshold;
12934 },
12935 set: function (val) {
12936 this._iOSEdgeSwipeThreshold = val;
12937 },
12938 enumerable: false,
12939 configurable: true
12940 });
12941 Object.defineProperty(__proto, "preventClickOnDrag", {
12942 /**
12943 * Automatically prevent `click` event if the user has dragged at least a single pixel on the viewport element
12944 * @ko 사용자가 뷰포트 영역을 1픽셀이라도 드래그했을 경우 자동으로 {@link https://developer.mozilla.org/ko/docs/Web/API/Element/click_event click} 이벤트를 취소합니다
12945 * @type {boolean}
12946 * @default true
12947 */
12948 get: function () {
12949 return this._preventClickOnDrag;
12950 },
12951 set: function (val) {
12952 var prevVal = this._preventClickOnDrag;
12953 if (val === prevVal) return;
12954 var controller = this._control.controller;
12955
12956 if (val) {
12957 controller.addPreventClickHandler();
12958 } else {
12959 controller.removePreventClickHandler();
12960 }
12961
12962 this._preventClickOnDrag = val;
12963 },
12964 enumerable: false,
12965 configurable: true
12966 });
12967 Object.defineProperty(__proto, "disableOnInit", {
12968 /**
12969 * Automatically call {@link Flicking#disableInput disableInput()} on initialization
12970 * @ko Flicking init시에 {@link Flicking#disableInput disableInput()}을 바로 호출합니다
12971 * @type {boolean}
12972 * @default false
12973 */
12974 get: function () {
12975 return this._disableOnInit;
12976 },
12977 set: function (val) {
12978 this._disableOnInit = val;
12979 },
12980 enumerable: false,
12981 configurable: true
12982 });
12983 Object.defineProperty(__proto, "changeOnHold", {
12984 /**
12985 * Change active panel index on mouse/touch hold while animating.
12986 * `index` of the `willChange`/`willRestore` event will be used as new index.
12987 * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
12988 * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
12989 * @type {boolean}
12990 * @default false
12991 */
12992 get: function () {
12993 return this._changeOnHold;
12994 },
12995 set: function (val) {
12996 this._changeOnHold = val;
12997 },
12998 enumerable: false,
12999 configurable: true
13000 });
13001 Object.defineProperty(__proto, "renderOnlyVisible", {
13002 // PERFORMANCE
13003
13004 /**
13005 * Whether to render visible panels only. This can dramatically increase performance when there're many panels
13006 * @ko 보이는 패널만 렌더링할지 여부를 설정합니다. 패널이 많을 경우에 퍼포먼스를 크게 향상시킬 수 있습니다
13007 * @type {boolean}
13008 * @default false
13009 */
13010 get: function () {
13011 return this._renderOnlyVisible;
13012 },
13013 // PERFORMANCE
13014 set: function (val) {
13015 this._renderOnlyVisible = val;
13016 },
13017 enumerable: false,
13018 configurable: true
13019 });
13020 Object.defineProperty(__proto, "virtual", {
13021 /**
13022 * By enabling this option, it will reduce memory consumption by restricting the number of DOM elements to `panelsPerView + 1`
13023 * Must be used with `panelsPerview`.
13024 * After Flicking's initialized, this property can be used to add/remove the panel count.
13025 * @ko 이 옵션을 활성화할 경우 패널 엘리먼트의 개수를 `panelsPerView + 1` 개로 고정함으로써, 메모리 사용량을 줄일 수 있습니다.
13026 * `panelsPerView` 옵션과 함께 사용되어야만 합니다.
13027 * Flicking 초기화 이후에, 이 프로퍼티는 렌더링하는 패널의 개수를 추가/제거하기 위해 사용될 수 있습니다.
13028 * @type {VirtualManager}
13029 * @property {function} renderPanel A rendering function for the panel element's innerHTML<ko>패널 엘리먼트의 innerHTML을 렌더링하는 함수</ko>
13030 * @property {number} initialPanelCount Initial panel count to render<ko>최초로 렌더링할 패널의 개수</ko>
13031 * @property {boolean} [cache=false] Whether to cache rendered panel's innerHTML<ko>렌더링된 패널의 innerHTML 정보를 캐시할지 여부</ko>
13032 * @property {string} [panelClass="flicking-panel"] The class name that will be applied to rendered panel elements<ko>렌더링되는 패널 엘리먼트에 적용될 클래스 이름</ko>
13033 * @example
13034 * ```ts
13035 * import Flicking, { VirtualPanel } from "@egjs/flicking";
13036 *
13037 * const flicking = new Flicking("#some_el", {
13038 * panelsPerView: 3,
13039 * virtual: {
13040 * renderPanel: (panel: VirtualPanel, index: number) => `Panel ${index}`,
13041 * initialPanelCount: 100
13042 * }
13043 * });
13044 *
13045 * // Add 100 virtual panels (at the end)
13046 * flicking.virtual.append(100);
13047 *
13048 * // Remove 100 virtual panels from 0 to 100
13049 * flicking.virtual.remove(0, 100);
13050 * ```
13051 */
13052 get: function () {
13053 return this._virtualManager;
13054 },
13055 enumerable: false,
13056 configurable: true
13057 });
13058 Object.defineProperty(__proto, "autoInit", {
13059 // OTHERS
13060
13061 /**
13062 * Call {@link Flicking#init init()} automatically when creating Flicking's instance
13063 * @ko Flicking 인스턴스를 생성할 때 자동으로 {@link Flicking#init init()}를 호출합니다
13064 * @type {boolean}
13065 * @default true
13066 * @readonly
13067 */
13068 get: function () {
13069 return this._autoInit;
13070 },
13071 enumerable: false,
13072 configurable: true
13073 });
13074 Object.defineProperty(__proto, "autoResize", {
13075 /**
13076 * Whether to automatically call {@link Flicking#resize resize()} when the viewport element(.flicking-viewport)'s size is changed
13077 * @ko 뷰포트 엘리먼트(.flicking-viewport)의 크기 변경시 {@link Flicking#resize resize()} 메소드를 자동으로 호출할지 여부를 설정합니다
13078 * @type {boolean}
13079 * @default true
13080 */
13081 get: function () {
13082 return this._autoResize;
13083 },
13084 // OTHERS
13085 set: function (val) {
13086 this._autoResize = val;
13087
13088 if (val) {
13089 this._autoResizer.enable();
13090 } else {
13091 this._autoResizer.disable();
13092 }
13093 },
13094 enumerable: false,
13095 configurable: true
13096 });
13097 Object.defineProperty(__proto, "useResizeObserver", {
13098 /**
13099 * Whether to listen {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}'s event instead of Window's {@link https://developer.mozilla.org/ko/docs/Web/API/Window/resize_event resize} event when using the `autoResize` option
13100 * @ko autoResize 옵션 사용시 {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}의 이벤트를 Window객체의 {@link https://developer.mozilla.org/ko/docs/Web/API/Window/resize_event resize} 이벤트 대신 수신할지 여부를 설정합니다
13101 * @type {boolean}
13102 * @default true
13103 */
13104 get: function () {
13105 return this._useResizeObserver;
13106 },
13107 set: function (val) {
13108 this._useResizeObserver = val;
13109
13110 if (this._autoResize) {
13111 this._autoResizer.enable();
13112 }
13113 },
13114 enumerable: false,
13115 configurable: true
13116 });
13117 Object.defineProperty(__proto, "resizeDebounce", {
13118 /**
13119 * Delays size recalculation from `autoResize` by the given time in milisecond.
13120 * If the size is changed again while being delayed, it cancels the previous one and delays from the beginning again.
13121 * This can increase performance by preventing `resize` being called too often.
13122 * @ko `autoResize` 설정시에 호출되는 크기 재계산을 주어진 시간(단위: ms)만큼 지연시킵니다.
13123 * 지연시키는 도중 크기가 다시 변경되었을 경우, 이전 것을 취소하고 주어진 시간만큼 다시 지연시킵니다.
13124 * 이를 통해 `resize`가 너무 많이 호출되는 것을 방지하여 성능을 향상시킬 수 있습니다.
13125 * @type {number}
13126 * @default 0
13127 */
13128 get: function () {
13129 return this._resizeDebounce;
13130 },
13131 enumerable: false,
13132 configurable: true
13133 });
13134 Object.defineProperty(__proto, "maxResizeDebounce", {
13135 /**
13136 * The maximum time for size recalculation delay when using `resizeDebounce`, in milisecond.
13137 * This guarantees that size recalculation is performed at least once every (n)ms.
13138 * @ko `resizeDebounce` 사용시에 크기 재계산이 지연되는 최대 시간을 지정합니다. (단위: ms)
13139 * 이를 통해, 적어도 (n)ms에 한번은 크기 재계산을 수행하는 것을 보장할 수 있습니다.
13140 * @type {number}
13141 * @default 100
13142 */
13143 get: function () {
13144 return this._maxResizeDebounce;
13145 },
13146 enumerable: false,
13147 configurable: true
13148 });
13149 Object.defineProperty(__proto, "useFractionalSize", {
13150 /**
13151 * By enabling this, Flicking will calculate all internal size with CSS width computed with getComputedStyle.
13152 * This can prevent 1px offset issue in some cases where panel size has the fractional part.
13153 * All sizes will have the original size before CSS {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform} is applied on the element.
13154 * @ko 이 옵션을 활성화할 경우, Flicking은 내부의 모든 크기를 {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect getBoundingClientRect}를 이용하여 계산합니다.
13155 * 이를 통해, 패널 크기에 소수점을 포함할 경우에 발생할 수 있는 일부 1px 오프셋 이슈를 해결 가능합니다.
13156 * 모든 크기는 CSS {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform}이 엘리먼트에 적용되기 이전의 크기를 사용할 것입니다.
13157 * @type {boolean}
13158 * @default false
13159 */
13160 get: function () {
13161 return this._useFractionalSize;
13162 },
13163 enumerable: false,
13164 configurable: true
13165 });
13166 Object.defineProperty(__proto, "externalRenderer", {
13167 /**
13168 * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
13169 * @ko 프레임워크(React, Vue, Angular, ...)에서만 사용하는 옵션으로, 자동으로 설정되므로 따로 사용하실 필요 없습니다!
13170 * @default null
13171 * @internal
13172 * @readonly
13173 */
13174 get: function () {
13175 return this._externalRenderer;
13176 },
13177 enumerable: false,
13178 configurable: true
13179 });
13180 Object.defineProperty(__proto, "renderExternal", {
13181 /**
13182 * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
13183 * @ko 프레임워크(React, Vue, Angular, ...)에서만 사용하는 옵션으로, 자동으로 설정되므로 따로 사용하실 필요 없습니다!
13184 * @default null
13185 * @internal
13186 * @readonly
13187 * @deprecated
13188 */
13189 get: function () {
13190 return this._renderExternal;
13191 },
13192 enumerable: false,
13193 configurable: true
13194 });
13195 /**
13196 * Initialize Flicking and move to the default index
13197 * This is automatically called on Flicking's constructor when `autoInit` is true(default)
13198 * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
13199 * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
13200 * @fires Flicking#ready
13201 * @return {Promise<void>}
13202 */
13203
13204 __proto.init = function () {
13205 var _this = this;
13206
13207 if (this._initialized) return Promise.resolve();
13208 var camera = this._camera;
13209 var renderer = this._renderer;
13210 var control = this._control;
13211 var virtualManager = this._virtualManager;
13212 var originalTrigger = this.trigger;
13213 var preventEventsBeforeInit = this._preventEventsBeforeInit;
13214 camera.init();
13215 virtualManager.init();
13216 renderer.init(this);
13217 control.init(this);
13218
13219 if (preventEventsBeforeInit) {
13220 this.trigger = function () {
13221 return _this;
13222 };
13223 }
13224
13225 this._initialResize(); // Look at initial panel
13226
13227
13228 this._moveToInitialPanel();
13229
13230 if (this._autoResize) {
13231 this._autoResizer.enable();
13232 }
13233
13234 if (this._preventClickOnDrag) {
13235 control.controller.addPreventClickHandler();
13236 }
13237
13238 if (this._disableOnInit) {
13239 this.disableInput();
13240 }
13241
13242 renderer.checkPanelContentsReady(renderer.panels);
13243 return renderer.render().then(function () {
13244 // Done initializing & emit ready event
13245 _this._plugins.forEach(function (plugin) {
13246 return plugin.init(_this);
13247 });
13248
13249 _this._initialized = true;
13250
13251 if (preventEventsBeforeInit) {
13252 _this.trigger = originalTrigger;
13253 }
13254
13255 _this.trigger(new ComponentEvent$1(EVENTS.READY));
13256 });
13257 };
13258 /**
13259 * Destroy Flicking and remove all event handlers
13260 * @ko Flicking과 하위 컴포넌트들을 초기 상태로 되돌리고, 부착된 모든 이벤트 핸들러를 제거합니다
13261 * @return {void}
13262 */
13263
13264
13265 __proto.destroy = function () {
13266 this.off();
13267
13268 this._autoResizer.disable();
13269
13270 this._control.destroy();
13271
13272 this._camera.destroy();
13273
13274 this._renderer.destroy();
13275
13276 this._plugins.forEach(function (plugin) {
13277 return plugin.destroy();
13278 });
13279
13280 this._initialized = false;
13281 };
13282 /**
13283 * Move to the previous panel (current index - 1)
13284 * @ko 이전 패널로 이동합니다 (현재 인덱스 - 1)
13285 * @param {number} [duration={@link Flicking#duration options.duration}] Duration of the panel movement animation (unit: ms)<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
13286 * @async
13287 * @fires Flicking#moveStart
13288 * @fires Flicking#move
13289 * @fires Flicking#moveEnd
13290 * @fires Flicking#willChange
13291 * @fires Flicking#changed
13292 * @fires Flicking#willRestore
13293 * @fires Flicking#restored
13294 * @fires Flicking#needPanel
13295 * @fires Flicking#visibleChange
13296 * @fires Flicking#reachEdge
13297 * @throws {FlickingError}
13298 * |code|condition|
13299 * |---|---|
13300 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|When the previous panel does not exist|
13301 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|When the animation is already playing|
13302 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
13303 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the any of the event's `stop()` is called|
13304 * <ko>
13305 *
13306 * |code|condition|
13307 * |---|---|
13308 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|이전 패널이 존재하지 않을 경우|
13309 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|애니메이션이 이미 진행중인 경우|
13310 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
13311 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
13312 * </ko>
13313 * @return {Promise<void>} A Promise which will be resolved after reaching the previous panel<ko>이전 패널 도달시에 resolve되는 Promise</ko>
13314 */
13315
13316
13317 __proto.prev = function (duration) {
13318 var _a, _b, _c;
13319
13320 if (duration === void 0) {
13321 duration = this._duration;
13322 }
13323
13324 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);
13325 };
13326 /**
13327 * Move to the next panel (current index + 1)
13328 * @ko 다음 패널로 이동합니다 (현재 인덱스 + 1)
13329 * @param {number} [duration={@link Flicking#duration options.duration}] Duration of the panel movement animation (unit: ms).<ko>패널 이동 애니메이션 진행 시간 (단위: ms)</ko>
13330 * @async
13331 * @fires Flicking#moveStart
13332 * @fires Flicking#move
13333 * @fires Flicking#moveEnd
13334 * @fires Flicking#willChange
13335 * @fires Flicking#changed
13336 * @fires Flicking#willRestore
13337 * @fires Flicking#restored
13338 * @fires Flicking#needPanel
13339 * @fires Flicking#visibleChange
13340 * @fires Flicking#reachEdge
13341 * @throws {FlickingError}
13342 * |code|condition|
13343 * |---|---|
13344 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|When the next panel does not exist|
13345 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|When the animation is already playing|
13346 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
13347 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the any of the event's `stop()` is called|
13348 * <ko>
13349 *
13350 * |code|condition|
13351 * |---|---|
13352 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|다음 패널이 존재하지 않을 경우|
13353 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|애니메이션이 이미 진행중인 경우|
13354 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
13355 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
13356 *
13357 * </ko>
13358 * @return {Promise<void>} A Promise which will be resolved after reaching the next panel<ko>다음 패널 도달시에 resolve되는 Promise</ko>
13359 */
13360
13361
13362 __proto.next = function (duration) {
13363 var _a, _b, _c;
13364
13365 if (duration === void 0) {
13366 duration = this._duration;
13367 }
13368
13369 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);
13370 };
13371 /**
13372 * Move to the panel with given index
13373 * @ko 주어진 인덱스에 해당하는 패널로 이동합니다
13374 * @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
13375 * @param {number} [duration={@link Flicking#duration options.duration}] Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
13376 * @param {DIRECTION} [direction=DIRECTION.NONE] Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
13377 * @async
13378 * @fires Flicking#moveStart
13379 * @fires Flicking#move
13380 * @fires Flicking#moveEnd
13381 * @fires Flicking#willChange
13382 * @fires Flicking#changed
13383 * @fires Flicking#willRestore
13384 * @fires Flicking#restored
13385 * @fires Flicking#needPanel
13386 * @fires Flicking#visibleChange
13387 * @fires Flicking#reachEdge
13388 * @throws {FlickingError}
13389 * |code|condition|
13390 * |---|---|
13391 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|When the root is not either string or HTMLElement|
13392 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|When the animation is already playing|
13393 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|When the animation is interrupted by user input|
13394 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|When the any of the event's `stop()` is called|
13395 * <ko>
13396 *
13397 * |code|condition|
13398 * |---|---|
13399 * |{@link ERROR_CODE INDEX_OUT_OF_RANGE}|해당 인덱스를 가진 패널이 존재하지 않을 경우|
13400 * |{@link ERROR_CODE ANIMATION_ALREADY_PLAYING}|애니메이션이 이미 진행중인 경우|
13401 * |{@link ERROR_CODE ANIMATION_INTERRUPTED}|사용자 입력에 의해 애니메이션이 중단된 경우|
13402 * |{@link ERROR_CODE STOP_CALLED_BY_USER}|발생된 이벤트들 중 하나라도 `stop()`이 호출된 경우|
13403 *
13404 * </ko>
13405 * @return {Promise<void>} A Promise which will be resolved after reaching the target panel<ko>해당 패널 도달시에 resolve되는 Promise</ko>
13406 */
13407
13408
13409 __proto.moveTo = function (index, duration, direction) {
13410 if (duration === void 0) {
13411 duration = this._duration;
13412 }
13413
13414 if (direction === void 0) {
13415 direction = DIRECTION.NONE;
13416 }
13417
13418 var renderer = this._renderer;
13419 var panelCount = renderer.panelCount;
13420 var panel = renderer.getPanel(index);
13421
13422 if (!panel) {
13423 return Promise.reject(new FlickingError(MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), CODE.INDEX_OUT_OF_RANGE));
13424 }
13425
13426 if (this._control.animating) {
13427 return Promise.reject(new FlickingError(MESSAGE.ANIMATION_ALREADY_PLAYING, CODE.ANIMATION_ALREADY_PLAYING));
13428 }
13429
13430 if (this._control.holding) {
13431 this._control.controller.release();
13432 }
13433
13434 return this._control.moveToPanel(panel, {
13435 duration: duration,
13436 direction: direction
13437 });
13438 };
13439 /**
13440 * Change the destination and duration of the animation currently playing
13441 * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
13442 * @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
13443 * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
13444 * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
13445 * @throws {FlickingError}
13446 * {@link ERROR_CODE INDEX_OUT_OF_RANGE} When the root is not either string or HTMLElement
13447 * <ko>{@link ERROR_CODE INDEX_OUT_OF_RANGE} 해당 인덱스를 가진 패널이 존재하지 않을 경우</ko>
13448 * @return {void}
13449 */
13450
13451
13452 __proto.updateAnimation = function (index, duration, direction) {
13453 if (!this._control.animating) {
13454 return;
13455 }
13456
13457 var renderer = this._renderer;
13458 var panelCount = renderer.panelCount;
13459 var panel = renderer.getPanel(index);
13460
13461 if (!panel) {
13462 throw new FlickingError(MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), CODE.INDEX_OUT_OF_RANGE);
13463 }
13464
13465 this._control.updateAnimation(panel, duration, direction);
13466 };
13467 /**
13468 * Stops the animation currently playing
13469 * @ko 재생 중인 애니메이션을 중단시킵니다
13470 * @fires Flicking#moveEnd
13471 * @return {void}
13472 */
13473
13474
13475 __proto.stopAnimation = function () {
13476 if (!this._control.animating) {
13477 return;
13478 }
13479
13480 this._control.stopAnimation();
13481 };
13482 /**
13483 * Return the {@link Panel} at the given index. `null` if it doesn't exists.
13484 * @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
13485 * @return {Panel | null} Panel at the given index<ko>주어진 인덱스에 해당하는 패널</ko>
13486 * @see Panel
13487 * @example
13488 * ```ts
13489 * const panel = flicking.getPanel(0);
13490 * // Which is a shorthand to...
13491 * const samePanel = flicking.panels[0];
13492 * ```
13493 */
13494
13495
13496 __proto.getPanel = function (index) {
13497 return this._renderer.getPanel(index);
13498 };
13499 /**
13500 * Enable input from the user (mouse/touch)
13501 * @ko 사용자의 입력(마우스/터치)를 활성화합니다
13502 * @return {this}
13503 */
13504
13505
13506 __proto.enableInput = function () {
13507 this._control.enable();
13508
13509 return this;
13510 };
13511 /**
13512 * Disable input from the user (mouse/touch)
13513 * @ko 사용자의 입력(마우스/터치)를 막습니다
13514 * @return {this}
13515 */
13516
13517
13518 __proto.disableInput = function () {
13519 this._control.disable();
13520
13521 return this;
13522 };
13523 /**
13524 * Get current flicking status. You can restore current state by giving returned value to {@link Flicking#setStatus setStatus()}
13525 * @ko 현재 상태를 반환합니다. 반환받은 값을 {@link Flicking#setStatus setStatus()} 메소드의 인자로 지정하면 현재 상태를 복원할 수 있습니다
13526 * @param {object} options Status retrieving options<ko>Status 반환 옵션</ko>
13527 * @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>
13528 * @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>
13529 * @param {boolean} [options.includePanelHTML=false] Include panel's `outerHTML` to the returning status<ko>패널의 `outerHTML`을 반환값에 포함시킵니다</ko>
13530 * @param {boolean} [options.visiblePanelsOnly=false] Include only {@link Flicking#visiblePanel visiblePanel}'s HTML. This option is available only when the `includePanelHTML` is true
13531 * <ko>현재 보이는 패널({@link Flicking#visiblePanel visiblePanel})의 HTML만 반환합니다. `includePanelHTML`이 `true`일 경우에만 동작합니다.</ko>
13532 * @return {Status} An object with current status value information<ko>현재 상태값 정보를 가진 객체.</ko>
13533 */
13534
13535
13536 __proto.getStatus = function (_a) {
13537 var _b, _c;
13538
13539 var _d = _a === void 0 ? {} : _a,
13540 _e = _d.index,
13541 index = _e === void 0 ? true : _e,
13542 _f = _d.position,
13543 position = _f === void 0 ? true : _f,
13544 _g = _d.includePanelHTML,
13545 includePanelHTML = _g === void 0 ? false : _g,
13546 _h = _d.visiblePanelsOnly,
13547 visiblePanelsOnly = _h === void 0 ? false : _h;
13548
13549 var camera = this._camera;
13550 var panels = visiblePanelsOnly ? this.visiblePanels : this.panels;
13551 var status = {
13552 panels: panels.map(function (panel) {
13553 var panelInfo = {
13554 index: panel.index
13555 };
13556
13557 if (includePanelHTML) {
13558 panelInfo.html = panel.element.outerHTML;
13559 }
13560
13561 return panelInfo;
13562 })
13563 };
13564
13565 if (index) {
13566 status.index = this.index;
13567 }
13568
13569 if (position) {
13570 var nearestAnchor = camera.findNearestAnchor(camera.position);
13571
13572 if (nearestAnchor) {
13573 status.position = {
13574 panel: nearestAnchor.panel.index,
13575 progressInPanel: camera.getProgressInPanel(nearestAnchor.panel)
13576 };
13577 }
13578 }
13579
13580 if (visiblePanelsOnly) {
13581 var visiblePanels = this.visiblePanels;
13582 status.visibleOffset = (_c = (_b = visiblePanels[0]) === null || _b === void 0 ? void 0 : _b.index) !== null && _c !== void 0 ? _c : 0;
13583 }
13584
13585 return status;
13586 };
13587 /**
13588 * Restore to the state of the given {@link Status}
13589 * @ko 주어진 {@link Status}의 상태로 복원합니다
13590 * @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>
13591 * @return {void}
13592 */
13593
13594
13595 __proto.setStatus = function (status) {
13596 var _a;
13597
13598 if (!this._initialized) {
13599 throw new FlickingError(MESSAGE.NOT_INITIALIZED, CODE.NOT_INITIALIZED);
13600 }
13601
13602 var index = status.index,
13603 position = status.position,
13604 visibleOffset = status.visibleOffset,
13605 panels = status.panels;
13606 var renderer = this._renderer;
13607 var control = this._control; // Can't add/remove panels on external rendering
13608
13609 if (((_a = panels[0]) === null || _a === void 0 ? void 0 : _a.html) && !this._renderExternal) {
13610 renderer.batchRemove({
13611 index: 0,
13612 deleteCount: this.panels.length,
13613 hasDOMInElements: true
13614 });
13615 renderer.batchInsert({
13616 index: 0,
13617 elements: parseElement(panels.map(function (panel) {
13618 return panel.html;
13619 })),
13620 hasDOMInElements: true
13621 });
13622 }
13623
13624 if (index) {
13625 var panelIndex = visibleOffset ? index - visibleOffset : index;
13626 void this.moveTo(panelIndex, 0).catch(function () {
13627 return void 0;
13628 });
13629 }
13630
13631 if (position && this._moveType === MOVE_TYPE.FREE_SCROLL) {
13632 var panel = position.panel,
13633 progressInPanel = position.progressInPanel;
13634 var panelIndex = visibleOffset ? panel - visibleOffset : panel;
13635 var panelRange = renderer.panels[panelIndex].range;
13636 var newCameraPos = panelRange.min + (panelRange.max - panelRange.min) * progressInPanel;
13637 void control.moveToPosition(newCameraPos, 0).catch(function () {
13638 return void 0;
13639 });
13640 }
13641 };
13642 /**
13643 * Add plugins that can have different effects on Flicking
13644 * @ko 플리킹에 다양한 효과를 부여할 수 있는 플러그인을 추가합니다
13645 * @param {...Plugin} plugins The plugin(s) to add<ko>추가할 플러그인(들)</ko>
13646 * @return {this}
13647 * @see https://github.com/naver/egjs-flicking-plugins
13648 */
13649
13650
13651 __proto.addPlugins = function () {
13652 var _a;
13653
13654 var _this = this;
13655
13656 var plugins = [];
13657
13658 for (var _i = 0; _i < arguments.length; _i++) {
13659 plugins[_i] = arguments[_i];
13660 }
13661
13662 if (this._initialized) {
13663 plugins.forEach(function (item) {
13664 return item.init(_this);
13665 });
13666 }
13667
13668 (_a = this._plugins).push.apply(_a, __spread$1(plugins));
13669
13670 return this;
13671 };
13672 /**
13673 * Remove plugins from Flicking.
13674 * @ko 플리킹으로부터 플러그인들을 제거합니다.
13675 * @param {...Plugin} plugin The plugin(s) to remove.<ko>제거 플러그인(들).</ko>
13676 * @return {this}
13677 * @see https://github.com/naver/egjs-flicking-plugins
13678 */
13679
13680
13681 __proto.removePlugins = function () {
13682 var _this = this;
13683
13684 var plugins = [];
13685
13686 for (var _i = 0; _i < arguments.length; _i++) {
13687 plugins[_i] = arguments[_i];
13688 }
13689
13690 plugins.forEach(function (item) {
13691 var foundIndex = findIndex(_this._plugins, function (val) {
13692 return val === item;
13693 });
13694
13695 if (foundIndex >= 0) {
13696 item.destroy();
13697
13698 _this._plugins.splice(foundIndex, 1);
13699 }
13700 });
13701 return this;
13702 };
13703 /**
13704 * Update viewport/panel sizes
13705 * @ko 패널 및 뷰포트의 크기를 갱신합니다
13706 * @method
13707 * @fires Flicking#beforeResize
13708 * @fires Flicking#afterResize
13709 * @return {this}
13710 */
13711
13712
13713 __proto.resize = function () {
13714 return __awaiter(this, void 0, void 0, function () {
13715 var viewport, renderer, camera, control, activePanel, prevWidth, prevHeight, prevProgressInPanel, newWidth, newHeight, sizeChanged;
13716 return __generator(this, function (_a) {
13717 switch (_a.label) {
13718 case 0:
13719 viewport = this._viewport;
13720 renderer = this._renderer;
13721 camera = this._camera;
13722 control = this._control;
13723 activePanel = control.activePanel;
13724 prevWidth = viewport.width;
13725 prevHeight = viewport.height;
13726 prevProgressInPanel = activePanel ? camera.getProgressInPanel(activePanel) : 0;
13727 this.trigger(new ComponentEvent$1(EVENTS.BEFORE_RESIZE, {
13728 width: prevWidth,
13729 height: prevHeight,
13730 element: viewport.element
13731 }));
13732 viewport.resize();
13733 return [4
13734 /*yield*/
13735 , renderer.forceRenderAllPanels()];
13736
13737 case 1:
13738 _a.sent(); // Render all panel elements, to update sizes
13739
13740
13741 renderer.updatePanelSize();
13742 camera.updateAlignPos();
13743 camera.updateRange();
13744 camera.updateAnchors();
13745 camera.updateAdaptiveHeight();
13746 camera.updateOffset();
13747 return [4
13748 /*yield*/
13749 , renderer.render()];
13750
13751 case 2:
13752 _a.sent();
13753
13754 if (control.animating) ; else {
13755 control.updatePosition(prevProgressInPanel);
13756 control.updateInput();
13757 }
13758
13759 newWidth = viewport.width;
13760 newHeight = viewport.height;
13761 sizeChanged = newWidth !== prevWidth || newHeight !== prevHeight;
13762 this.trigger(new ComponentEvent$1(EVENTS.AFTER_RESIZE, {
13763 width: viewport.width,
13764 height: viewport.height,
13765 prev: {
13766 width: prevWidth,
13767 height: prevHeight
13768 },
13769 sizeChanged: sizeChanged,
13770 element: viewport.element
13771 }));
13772 return [2
13773 /*return*/
13774 ];
13775 }
13776 });
13777 });
13778 };
13779 /**
13780 * Add new panels after the last panel
13781 * @ko 패널 목록의 제일 끝에 새로운 패널들을 추가합니다
13782 * @param {ElementLike | ElementLike[]} element A new HTMLElement, a outerHTML of element, or an array of both
13783 * <ko>새로운 HTMLElement, 혹은 엘리먼트의 outerHTML, 혹은 그것들의 배열</ko>
13784 * @return {Panel[]} An array of appended panels<ko>추가된 패널들의 배열</ko>
13785 * @see Panel
13786 * @see ElementLike
13787 * @throws {FlickingError} {@link ERROR_CODE ERROR_CODE.NOT_ALLOWED_IN_FRAMEWORK} if called on frameworks (React, Angular, Vue...)
13788 * @example
13789 * ```ts
13790 * const flicking = new Flicking("#flick");
13791 * // These are possible parameters
13792 * flicking.append(document.createElement("div"));
13793 * flicking.append("\<div\>Panel\</div\>");
13794 * flicking.append(["\<div\>Panel\</div\>", document.createElement("div")]);
13795 * // Even this is possible
13796 * flicking.append("\<div\>Panel 1\</div\>\<div\>Panel 2\</div\>");
13797 * ```
13798 */
13799
13800
13801 __proto.append = function (element) {
13802 return this.insert(this._renderer.panelCount, element);
13803 };
13804 /**
13805 * Add new panels before the first panel
13806 * This will increase index of panels after by the number of panels added
13807 * @ko 패널 목록의 제일 앞(index 0)에 새로운 패널들을 추가합니다
13808 * 추가한 패널의 개수만큼 기존 패널들의 인덱스가 증가합니다.
13809 * @param {ElementLike | ElementLike[]} element A new HTMLElement, a outerHTML of element, or an array of both
13810 * <ko>새로운 HTMLElement, 혹은 엘리먼트의 outerHTML, 혹은 그것들의 배열</ko>
13811 * @return {Panel[]} An array of prepended panels<ko>추가된 패널들의 배열</ko>
13812 * @see Panel
13813 * @see ElementLike
13814 * @throws {FlickingError} {@link ERROR_CODE ERROR_CODE.NOT_ALLOWED_IN_FRAMEWORK} if called on frameworks (React, Angular, Vue...)
13815 * @example
13816 * ```ts
13817 * const flicking = new eg.Flicking("#flick");
13818 * flicking.prepend(document.createElement("div"));
13819 * flicking.prepend("\<div\>Panel\</div\>");
13820 * flicking.prepend(["\<div\>Panel\</div\>", document.createElement("div")]);
13821 * // Even this is possible
13822 * flicking.prepend("\<div\>Panel 1\</div\>\<div\>Panel 2\</div\>");
13823 * ```
13824 */
13825
13826
13827 __proto.prepend = function (element) {
13828 return this.insert(0, element);
13829 };
13830 /**
13831 * Insert new panels at given index
13832 * This will increase index of panels after by the number of panels added
13833 * @ko 주어진 인덱스에 새로운 패널들을 추가합니다
13834 * 해당 인덱스보다 같거나 큰 인덱스를 가진 기존 패널들은 추가한 패널의 개수만큼 인덱스가 증가합니다.
13835 * @param {number} index Index to insert new panels at<ko>새로 패널들을 추가할 인덱스</ko>
13836 * @param {ElementLike | ElementLike[]} element A new HTMLElement, a outerHTML of element, or an array of both
13837 * <ko>새로운 HTMLElement, 혹은 엘리먼트의 outerHTML, 혹은 그것들의 배열</ko>
13838 * @return {Panel[]} An array of prepended panels<ko>추가된 패널들의 배열</ko>
13839 * @throws {FlickingError} {@link ERROR_CODE ERROR_CODE.NOT_ALLOWED_IN_FRAMEWORK} if called on frameworks (React, Angular, Vue...)
13840 * @example
13841 * ```ts
13842 * const flicking = new eg.Flicking("#flick");
13843 * flicking.insert(0, document.createElement("div"));
13844 * flicking.insert(2, "\<div\>Panel\</div\>");
13845 * flicking.insert(1, ["\<div\>Panel\</div\>", document.createElement("div")]);
13846 * // Even this is possible
13847 * flicking.insert(3, "\<div\>Panel 1\</div\>\<div\>Panel 2\</div\>");
13848 * ```
13849 */
13850
13851
13852 __proto.insert = function (index, element) {
13853 if (this._renderExternal) {
13854 throw new FlickingError(MESSAGE.NOT_ALLOWED_IN_FRAMEWORK, CODE.NOT_ALLOWED_IN_FRAMEWORK);
13855 }
13856
13857 return this._renderer.batchInsert({
13858 index: index,
13859 elements: parseElement(element),
13860 hasDOMInElements: true
13861 });
13862 };
13863 /**
13864 * Remove the panel at the given index
13865 * This will decrease index of panels after by the number of panels removed
13866 * @ko 주어진 인덱스의 패널을 제거합니다
13867 * 해당 인덱스보다 큰 인덱스를 가진 기존 패널들은 제거한 패널의 개수만큼 인덱스가 감소합니다
13868 * @param {number} index Index of panel to remove<ko>제거할 패널의 인덱스</ko>
13869 * @param {number} [deleteCount=1] Number of panels to remove from index<ko>`index` 이후로 제거할 패널의 개수</ko>
13870 * @return {Panel[]} An array of removed panels<ko>제거된 패널들의 배열</ko>
13871 */
13872
13873
13874 __proto.remove = function (index, deleteCount) {
13875 if (deleteCount === void 0) {
13876 deleteCount = 1;
13877 }
13878
13879 if (this._renderExternal) {
13880 throw new FlickingError(MESSAGE.NOT_ALLOWED_IN_FRAMEWORK, CODE.NOT_ALLOWED_IN_FRAMEWORK);
13881 }
13882
13883 return this._renderer.batchRemove({
13884 index: index,
13885 deleteCount: deleteCount,
13886 hasDOMInElements: true
13887 });
13888 };
13889
13890 __proto._createControl = function () {
13891 var _a;
13892
13893 var moveType = this._moveType;
13894 var moveTypes = Object.keys(MOVE_TYPE).map(function (key) {
13895 return MOVE_TYPE[key];
13896 });
13897 var moveTypeStr = Array.isArray(moveType) ? moveType[0] : moveType;
13898 var moveTypeOptions = Array.isArray(moveType) ? (_a = moveType[1]) !== null && _a !== void 0 ? _a : {} : {};
13899
13900 if (!includes(moveTypes, moveTypeStr)) {
13901 throw new FlickingError(MESSAGE.WRONG_OPTION("moveType", JSON.stringify(moveType)), CODE.WRONG_OPTION);
13902 }
13903
13904 switch (moveTypeStr) {
13905 case MOVE_TYPE.SNAP:
13906 return new SnapControl(moveTypeOptions);
13907
13908 case MOVE_TYPE.FREE_SCROLL:
13909 return new FreeControl(moveTypeOptions);
13910
13911 case MOVE_TYPE.STRICT:
13912 return new StrictControl(moveTypeOptions);
13913 }
13914 };
13915
13916 __proto._createCamera = function () {
13917 if (this._circular && this._bound) {
13918 // eslint-disable-next-line no-console
13919 console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
13920 }
13921
13922 return new Camera$1(this, {
13923 align: this._align
13924 });
13925 };
13926
13927 __proto._createRenderer = function () {
13928 var externalRenderer = this._externalRenderer;
13929
13930 if (this._virtual && this._panelsPerView <= 0) {
13931 // eslint-disable-next-line no-console
13932 console.warn("\"virtual\" and \"panelsPerView\" option should be used together, ignoring virtual.");
13933 }
13934
13935 return externalRenderer ? externalRenderer : this._renderExternal ? this._createExternalRenderer() : this._createVanillaRenderer();
13936 };
13937
13938 __proto._createExternalRenderer = function () {
13939 var _a = this._renderExternal,
13940 renderer = _a.renderer,
13941 rendererOptions = _a.rendererOptions;
13942 return new renderer(__assign$2({
13943 align: this._align
13944 }, rendererOptions));
13945 };
13946
13947 __proto._createVanillaRenderer = function () {
13948 var virtual = this.virtualEnabled;
13949 return new VanillaRenderer({
13950 align: this._align,
13951 strategy: virtual ? new VirtualRenderingStrategy() : new NormalRenderingStrategy({
13952 providerCtor: VanillaElementProvider
13953 })
13954 });
13955 };
13956
13957 __proto._moveToInitialPanel = function () {
13958 var renderer = this._renderer;
13959 var control = this._control;
13960 var camera = this._camera;
13961 var defaultPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
13962 if (!defaultPanel) return;
13963 var nearestAnchor = camera.findNearestAnchor(defaultPanel.position);
13964 var initialPanel = nearestAnchor && defaultPanel.index !== nearestAnchor.panel.index ? nearestAnchor.panel : defaultPanel;
13965 control.setActive(initialPanel, null, false);
13966
13967 if (!nearestAnchor) {
13968 throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(initialPanel.position), CODE.POSITION_NOT_REACHABLE);
13969 }
13970
13971 var position = initialPanel.position;
13972
13973 if (!camera.canReach(initialPanel)) {
13974 position = nearestAnchor.position;
13975 }
13976
13977 camera.lookAt(position);
13978 control.updateInput();
13979 camera.updateOffset();
13980 };
13981
13982 __proto._initialResize = function () {
13983 var viewport = this._viewport;
13984 var renderer = this._renderer;
13985 var camera = this._camera;
13986 var control = this._control;
13987 this.trigger(new ComponentEvent$1(EVENTS.BEFORE_RESIZE, {
13988 width: 0,
13989 height: 0,
13990 element: viewport.element
13991 }));
13992 viewport.resize();
13993 renderer.updatePanelSize();
13994 camera.updateAlignPos();
13995 camera.updateRange();
13996 camera.updateAnchors();
13997 camera.updateOffset();
13998 control.updateInput();
13999 var newWidth = viewport.width;
14000 var newHeight = viewport.height;
14001 var sizeChanged = newWidth !== 0 || newHeight !== 0;
14002 this.trigger(new ComponentEvent$1(EVENTS.AFTER_RESIZE, {
14003 width: viewport.width,
14004 height: viewport.height,
14005 prev: {
14006 width: 0,
14007 height: 0
14008 },
14009 sizeChanged: sizeChanged,
14010 element: viewport.element
14011 }));
14012 };
14013 /**
14014 * Version info string
14015 * @ko 버전정보 문자열
14016 * @type {string}
14017 * @readonly
14018 * @example
14019 * ```ts
14020 * Flicking.VERSION; // ex) 4.0.0
14021 * ```
14022 */
14023
14024
14025 Flicking.VERSION = "4.10.0";
14026 return Flicking;
14027 }(Component);
14028
14029 /*
14030 * Copyright (c) 2015 NAVER Corp.
14031 * egjs projects are licensed under the MIT license
14032 */
14033
14034 var Core = {
14035 __proto__: null,
14036 Viewport: Viewport,
14037 FlickingError: FlickingError,
14038 AnchorPoint: AnchorPoint,
14039 VirtualManager: VirtualManager,
14040 VanillaElementProvider: VanillaElementProvider,
14041 VirtualElementProvider: VirtualElementProvider,
14042 Panel: Panel,
14043 VirtualPanel: VirtualPanel
14044 };
14045
14046 /**
14047 * Decorator that makes the method of flicking available in the framework.
14048 * @ko 프레임워크에서 플리킹의 메소드를 사용할 수 있게 하는 데코레이터.
14049 * @memberof eg.Flicking
14050 * @private
14051 * @example
14052 * ```js
14053 * import Flicking, { withFlickingMethods } from "@egjs/flicking";
14054 *
14055 * class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>> {
14056 * &#64;withFlickingMethods
14057 * private flicking: Flicking;
14058 * }
14059 * ```
14060 */
14061
14062 var withFlickingMethods = function (prototype, flickingName) {
14063 [Component.prototype, Flicking.prototype].forEach(function (proto) {
14064 Object.getOwnPropertyNames(proto).filter(function (name) {
14065 return !prototype[name] && name.indexOf("_") !== 0 && name !== "constructor";
14066 }).forEach(function (name) {
14067 var descriptor = Object.getOwnPropertyDescriptor(proto, name);
14068
14069 if (descriptor.value) {
14070 // Public Function
14071 Object.defineProperty(prototype, name, {
14072 value: function () {
14073 var _a;
14074
14075 var args = [];
14076
14077 for (var _i = 0; _i < arguments.length; _i++) {
14078 args[_i] = arguments[_i];
14079 }
14080
14081 return (_a = descriptor.value).call.apply(_a, __spread$1([this[flickingName]], args));
14082 }
14083 });
14084 } else {
14085 var getterDescriptor = {};
14086
14087 if (descriptor.get) {
14088 getterDescriptor.get = function () {
14089 var _a;
14090
14091 var flicking = this[flickingName];
14092 return flicking && ((_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(flicking));
14093 };
14094 }
14095
14096 if (descriptor.set) {
14097 getterDescriptor.set = function () {
14098 var _a;
14099
14100 var args = [];
14101
14102 for (var _i = 0; _i < arguments.length; _i++) {
14103 args[_i] = arguments[_i];
14104 }
14105
14106 return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spread$1([this[flickingName]], args));
14107 };
14108 }
14109
14110 Object.defineProperty(prototype, name, getterDescriptor);
14111 }
14112 });
14113 });
14114 };
14115
14116 var sync = (function (flicking, diffResult, rendered) {
14117 var renderer = flicking.renderer;
14118 var panels = renderer.panels;
14119
14120 var prevList = __spread$1(diffResult.prevList);
14121
14122 var added = [];
14123 var removed = [];
14124
14125 if (diffResult.removed.length > 0) {
14126 var endIdx_1 = -1;
14127 var prevIdx_1 = -1;
14128 diffResult.removed.forEach(function (removedIdx) {
14129 if (endIdx_1 < 0) {
14130 endIdx_1 = removedIdx;
14131 }
14132
14133 if (prevIdx_1 >= 0 && removedIdx !== prevIdx_1 - 1) {
14134 removed.push.apply(removed, __spread$1(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
14135 endIdx_1 = removedIdx;
14136 prevIdx_1 = removedIdx;
14137 } else {
14138 prevIdx_1 = removedIdx;
14139 }
14140
14141 prevList.splice(removedIdx, 1);
14142 });
14143 removed.push.apply(removed, __spread$1(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
14144 }
14145
14146 diffResult.ordered.forEach(function (_a) {
14147 var _b = __read$1(_a, 2),
14148 from = _b[0],
14149 to = _b[1];
14150
14151 var prevPanel = panels.splice(from, 1)[0];
14152 panels.splice(to, 0, prevPanel);
14153 });
14154
14155 if (diffResult.ordered.length > 0) {
14156 panels.forEach(function (panel, idx) {
14157 var indexDiff = idx - panel.index;
14158
14159 if (indexDiff > 0) {
14160 panel.increaseIndex(indexDiff);
14161 } else {
14162 panel.decreaseIndex(-indexDiff);
14163 }
14164 });
14165 panels.sort(function (panel1, panel2) {
14166 return panel1.index - panel2.index;
14167 });
14168 panels.forEach(function (panel) {
14169 panel.updatePosition();
14170 });
14171 }
14172
14173 if (diffResult.added.length > 0) {
14174 var startIdx_1 = -1;
14175 var prevIdx_2 = -1;
14176 var addedElements_1 = rendered.slice(prevList.length);
14177 diffResult.added.forEach(function (addedIdx, idx) {
14178 if (startIdx_1 < 0) {
14179 startIdx_1 = idx;
14180 }
14181
14182 if (prevIdx_2 >= 0 && addedIdx !== prevIdx_2 + 1) {
14183 added.push.apply(added, __spread$1(batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1)));
14184 startIdx_1 = -1;
14185 prevIdx_2 = -1;
14186 } else {
14187 prevIdx_2 = addedIdx;
14188 }
14189 });
14190
14191 if (startIdx_1 >= 0) {
14192 added.push.apply(added, __spread$1(batchInsert(renderer, diffResult, addedElements_1, startIdx_1)));
14193 }
14194 }
14195
14196 if (diffResult.added.length > 0 || diffResult.removed.length > 0) {
14197 renderer.updateAfterPanelChange(added, removed);
14198 }
14199 });
14200
14201 var batchInsert = function (renderer, diffResult, addedElements, startIdx, endIdx) {
14202 return renderer.batchInsertDefer.apply(renderer, __spread$1(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
14203 return {
14204 index: index,
14205 elements: [addedElements[elIdx]],
14206 hasDOMInElements: false
14207 };
14208 })));
14209 };
14210
14211 var batchRemove = function (renderer, startIdx, endIdx) {
14212 var removed = renderer.panels.slice(startIdx, endIdx);
14213 return renderer.batchRemoveDefer({
14214 index: startIdx,
14215 deleteCount: removed.length,
14216 hasDOMInElements: false
14217 });
14218 };
14219
14220 var getRenderingPanels = (function (flicking, diffResult) {
14221 var removedPanels = diffResult.removed.reduce(function (map, idx) {
14222 map[idx] = true;
14223 return map;
14224 }, {});
14225 var maintainedMap = diffResult.maintained.reduce(function (map, _a) {
14226 var _b = __read$1(_a, 2),
14227 prev = _b[0],
14228 current = _b[1];
14229
14230 map[prev] = current;
14231 return map;
14232 }, {});
14233 return __spread$1(flicking.panels.filter(function (panel) {
14234 return !removedPanels[panel.index];
14235 }) // Sort panels by position
14236 .sort(function (panel1, panel2) {
14237 return panel1.position + panel1.offset - (panel2.position + panel2.offset);
14238 }).map(function (panel) {
14239 return diffResult.list[maintainedMap[panel.index]];
14240 }), diffResult.added.map(function (idx) {
14241 return diffResult.list[idx];
14242 }));
14243 });
14244
14245 var getDefaultCameraTransform = (function (align, horizontal, firstPanelSize) {
14246 if (align === void 0) {
14247 align = ALIGN.CENTER;
14248 }
14249
14250 if (horizontal === void 0) {
14251 horizontal = true;
14252 }
14253
14254 var cameraAlign = getCameraAlign(align);
14255 var panelAlign = getPanelAlign(align);
14256 if (panelAlign == null) return "";
14257 var camPosition = "calc(" + cameraAlign + " - (" + (firstPanelSize || "0px") + " * " + panelAlign.percentage + ") - " + panelAlign.absolute + "px)";
14258 return horizontal ? "translate(" + camPosition + ")" : "translate(0, " + camPosition + ")";
14259 });
14260
14261 var getCameraAlign = function (align) {
14262 var alignVal = typeof align === "object" ? align.camera : align;
14263 return parseAlign(alignVal);
14264 };
14265
14266 var getPanelAlign = function (align) {
14267 var alignVal = typeof align === "object" ? align.panel : align;
14268 return parseArithmeticExpression(parseAlign(alignVal));
14269 };
14270
14271 var parseAlign = function (alignVal) {
14272 if (typeof alignVal === "number") {
14273 return alignVal + "px";
14274 }
14275
14276 switch (alignVal) {
14277 case ALIGN.CENTER:
14278 return "50%";
14279
14280 case ALIGN.NEXT:
14281 return "100%";
14282
14283 case ALIGN.PREV:
14284 return "0%";
14285
14286 default:
14287 return alignVal;
14288 }
14289 };
14290
14291 var CFC = {
14292 __proto__: null,
14293 withFlickingMethods: withFlickingMethods,
14294 sync: sync,
14295 getRenderingPanels: getRenderingPanels,
14296 getDefaultCameraTransform: getDefaultCameraTransform
14297 };
14298
14299 /*
14300 * Copyright (c) 2015 NAVER Corp.
14301 * egjs projects are licensed under the MIT license
14302 */
14303 merge(Flicking, Core);
14304 merge(Flicking, Camera);
14305 merge(Flicking, Control);
14306 merge(Flicking, Renderer);
14307 merge(Flicking, Constants);
14308 merge(Flicking, CFC);
14309 merge(Flicking, Utils);
14310
14311 return Flicking;
14312
14313}));
14314//# sourceMappingURL=flicking.pkgd.js.map