1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
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 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
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 |
|
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 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 | |
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
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 |
|
323 |
|
324 |
|
325 | var isUndefined = function (value) {
|
326 | return typeof value === "undefined";
|
327 | };
|
328 |
|
329 | |
330 |
|
331 |
|
332 |
|
333 |
|
334 | var ComponentEvent =
|
335 |
|
336 | function () {
|
337 | |
338 |
|
339 |
|
340 |
|
341 |
|
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;
|
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 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 | var __proto = ComponentEvent.prototype;
|
377 |
|
378 | __proto.stop = function () {
|
379 | this._canceled = true;
|
380 | };
|
381 | |
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 | __proto.isCanceled = function () {
|
389 | return this._canceled;
|
390 | };
|
391 |
|
392 | return ComponentEvent;
|
393 | }();
|
394 |
|
395 | |
396 |
|
397 |
|
398 |
|
399 |
|
400 | var Component =
|
401 |
|
402 | function () {
|
403 | |
404 |
|
405 |
|
406 | function Component() {
|
407 | this._eventHandler = {};
|
408 | }
|
409 | |
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
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 |
|
477 | handler.apply(void 0, __spread(params));
|
478 | });
|
479 | }
|
480 |
|
481 | return this;
|
482 | };
|
483 | |
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
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 | }
|
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 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 | __proto.hasOn = function (eventName) {
|
565 | return !!this._eventHandler[eventName];
|
566 | };
|
567 | |
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
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 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 | __proto.off = function (eventName, handlerToDetach) {
|
638 | var e_1, _a;
|
639 |
|
640 |
|
641 | if (isUndefined(eventName)) {
|
642 | this._eventHandler = {};
|
643 | return this;
|
644 | }
|
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 | }
|
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 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 | Component.VERSION = "3.0.2";
|
711 | return Component;
|
712 | }();
|
713 |
|
714 | |
715 |
|
716 |
|
717 |
|
718 |
|
719 | var ComponentEvent$1 = ComponentEvent;
|
720 |
|
721 | |
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 | |
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
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 |
|
802 |
|
803 |
|
804 | |
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 |
|
812 |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 |
|
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 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 | var ALIGN = {
|
856 | PREV: "prev",
|
857 | CENTER: "center",
|
858 | NEXT: "next"
|
859 | };
|
860 | |
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 |
|
871 | var DIRECTION = {
|
872 | PREV: "PREV",
|
873 | NEXT: "NEXT",
|
874 | NONE: null
|
875 | };
|
876 | |
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
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 |
|
900 |
|
901 |
|
902 |
|
903 |
|
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 | }
|
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 | }
|
1071 |
|
1072 |
|
1073 | ++idx;
|
1074 | matchResult = cssRegex.exec(cssValue);
|
1075 | }
|
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 | };
|
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 |
|
1314 |
|
1315 |
|
1316 | |
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 | var FlickingError =
|
1336 |
|
1337 | function (_super) {
|
1338 | __extends$2(FlickingError, _super);
|
1339 | |
1340 |
|
1341 |
|
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 |
|
1359 |
|
1360 |
|
1361 |
|
1362 | var Viewport =
|
1363 |
|
1364 | function () {
|
1365 | |
1366 |
|
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 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 | get: function () {
|
1391 | return this._el;
|
1392 | },
|
1393 | enumerable: false,
|
1394 | configurable: true
|
1395 | });
|
1396 | Object.defineProperty(__proto, "width", {
|
1397 | |
1398 |
|
1399 |
|
1400 |
|
1401 |
|
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 |
|
1412 |
|
1413 |
|
1414 |
|
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 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 | get: function () {
|
1434 | return this._padding;
|
1435 | },
|
1436 | enumerable: false,
|
1437 | configurable: true
|
1438 | });
|
1439 | |
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
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 |
|
1478 |
|
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 |
|
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 | };
|
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 |
|
1619 |
|
1620 | var VanillaElementProvider =
|
1621 |
|
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 |
|
1669 |
|
1670 |
|
1671 |
|
1672 | |
1673 |
|
1674 |
|
1675 | var VirtualElementProvider =
|
1676 |
|
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 () {
|
1713 |
|
1714 | };
|
1715 |
|
1716 | __proto.hide = function () {
|
1717 |
|
1718 | };
|
1719 |
|
1720 | return VirtualElementProvider;
|
1721 | }();
|
1722 |
|
1723 | |
1724 |
|
1725 |
|
1726 |
|
1727 | var VirtualManager =
|
1728 |
|
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 |
|
1753 |
|
1754 | |
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 |
|
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 |
|
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 | get: function () {
|
1784 | return this._initialPanelCount;
|
1785 | },
|
1786 | enumerable: false,
|
1787 | configurable: true
|
1788 | });
|
1789 | Object.defineProperty(__proto, "cache", {
|
1790 | |
1791 |
|
1792 |
|
1793 |
|
1794 |
|
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 |
|
1808 |
|
1809 |
|
1810 |
|
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 |
|
1857 |
|
1858 |
|
1859 |
|
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 |
|
1873 |
|
1874 |
|
1875 |
|
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 |
|
1888 |
|
1889 |
|
1890 |
|
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 |
|
1909 |
|
1910 |
|
1911 |
|
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 |
|
1949 |
|
1950 |
|
1951 |
|
1952 |
|
1953 |
|
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 | }];
|
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 |
|
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;
|
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 |
|
2303 |
|
2304 |
|
2305 |
|
2306 |
|
2307 |
|
2308 |
|
2309 |
|
2310 |
|
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 |
|
2323 |
|
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 | |
2331 |
|
2332 |
|
2333 |
|
2334 |
|
2335 | function keys(obj) {
|
2336 | return Object.keys(obj);
|
2337 | }
|
2338 |
|
2339 | var OBSERVERS_PATH = "__observers__";
|
2340 |
|
2341 | var Observer =
|
2342 |
|
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 |
|
2425 |
|
2426 |
|
2427 |
|
2428 |
|
2429 |
|
2430 |
|
2431 |
|
2432 | |
2433 |
|
2434 |
|
2435 |
|
2436 |
|
2437 |
|
2438 |
|
2439 |
|
2440 |
|
2441 |
|
2442 |
|
2443 |
|
2444 |
|
2445 |
|
2446 |
|
2447 |
|
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 |
|
2492 |
|
2493 |
|
2494 |
|
2495 |
|
2496 | var win;
|
2497 |
|
2498 | if (typeof window === "undefined") {
|
2499 |
|
2500 | win = {
|
2501 | navigator: {
|
2502 | userAgent: ""
|
2503 | }
|
2504 | };
|
2505 | } else {
|
2506 | win = window;
|
2507 | }
|
2508 |
|
2509 | |
2510 |
|
2511 |
|
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 |
|
2550 |
|
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 |
|
2568 |
|
2569 | var match = param.match(/^<([a-z]+)\s*([^>]*)>/);
|
2570 |
|
2571 | if (match) {
|
2572 |
|
2573 | var dummy = document.createElement("div");
|
2574 | dummy.innerHTML = param;
|
2575 | el = toArray$1(dummy.childNodes);
|
2576 | } else {
|
2577 |
|
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 |
|
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 |
|
2591 | el = param;
|
2592 | } else if ("jQuery" in win && param instanceof jQuery || param.constructor.prototype.jquery) {
|
2593 |
|
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 |
|
2640 |
|
2641 |
|
2642 |
|
2643 |
|
2644 |
|
2645 | var requestAnimationFrame = function (fp) {
|
2646 | return raf(fp);
|
2647 | };
|
2648 | |
2649 |
|
2650 |
|
2651 |
|
2652 |
|
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 |
|
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 |
|
2721 |
|
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 | }
|
2732 |
|
2733 |
|
2734 |
|
2735 | return v.indexOf(".") >= 0 ? v.length - v.indexOf(".") - 1 : 0;
|
2736 | };
|
2737 | var inversePow = function (n) {
|
2738 |
|
2739 |
|
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 |
|
2815 | function () {
|
2816 | function EventManager(_axes) {
|
2817 | this._axes = _axes;
|
2818 | }
|
2819 | |
2820 |
|
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 |
|
2826 |
|
2827 |
|
2828 |
|
2829 |
|
2830 |
|
2831 |
|
2832 |
|
2833 |
|
2834 |
|
2835 |
|
2836 |
|
2837 |
|
2838 |
|
2839 |
|
2840 |
|
2841 |
|
2842 |
|
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 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 |
|
2867 |
|
2868 |
|
2869 |
|
2870 |
|
2871 |
|
2872 |
|
2873 |
|
2874 |
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 | |
2880 |
|
2881 |
|
2882 |
|
2883 |
|
2884 |
|
2885 |
|
2886 |
|
2887 |
|
2888 |
|
2889 |
|
2890 |
|
2891 |
|
2892 |
|
2893 |
|
2894 |
|
2895 |
|
2896 |
|
2897 |
|
2898 | |
2899 |
|
2900 |
|
2901 |
|
2902 |
|
2903 |
|
2904 |
|
2905 |
|
2906 |
|
2907 |
|
2908 |
|
2909 |
|
2910 |
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 |
|
2919 |
|
2920 |
|
2921 |
|
2922 |
|
2923 |
|
2924 |
|
2925 |
|
2926 |
|
2927 |
|
2928 |
|
2929 |
|
2930 |
|
2931 |
|
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 |
|
2952 |
|
2953 |
|
2954 |
|
2955 |
|
2956 |
|
2957 |
|
2958 |
|
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 |
|
2965 |
|
2966 |
|
2967 |
|
2968 |
|
2969 |
|
2970 |
|
2971 |
|
2972 |
|
2973 |
|
2974 |
|
2975 |
|
2976 |
|
2977 |
|
2978 |
|
2979 |
|
2980 |
|
2981 |
|
2982 |
|
2983 |
|
2984 |
|
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 () {}
|
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 |
|
3035 |
|
3036 |
|
3037 |
|
3038 |
|
3039 |
|
3040 |
|
3041 |
|
3042 |
|
3043 |
|
3044 |
|
3045 |
|
3046 |
|
3047 |
|
3048 |
|
3049 |
|
3050 |
|
3051 |
|
3052 |
|
3053 |
|
3054 |
|
3055 |
|
3056 |
|
3057 |
|
3058 |
|
3059 |
|
3060 |
|
3061 |
|
3062 |
|
3063 |
|
3064 |
|
3065 |
|
3066 |
|
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 |
|
3088 |
|
3089 |
|
3090 |
|
3091 |
|
3092 |
|
3093 |
|
3094 |
|
3095 |
|
3096 |
|
3097 |
|
3098 |
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 |
|
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 |
|
3120 |
|
3121 |
|
3122 |
|
3123 |
|
3124 |
|
3125 |
|
3126 |
|
3127 |
|
3128 |
|
3129 |
|
3130 |
|
3131 |
|
3132 |
|
3133 |
|
3134 |
|
3135 |
|
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 | }
|
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 |
|
3184 | var roundUnit = this._axes.options.round;
|
3185 |
|
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 |
|
3211 | function () {
|
3212 | function InterruptManager(_options) {
|
3213 | this._options = _options;
|
3214 | this._prevented = false;
|
3215 | }
|
3216 |
|
3217 | var __proto = InterruptManager.prototype;
|
3218 |
|
3219 | __proto.isInterrupting = function () {
|
3220 |
|
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 |
|
3239 |
|
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 | };
|
3248 |
|
3249 | var isOutside = function (pos, range) {
|
3250 | return pos < range[0] || pos > range[1];
|
3251 | };
|
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);
|
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 |
|
3272 | toPos = (toPos - max) % length + min;
|
3273 | }
|
3274 |
|
3275 | if (circular[0] && pos < min) {
|
3276 |
|
3277 | toPos = (toPos - min) % length + max;
|
3278 | }
|
3279 |
|
3280 | return toPos;
|
3281 | };
|
3282 |
|
3283 | var AxisManager =
|
3284 |
|
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 |
|
3395 |
|
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 |
|
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 |
|
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 |
|
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;
|
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 |
|
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"];
|
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;
|
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 |
|
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;
|
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 |
|
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 |
|
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;
|
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 | }
|
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 | }
|
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;
|
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 | };
|
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 |
|
4176 | return min - _this._animationManager.interpolate(min - v, out[0]);
|
4177 | } else if (v > max) {
|
4178 |
|
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 |
|
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;
|
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);
|
4337 |
|
4338 | var userWish = this.getUserControl(param);
|
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 |
|
4482 |
|
4483 |
|
4484 |
|
4485 |
|
4486 |
|
4487 |
|
4488 |
|
4489 |
|
4490 |
|
4491 |
|
4492 | __proto._getFinalPos = function (destPos, originalIntendedPos) {
|
4493 | var _this = this;
|
4494 |
|
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 |
|
4501 | return originalIntendedPos[key];
|
4502 | } else {
|
4503 |
|
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;
|
4515 |
|
4516 | var minRoundUnit = null;
|
4517 |
|
4518 |
|
4519 | if (!roundUnit) {
|
4520 |
|
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 |
|
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();
|
4570 |
|
4571 |
|
4572 |
|
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;
|
4581 |
|
4582 |
|
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);
|
4616 |
|
4617 |
|
4618 |
|
4619 | var circulatedPos = getCirculatedPos(nextPos, options.range, options.circular);
|
4620 |
|
4621 | if (nextPos !== circulatedPos) {
|
4622 |
|
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 |
|
4647 |
|
4648 |
|
4649 |
|
4650 |
|
4651 |
|
4652 |
|
4653 |
|
4654 |
|
4655 |
|
4656 |
|
4657 |
|
4658 |
|
4659 |
|
4660 | |
4661 |
|
4662 |
|
4663 |
|
4664 |
|
4665 |
|
4666 |
|
4667 |
|
4668 |
|
4669 |
|
4670 |
|
4671 |
|
4672 |
|
4673 |
|
4674 |
|
4675 |
|
4676 |
|
4677 |
|
4678 |
|
4679 | |
4680 |
|
4681 |
|
4682 |
|
4683 |
|
4684 |
|
4685 |
|
4686 |
|
4687 |
|
4688 |
|
4689 |
|
4690 |
|
4691 |
|
4692 |
|
4693 |
|
4694 |
|
4695 |
|
4696 |
|
4697 |
|
4698 |
|
4699 |
|
4700 |
|
4701 |
|
4702 |
|
4703 |
|
4704 |
|
4705 |
|
4706 |
|
4707 |
|
4708 |
|
4709 |
|
4710 |
|
4711 |
|
4712 |
|
4713 |
|
4714 |
|
4715 |
|
4716 |
|
4717 |
|
4718 |
|
4719 |
|
4720 |
|
4721 |
|
4722 |
|
4723 |
|
4724 |
|
4725 |
|
4726 |
|
4727 |
|
4728 |
|
4729 |
|
4730 |
|
4731 |
|
4732 |
|
4733 |
|
4734 |
|
4735 |
|
4736 |
|
4737 |
|
4738 |
|
4739 |
|
4740 |
|
4741 |
|
4742 |
|
4743 |
|
4744 |
|
4745 |
|
4746 |
|
4747 |
|
4748 |
|
4749 | var Axes =
|
4750 |
|
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 |
|
4803 |
|
4804 |
|
4805 |
|
4806 |
|
4807 |
|
4808 |
|
4809 |
|
4810 |
|
4811 |
|
4812 |
|
4813 |
|
4814 |
|
4815 |
|
4816 |
|
4817 |
|
4818 |
|
4819 |
|
4820 |
|
4821 |
|
4822 |
|
4823 |
|
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 | }
|
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 |
|
4853 |
|
4854 |
|
4855 |
|
4856 |
|
4857 |
|
4858 |
|
4859 |
|
4860 |
|
4861 |
|
4862 |
|
4863 |
|
4864 |
|
4865 |
|
4866 |
|
4867 |
|
4868 |
|
4869 |
|
4870 |
|
4871 |
|
4872 |
|
4873 |
|
4874 |
|
4875 |
|
4876 |
|
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 |
|
4902 |
|
4903 |
|
4904 |
|
4905 |
|
4906 |
|
4907 |
|
4908 |
|
4909 |
|
4910 |
|
4911 |
|
4912 |
|
4913 |
|
4914 |
|
4915 |
|
4916 |
|
4917 |
|
4918 |
|
4919 |
|
4920 |
|
4921 |
|
4922 |
|
4923 |
|
4924 |
|
4925 | __proto.get = function (axes) {
|
4926 | return this.axisManager.get(axes);
|
4927 | };
|
4928 | |
4929 |
|
4930 |
|
4931 |
|
4932 |
|
4933 |
|
4934 |
|
4935 |
|
4936 |
|
4937 |
|
4938 |
|
4939 |
|
4940 |
|
4941 |
|
4942 |
|
4943 |
|
4944 |
|
4945 |
|
4946 |
|
4947 |
|
4948 |
|
4949 |
|
4950 |
|
4951 |
|
4952 |
|
4953 |
|
4954 |
|
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 |
|
4969 |
|
4970 |
|
4971 |
|
4972 |
|
4973 |
|
4974 |
|
4975 |
|
4976 |
|
4977 |
|
4978 |
|
4979 |
|
4980 |
|
4981 |
|
4982 |
|
4983 |
|
4984 |
|
4985 |
|
4986 |
|
4987 |
|
4988 |
|
4989 |
|
4990 |
|
4991 |
|
4992 |
|
4993 |
|
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 |
|
5008 |
|
5009 |
|
5010 |
|
5011 |
|
5012 |
|
5013 |
|
5014 |
|
5015 |
|
5016 |
|
5017 |
|
5018 |
|
5019 |
|
5020 |
|
5021 |
|
5022 |
|
5023 |
|
5024 |
|
5025 |
|
5026 |
|
5027 |
|
5028 |
|
5029 |
|
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 |
|
5040 |
|
5041 |
|
5042 |
|
5043 |
|
5044 |
|
5045 |
|
5046 |
|
5047 |
|
5048 |
|
5049 |
|
5050 |
|
5051 |
|
5052 |
|
5053 |
|
5054 |
|
5055 |
|
5056 |
|
5057 |
|
5058 |
|
5059 |
|
5060 |
|
5061 |
|
5062 |
|
5063 |
|
5064 |
|
5065 |
|
5066 | __proto.setAxis = function (axis) {
|
5067 | this.axisManager.setAxis(axis);
|
5068 | return this;
|
5069 | };
|
5070 | |
5071 |
|
5072 |
|
5073 |
|
5074 |
|
5075 |
|
5076 |
|
5077 |
|
5078 |
|
5079 |
|
5080 |
|
5081 |
|
5082 |
|
5083 |
|
5084 |
|
5085 |
|
5086 |
|
5087 |
|
5088 |
|
5089 |
|
5090 | __proto.stopAnimation = function () {
|
5091 | this.animationManager.stopAnimation();
|
5092 | this.animationManager.finish(false);
|
5093 | return this;
|
5094 | };
|
5095 | |
5096 |
|
5097 |
|
5098 |
|
5099 |
|
5100 |
|
5101 |
|
5102 |
|
5103 |
|
5104 |
|
5105 |
|
5106 |
|
5107 |
|
5108 |
|
5109 |
|
5110 |
|
5111 |
|
5112 |
|
5113 |
|
5114 |
|
5115 |
|
5116 |
|
5117 |
|
5118 |
|
5119 |
|
5120 |
|
5121 |
|
5122 |
|
5123 |
|
5124 |
|
5125 | __proto.updateAnimation = function (options) {
|
5126 | this.animationManager.updateAnimation(options);
|
5127 | return this;
|
5128 | };
|
5129 | |
5130 |
|
5131 |
|
5132 |
|
5133 |
|
5134 |
|
5135 |
|
5136 |
|
5137 |
|
5138 |
|
5139 |
|
5140 |
|
5141 |
|
5142 |
|
5143 |
|
5144 |
|
5145 |
|
5146 |
|
5147 |
|
5148 |
|
5149 |
|
5150 |
|
5151 |
|
5152 |
|
5153 |
|
5154 |
|
5155 | __proto.isBounceArea = function (axes) {
|
5156 | return this.axisManager.isOutside(axes);
|
5157 | };
|
5158 | |
5159 |
|
5160 |
|
5161 |
|
5162 |
|
5163 |
|
5164 | __proto.destroy = function () {
|
5165 | this.disconnect();
|
5166 | this.eventManager.destroy();
|
5167 | };
|
5168 | |
5169 |
|
5170 |
|
5171 |
|
5172 |
|
5173 |
|
5174 |
|
5175 |
|
5176 |
|
5177 |
|
5178 |
|
5179 |
|
5180 |
|
5181 |
|
5182 | Axes.VERSION = "3.8.1";
|
5183 |
|
5184 |
|
5185 | |
5186 |
|
5187 |
|
5188 |
|
5189 |
|
5190 |
|
5191 |
|
5192 |
|
5193 |
|
5194 |
|
5195 |
|
5196 |
|
5197 |
|
5198 | Axes.TRANSFORM = TRANSFORM;
|
5199 | |
5200 |
|
5201 |
|
5202 |
|
5203 |
|
5204 |
|
5205 | Axes.DIRECTION_NONE = DIRECTION_NONE;
|
5206 | |
5207 |
|
5208 |
|
5209 |
|
5210 |
|
5211 |
|
5212 | Axes.DIRECTION_LEFT = DIRECTION_LEFT;
|
5213 | |
5214 |
|
5215 |
|
5216 |
|
5217 |
|
5218 |
|
5219 | Axes.DIRECTION_RIGHT = DIRECTION_RIGHT;
|
5220 | |
5221 |
|
5222 |
|
5223 |
|
5224 |
|
5225 |
|
5226 | Axes.DIRECTION_UP = DIRECTION_UP;
|
5227 | |
5228 |
|
5229 |
|
5230 |
|
5231 |
|
5232 |
|
5233 | Axes.DIRECTION_DOWN = DIRECTION_DOWN;
|
5234 | |
5235 |
|
5236 |
|
5237 |
|
5238 |
|
5239 |
|
5240 | Axes.DIRECTION_HORIZONTAL = DIRECTION_HORIZONTAL;
|
5241 | |
5242 |
|
5243 |
|
5244 |
|
5245 |
|
5246 |
|
5247 | Axes.DIRECTION_VERTICAL = DIRECTION_VERTICAL;
|
5248 | |
5249 |
|
5250 |
|
5251 |
|
5252 |
|
5253 |
|
5254 | Axes.DIRECTION_ALL = DIRECTION_ALL;
|
5255 | Axes = __decorate([ReactiveSubscribe], Axes);
|
5256 | return Axes;
|
5257 | }(Component);
|
5258 |
|
5259 | |
5260 |
|
5261 |
|
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 |
|
5274 |
|
5275 |
|
5276 |
|
5277 |
|
5278 |
|
5279 |
|
5280 |
|
5281 |
|
5282 |
|
5283 |
|
5284 |
|
5285 |
|
5286 |
|
5287 |
|
5288 |
|
5289 |
|
5290 |
|
5291 |
|
5292 |
|
5293 |
|
5294 |
|
5295 |
|
5296 |
|
5297 |
|
5298 |
|
5299 | |
5300 |
|
5301 |
|
5302 |
|
5303 |
|
5304 |
|
5305 |
|
5306 |
|
5307 |
|
5308 |
|
5309 |
|
5310 |
|
5311 |
|
5312 |
|
5313 |
|
5314 |
|
5315 |
|
5316 |
|
5317 |
|
5318 |
|
5319 |
|
5320 |
|
5321 |
|
5322 |
|
5323 |
|
5324 | var PanInput =
|
5325 |
|
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 |
|
5404 |
|
5405 |
|
5406 |
|
5407 |
|
5408 | __proto.destroy = function () {
|
5409 | this.disconnect();
|
5410 | this.element = null;
|
5411 | };
|
5412 | |
5413 |
|
5414 |
|
5415 |
|
5416 |
|
5417 |
|
5418 |
|
5419 | __proto.enable = function () {
|
5420 | this._enabled = true;
|
5421 | return this;
|
5422 | };
|
5423 | |
5424 |
|
5425 |
|
5426 |
|
5427 |
|
5428 |
|
5429 |
|
5430 | __proto.disable = function () {
|
5431 | this._enabled = false;
|
5432 | return this;
|
5433 | };
|
5434 | |
5435 |
|
5436 |
|
5437 |
|
5438 |
|
5439 |
|
5440 |
|
5441 | __proto.isEnabled = function () {
|
5442 | return this._enabled;
|
5443 | };
|
5444 | |
5445 |
|
5446 |
|
5447 |
|
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 |
|
5519 | this.release();
|
5520 | return;
|
5521 | } else if (this._atRightEdge) {
|
5522 | clearTimeout(this._rightEdgeTimer);
|
5523 |
|
5524 | var swipeRightToLeft = panEvent.deltaX < -iOSEdgeSwipeThreshold;
|
5525 |
|
5526 | if (swipeRightToLeft) {
|
5527 | this._atRightEdge = false;
|
5528 | } else {
|
5529 |
|
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 | });
|
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 |
|
5678 |
|
5679 |
|
5680 |
|
5681 | var Axes$1 = Axes;
|
5682 |
|
5683 | |
5684 |
|
5685 |
|
5686 |
|
5687 | var EVENT = {
|
5688 | HOLD: "hold",
|
5689 | CHANGE: "change",
|
5690 | RELEASE: "release",
|
5691 | ANIMATION_END: "animationEnd",
|
5692 | FINISH: "finish"
|
5693 | };
|
5694 | |
5695 |
|
5696 |
|
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 |
|
5712 |
|
5713 |
|
5714 |
|
5715 |
|
5716 |
|
5717 | var State =
|
5718 |
|
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 |
|
5729 |
|
5730 |
|
5731 |
|
5732 |
|
5733 | get: function () {
|
5734 | return this._delta;
|
5735 | },
|
5736 | enumerable: false,
|
5737 | configurable: true
|
5738 | });
|
5739 | Object.defineProperty(__proto, "targetPanel", {
|
5740 | |
5741 |
|
5742 |
|
5743 |
|
5744 |
|
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 |
|
5757 |
|
5758 |
|
5759 |
|
5760 |
|
5761 |
|
5762 | __proto.onEnter = function (prevState) {
|
5763 | this._delta = prevState._delta;
|
5764 | this._targetPanel = prevState._targetPanel;
|
5765 | };
|
5766 | |
5767 |
|
5768 |
|
5769 |
|
5770 |
|
5771 |
|
5772 |
|
5773 |
|
5774 |
|
5775 |
|
5776 |
|
5777 |
|
5778 | __proto.onHold = function (ctx) {
|
5779 | };
|
5780 | |
5781 |
|
5782 |
|
5783 |
|
5784 |
|
5785 |
|
5786 |
|
5787 |
|
5788 |
|
5789 |
|
5790 |
|
5791 |
|
5792 | __proto.onChange = function (ctx) {
|
5793 | };
|
5794 | |
5795 |
|
5796 |
|
5797 |
|
5798 |
|
5799 |
|
5800 |
|
5801 |
|
5802 |
|
5803 |
|
5804 |
|
5805 |
|
5806 | __proto.onRelease = function (ctx) {
|
5807 | };
|
5808 | |
5809 |
|
5810 |
|
5811 |
|
5812 |
|
5813 |
|
5814 |
|
5815 |
|
5816 |
|
5817 |
|
5818 |
|
5819 |
|
5820 | __proto.onAnimationEnd = function (ctx) {
|
5821 | };
|
5822 | |
5823 |
|
5824 |
|
5825 |
|
5826 |
|
5827 |
|
5828 |
|
5829 |
|
5830 |
|
5831 |
|
5832 |
|
5833 | __proto.onFinish = function (ctx) {
|
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 |
|
5862 | camera.lookAt(prevPosition);
|
5863 | transitTo(STATE_TYPE.DISABLED);
|
5864 | }
|
5865 | };
|
5866 |
|
5867 | return State;
|
5868 | }();
|
5869 |
|
5870 | |
5871 |
|
5872 |
|
5873 |
|
5874 |
|
5875 |
|
5876 | var IdleState =
|
5877 |
|
5878 | function (_super) {
|
5879 | __extends$2(IdleState, _super);
|
5880 |
|
5881 | function IdleState() {
|
5882 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
5883 | |
5884 |
|
5885 |
|
5886 |
|
5887 |
|
5888 |
|
5889 |
|
5890 |
|
5891 | _this.holding = false;
|
5892 | |
5893 |
|
5894 |
|
5895 |
|
5896 |
|
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 |
|
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 | };
|
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 |
|
5952 | transitTo(STATE_TYPE.ANIMATING).onChange(ctx);
|
5953 | }
|
5954 | };
|
5955 |
|
5956 | return IdleState;
|
5957 | }(State);
|
5958 |
|
5959 | |
5960 |
|
5961 |
|
5962 |
|
5963 |
|
5964 |
|
5965 | var HoldingState =
|
5966 |
|
5967 | function (_super) {
|
5968 | __extends$2(HoldingState, _super);
|
5969 |
|
5970 | function HoldingState() {
|
5971 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
5972 | |
5973 |
|
5974 |
|
5975 |
|
5976 |
|
5977 |
|
5978 |
|
5979 |
|
5980 | _this.holding = true;
|
5981 | |
5982 |
|
5983 |
|
5984 |
|
5985 |
|
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 |
|
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 |
|
6027 |
|
6028 |
|
6029 |
|
6030 |
|
6031 | axesEvent.setTo({
|
6032 | flick: flicking.camera.position
|
6033 | }, 0);
|
6034 | transitTo(STATE_TYPE.IDLE);
|
6035 | return;
|
6036 | }
|
6037 |
|
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;
|
6048 |
|
6049 |
|
6050 | transitTo(STATE_TYPE.IDLE);
|
6051 |
|
6052 | if (!this._releaseEvent) {
|
6053 | return;
|
6054 | }
|
6055 |
|
6056 |
|
6057 |
|
6058 | var releaseEvent = this._releaseEvent;
|
6059 |
|
6060 |
|
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 |
|
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 |
|
6106 | direction: getDirection$1(cameraPosition, clickedPanelPosition)
|
6107 | }));
|
6108 | }
|
6109 | };
|
6110 |
|
6111 | return HoldingState;
|
6112 | }(State);
|
6113 |
|
6114 | |
6115 |
|
6116 |
|
6117 |
|
6118 |
|
6119 |
|
6120 | var DraggingState =
|
6121 |
|
6122 | function (_super) {
|
6123 | __extends$2(DraggingState, _super);
|
6124 |
|
6125 | function DraggingState() {
|
6126 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
6127 | |
6128 |
|
6129 |
|
6130 |
|
6131 |
|
6132 |
|
6133 |
|
6134 |
|
6135 | _this.holding = true;
|
6136 | |
6137 |
|
6138 |
|
6139 |
|
6140 |
|
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;
|
6159 |
|
6160 |
|
6161 | flicking.trigger(new ComponentEvent$1(EVENTS.HOLD_END, {
|
6162 | axesEvent: axesEvent
|
6163 | }));
|
6164 |
|
6165 | if (flicking.renderer.panelCount <= 0) {
|
6166 |
|
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 |
|
6189 |
|
6190 |
|
6191 |
|
6192 |
|
6193 | var AnimatingState =
|
6194 |
|
6195 | function (_super) {
|
6196 | __extends$2(AnimatingState, _super);
|
6197 |
|
6198 | function AnimatingState() {
|
6199 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
6200 | |
6201 |
|
6202 |
|
6203 |
|
6204 |
|
6205 |
|
6206 |
|
6207 |
|
6208 | _this.holding = false;
|
6209 | |
6210 |
|
6211 |
|
6212 |
|
6213 |
|
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 |
|
6276 |
|
6277 |
|
6278 |
|
6279 |
|
6280 | var DisabledState =
|
6281 |
|
6282 | function (_super) {
|
6283 | __extends$2(DisabledState, _super);
|
6284 |
|
6285 | function DisabledState() {
|
6286 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
6287 | |
6288 |
|
6289 |
|
6290 |
|
6291 |
|
6292 |
|
6293 |
|
6294 |
|
6295 | _this.holding = false;
|
6296 | |
6297 |
|
6298 |
|
6299 |
|
6300 |
|
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;
|
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;
|
6325 |
|
6326 | if (axesEvent.delta.flick === 0) {
|
6327 | transitTo(STATE_TYPE.IDLE);
|
6328 | }
|
6329 | };
|
6330 |
|
6331 | return DisabledState;
|
6332 | }(State);
|
6333 |
|
6334 | |
6335 |
|
6336 |
|
6337 |
|
6338 | var StateMachine =
|
6339 |
|
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 |
|
6421 |
|
6422 |
|
6423 |
|
6424 |
|
6425 | var AxesController =
|
6426 |
|
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 |
|
6460 |
|
6461 |
|
6462 |
|
6463 |
|
6464 |
|
6465 | get: function () {
|
6466 | return this._axes;
|
6467 | },
|
6468 | enumerable: false,
|
6469 | configurable: true
|
6470 | });
|
6471 | Object.defineProperty(__proto, "stateMachine", {
|
6472 | |
6473 |
|
6474 |
|
6475 | get: function () {
|
6476 | return this._stateMachine;
|
6477 | },
|
6478 | enumerable: false,
|
6479 | configurable: true
|
6480 | });
|
6481 | Object.defineProperty(__proto, "state", {
|
6482 | |
6483 |
|
6484 |
|
6485 |
|
6486 |
|
6487 | get: function () {
|
6488 | return this._stateMachine.state;
|
6489 | },
|
6490 | enumerable: false,
|
6491 | configurable: true
|
6492 | });
|
6493 | Object.defineProperty(__proto, "animatingContext", {
|
6494 | |
6495 |
|
6496 |
|
6497 |
|
6498 |
|
6499 |
|
6500 |
|
6501 |
|
6502 |
|
6503 | get: function () {
|
6504 | return this._animatingContext;
|
6505 | },
|
6506 | enumerable: false,
|
6507 | configurable: true
|
6508 | });
|
6509 | Object.defineProperty(__proto, "controlParams", {
|
6510 | |
6511 |
|
6512 |
|
6513 |
|
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 |
|
6545 |
|
6546 |
|
6547 |
|
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 |
|
6560 |
|
6561 |
|
6562 |
|
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 |
|
6575 |
|
6576 |
|
6577 |
|
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 |
|
6590 |
|
6591 |
|
6592 |
|
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 |
|
6604 |
|
6605 |
|
6606 |
|
6607 |
|
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 |
|
6653 |
|
6654 |
|
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 |
|
6673 |
|
6674 |
|
6675 |
|
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 |
|
6687 |
|
6688 |
|
6689 |
|
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 |
|
6701 |
|
6702 |
|
6703 |
|
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 |
|
6715 |
|
6716 |
|
6717 |
|
6718 |
|
6719 |
|
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 |
|
6739 |
|
6740 |
|
6741 |
|
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 |
|
6753 |
|
6754 |
|
6755 |
|
6756 |
|
6757 |
|
6758 |
|
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 |
|
6777 |
|
6778 |
|
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 |
|
6793 |
|
6794 |
|
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 |
|
6809 |
|
6810 |
|
6811 |
|
6812 |
|
6813 |
|
6814 |
|
6815 |
|
6816 |
|
6817 |
|
6818 |
|
6819 |
|
6820 |
|
6821 |
|
6822 |
|
6823 |
|
6824 |
|
6825 |
|
6826 |
|
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 |
|
6926 |
|
6927 |
|
6928 |
|
6929 | var Control$1 =
|
6930 |
|
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 |
|
6943 |
|
6944 |
|
6945 |
|
6946 |
|
6947 | get: function () {
|
6948 | return this._controller;
|
6949 | },
|
6950 | enumerable: false,
|
6951 | configurable: true
|
6952 | });
|
6953 | Object.defineProperty(__proto, "activeIndex", {
|
6954 | |
6955 |
|
6956 |
|
6957 |
|
6958 |
|
6959 |
|
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 |
|
6972 |
|
6973 |
|
6974 |
|
6975 |
|
6976 | get: function () {
|
6977 | return this._activePanel;
|
6978 | },
|
6979 | enumerable: false,
|
6980 | configurable: true
|
6981 | });
|
6982 | Object.defineProperty(__proto, "animating", {
|
6983 | |
6984 |
|
6985 |
|
6986 |
|
6987 |
|
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 |
|
6998 |
|
6999 |
|
7000 |
|
7001 |
|
7002 | get: function () {
|
7003 | return this._controller.state.holding;
|
7004 | },
|
7005 | enumerable: false,
|
7006 | configurable: true
|
7007 | });
|
7008 | |
7009 |
|
7010 |
|
7011 |
|
7012 |
|
7013 |
|
7014 |
|
7015 |
|
7016 | __proto.init = function (flicking) {
|
7017 | this._flicking = flicking;
|
7018 |
|
7019 | this._controller.init(flicking);
|
7020 |
|
7021 | return this;
|
7022 | };
|
7023 | |
7024 |
|
7025 |
|
7026 |
|
7027 |
|
7028 |
|
7029 |
|
7030 | __proto.destroy = function () {
|
7031 | this._controller.destroy();
|
7032 |
|
7033 | this._flicking = null;
|
7034 | this._activePanel = null;
|
7035 | };
|
7036 | |
7037 |
|
7038 |
|
7039 |
|
7040 |
|
7041 |
|
7042 |
|
7043 |
|
7044 | __proto.enable = function () {
|
7045 | this._controller.enable();
|
7046 |
|
7047 | return this;
|
7048 | };
|
7049 | |
7050 |
|
7051 |
|
7052 |
|
7053 |
|
7054 |
|
7055 |
|
7056 |
|
7057 | __proto.disable = function () {
|
7058 | this._controller.disable();
|
7059 |
|
7060 | return this;
|
7061 | };
|
7062 | |
7063 |
|
7064 |
|
7065 |
|
7066 |
|
7067 |
|
7068 |
|
7069 |
|
7070 | __proto.release = function () {
|
7071 | this._controller.release();
|
7072 |
|
7073 | return this;
|
7074 | };
|
7075 | |
7076 |
|
7077 |
|
7078 |
|
7079 |
|
7080 |
|
7081 |
|
7082 |
|
7083 |
|
7084 |
|
7085 |
|
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 |
|
7102 |
|
7103 |
|
7104 |
|
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 |
|
7118 |
|
7119 |
|
7120 |
|
7121 |
|
7122 |
|
7123 |
|
7124 |
|
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 |
|
7139 |
|
7140 |
|
7141 |
|
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 |
|
7155 |
|
7156 |
|
7157 |
|
7158 |
|
7159 |
|
7160 |
|
7161 | __proto.resetActive = function () {
|
7162 | this._activePanel = null;
|
7163 | return this;
|
7164 | };
|
7165 | |
7166 |
|
7167 |
|
7168 |
|
7169 |
|
7170 |
|
7171 |
|
7172 |
|
7173 |
|
7174 |
|
7175 |
|
7176 |
|
7177 |
|
7178 |
|
7179 |
|
7180 |
|
7181 |
|
7182 |
|
7183 |
|
7184 |
|
7185 |
|
7186 |
|
7187 |
|
7188 |
|
7189 |
|
7190 |
|
7191 |
|
7192 |
|
7193 |
|
7194 |
|
7195 |
|
7196 |
|
7197 |
|
7198 |
|
7199 |
|
7200 |
|
7201 |
|
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 |
|
7219 | , this._animateToPosition({
|
7220 | position: position,
|
7221 | duration: duration,
|
7222 | newActivePanel: panel,
|
7223 | axesEvent: axesEvent
|
7224 | })];
|
7225 | });
|
7226 | });
|
7227 | };
|
7228 | |
7229 |
|
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 |
|
7299 | , animate()];
|
7300 | } else {
|
7301 | return [2
|
7302 |
|
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 |
|
7310 | , flicking.renderer.render()];
|
7311 |
|
7312 | case 1:
|
7313 | _a.sent();
|
7314 |
|
7315 | return [2
|
7316 |
|
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 |
|
7346 | position = nearestAnchor.position;
|
7347 | panel = nearestAnchor.panel;
|
7348 | } else if (flicking.circularEnabled) {
|
7349 |
|
7350 | var camPos_1 = this._controller.position;
|
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 |
|
7374 |
|
7375 |
|
7376 | var AnchorPoint =
|
7377 |
|
7378 | function () {
|
7379 | |
7380 |
|
7381 |
|
7382 |
|
7383 |
|
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 |
|
7398 |
|
7399 |
|
7400 |
|
7401 |
|
7402 | get: function () {
|
7403 | return this._index;
|
7404 | },
|
7405 | enumerable: false,
|
7406 | configurable: true
|
7407 | });
|
7408 | Object.defineProperty(__proto, "position", {
|
7409 | |
7410 |
|
7411 |
|
7412 |
|
7413 |
|
7414 |
|
7415 | get: function () {
|
7416 | return this._pos;
|
7417 | },
|
7418 | enumerable: false,
|
7419 | configurable: true
|
7420 | });
|
7421 | Object.defineProperty(__proto, "panel", {
|
7422 | |
7423 |
|
7424 |
|
7425 |
|
7426 |
|
7427 |
|
7428 | get: function () {
|
7429 | return this._panel;
|
7430 | },
|
7431 | enumerable: false,
|
7432 | configurable: true
|
7433 | });
|
7434 | return AnchorPoint;
|
7435 | }();
|
7436 |
|
7437 | |
7438 |
|
7439 |
|
7440 |
|
7441 |
|
7442 | var SnapControl =
|
7443 |
|
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 |
|
7463 |
|
7464 |
|
7465 |
|
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 |
|
7478 |
|
7479 |
|
7480 |
|
7481 |
|
7482 |
|
7483 |
|
7484 |
|
7485 |
|
7486 |
|
7487 |
|
7488 |
|
7489 |
|
7490 |
|
7491 |
|
7492 |
|
7493 |
|
7494 |
|
7495 |
|
7496 |
|
7497 |
|
7498 |
|
7499 |
|
7500 |
|
7501 |
|
7502 |
|
7503 |
|
7504 |
|
7505 |
|
7506 |
|
7507 |
|
7508 |
|
7509 |
|
7510 |
|
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 |
|
7533 | targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
|
7534 | } else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
|
7535 |
|
7536 | targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
|
7537 | } else {
|
7538 |
|
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;
|
7636 |
|
7637 | |
7638 |
|
7639 |
|
7640 |
|
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 |
|
7651 |
|
7652 |
|
7653 |
|
7654 | var FreeControl =
|
7655 |
|
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 |
|
7675 |
|
7676 |
|
7677 |
|
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 |
|
7690 |
|
7691 |
|
7692 |
|
7693 |
|
7694 |
|
7695 |
|
7696 |
|
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 |
|
7712 |
|
7713 |
|
7714 |
|
7715 |
|
7716 |
|
7717 |
|
7718 |
|
7719 |
|
7720 |
|
7721 |
|
7722 |
|
7723 |
|
7724 |
|
7725 |
|
7726 |
|
7727 |
|
7728 |
|
7729 |
|
7730 |
|
7731 |
|
7732 |
|
7733 |
|
7734 |
|
7735 |
|
7736 |
|
7737 |
|
7738 |
|
7739 |
|
7740 |
|
7741 |
|
7742 |
|
7743 |
|
7744 |
|
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;
|
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 |
|
7777 |
|
7778 |
|
7779 |
|
7780 | var StrictControl =
|
7781 |
|
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 |
|
7810 |
|
7811 |
|
7812 |
|
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 |
|
7825 |
|
7826 |
|
7827 |
|
7828 |
|
7829 | __proto.destroy = function () {
|
7830 | _super.prototype.destroy.call(this);
|
7831 |
|
7832 | this._resetIndexRange();
|
7833 | };
|
7834 | |
7835 |
|
7836 |
|
7837 |
|
7838 |
|
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 |
|
7923 | , _super.prototype.moveToPanel.call(this, panel, options)];
|
7924 | });
|
7925 | });
|
7926 | };
|
7927 | |
7928 |
|
7929 |
|
7930 |
|
7931 |
|
7932 |
|
7933 |
|
7934 |
|
7935 |
|
7936 |
|
7937 |
|
7938 |
|
7939 |
|
7940 |
|
7941 |
|
7942 |
|
7943 |
|
7944 |
|
7945 |
|
7946 |
|
7947 |
|
7948 |
|
7949 |
|
7950 |
|
7951 |
|
7952 |
|
7953 |
|
7954 |
|
7955 |
|
7956 |
|
7957 |
|
7958 |
|
7959 |
|
7960 |
|
7961 |
|
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 |
|
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 |
|
8000 | targetPanel = anchorAtPosition.panel;
|
8001 | targetPos = anchorAtPosition.position;
|
8002 | } else if (isOverThreshold && isAdjacent) {
|
8003 |
|
8004 | targetPanel = adjacentAnchor.panel;
|
8005 | targetPos = adjacentAnchor.position;
|
8006 | } else {
|
8007 |
|
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 |
|
8034 |
|
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 |
|
8055 |
|
8056 |
|
8057 | var CameraMode =
|
8058 |
|
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 |
|
8100 | return anchors[anchorIdx - 1];
|
8101 | }
|
8102 |
|
8103 | prevDist = dist;
|
8104 | }
|
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;
|
8131 |
|
8132 | return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
|
8133 | };
|
8134 |
|
8135 | return CameraMode;
|
8136 | }();
|
8137 |
|
8138 | var LinearCameraMode =
|
8139 |
|
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 |
|
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 |
|
8171 |
|
8172 |
|
8173 |
|
8174 | var CircularCameraMode =
|
8175 |
|
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 | }
|
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 |
|
8328 | return position;
|
8329 | };
|
8330 |
|
8331 | __proto.canReach = function (panel) {
|
8332 | if (panel.removed) return false;
|
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);
|
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 |
|
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 |
|
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 |
|
8522 | return panels[panelIdx - 1];
|
8523 | }
|
8524 |
|
8525 | prevDist = dist;
|
8526 | }
|
8527 |
|
8528 |
|
8529 | return panels[panels.length - 1];
|
8530 | };
|
8531 |
|
8532 | return BoundCameraMode;
|
8533 | }(CameraMode);
|
8534 |
|
8535 | |
8536 |
|
8537 |
|
8538 |
|
8539 |
|
8540 | var Camera$1 =
|
8541 |
|
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();
|
8587 |
|
8588 |
|
8589 | this._align = align;
|
8590 | }
|
8591 |
|
8592 | var __proto = Camera.prototype;
|
8593 | Object.defineProperty(__proto, "element", {
|
8594 |
|
8595 |
|
8596 | |
8597 |
|
8598 |
|
8599 |
|
8600 |
|
8601 |
|
8602 | get: function () {
|
8603 | return this._el;
|
8604 | },
|
8605 | enumerable: false,
|
8606 | configurable: true
|
8607 | });
|
8608 | Object.defineProperty(__proto, "children", {
|
8609 | |
8610 |
|
8611 |
|
8612 |
|
8613 |
|
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 |
|
8624 |
|
8625 |
|
8626 |
|
8627 |
|
8628 | get: function () {
|
8629 | return this._position;
|
8630 | },
|
8631 | enumerable: false,
|
8632 | configurable: true
|
8633 | });
|
8634 | Object.defineProperty(__proto, "alignPosition", {
|
8635 | |
8636 |
|
8637 |
|
8638 |
|
8639 |
|
8640 |
|
8641 | get: function () {
|
8642 | return this._alignPos;
|
8643 | },
|
8644 | enumerable: false,
|
8645 | configurable: true
|
8646 | });
|
8647 | Object.defineProperty(__proto, "offset", {
|
8648 | |
8649 |
|
8650 |
|
8651 |
|
8652 |
|
8653 |
|
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 |
|
8664 |
|
8665 |
|
8666 |
|
8667 |
|
8668 |
|
8669 |
|
8670 |
|
8671 | get: function () {
|
8672 | return this._circularEnabled;
|
8673 | },
|
8674 | enumerable: false,
|
8675 | configurable: true
|
8676 | });
|
8677 | Object.defineProperty(__proto, "mode", {
|
8678 | |
8679 |
|
8680 |
|
8681 |
|
8682 |
|
8683 | get: function () {
|
8684 | return this._mode;
|
8685 | },
|
8686 | enumerable: false,
|
8687 | configurable: true
|
8688 | });
|
8689 | Object.defineProperty(__proto, "range", {
|
8690 | |
8691 |
|
8692 |
|
8693 |
|
8694 |
|
8695 |
|
8696 |
|
8697 |
|
8698 | get: function () {
|
8699 | return this._range;
|
8700 | },
|
8701 | enumerable: false,
|
8702 | configurable: true
|
8703 | });
|
8704 | Object.defineProperty(__proto, "rangeDiff", {
|
8705 | |
8706 |
|
8707 |
|
8708 |
|
8709 |
|
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 |
|
8720 |
|
8721 |
|
8722 |
|
8723 |
|
8724 | get: function () {
|
8725 | return this._visiblePanels;
|
8726 | },
|
8727 | enumerable: false,
|
8728 | configurable: true
|
8729 | });
|
8730 | Object.defineProperty(__proto, "visibleRange", {
|
8731 | |
8732 |
|
8733 |
|
8734 |
|
8735 |
|
8736 |
|
8737 |
|
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 |
|
8751 |
|
8752 |
|
8753 |
|
8754 |
|
8755 | get: function () {
|
8756 | return this._anchors;
|
8757 | },
|
8758 | enumerable: false,
|
8759 | configurable: true
|
8760 | });
|
8761 | Object.defineProperty(__proto, "controlParams", {
|
8762 | |
8763 |
|
8764 |
|
8765 |
|
8766 |
|
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 |
|
8781 |
|
8782 |
|
8783 |
|
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 |
|
8794 |
|
8795 |
|
8796 |
|
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 |
|
8808 |
|
8809 |
|
8810 |
|
8811 |
|
8812 |
|
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];
|
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];
|
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 |
|
8860 |
|
8861 | |
8862 |
|
8863 |
|
8864 |
|
8865 |
|
8866 | get: function () {
|
8867 | return this._align;
|
8868 | },
|
8869 |
|
8870 | set: function (val) {
|
8871 | this._align = val;
|
8872 | },
|
8873 | enumerable: false,
|
8874 | configurable: true
|
8875 | });
|
8876 | |
8877 |
|
8878 |
|
8879 |
|
8880 |
|
8881 |
|
8882 |
|
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 |
|
8898 |
|
8899 |
|
8900 |
|
8901 |
|
8902 |
|
8903 | __proto.destroy = function () {
|
8904 | this._resetInternalValues();
|
8905 |
|
8906 | return this;
|
8907 | };
|
8908 | |
8909 |
|
8910 |
|
8911 |
|
8912 |
|
8913 |
|
8914 |
|
8915 |
|
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 |
|
8944 |
|
8945 |
|
8946 |
|
8947 |
|
8948 |
|
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 |
|
8968 |
|
8969 |
|
8970 |
|
8971 |
|
8972 |
|
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 |
|
8993 |
|
8994 |
|
8995 |
|
8996 |
|
8997 |
|
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 |
|
9007 |
|
9008 |
|
9009 |
|
9010 |
|
9011 |
|
9012 |
|
9013 |
|
9014 |
|
9015 | __proto.findAnchorIncludePosition = function (position) {
|
9016 | return this._mode.findAnchorIncludePosition(position);
|
9017 | };
|
9018 | |
9019 |
|
9020 |
|
9021 |
|
9022 |
|
9023 |
|
9024 |
|
9025 |
|
9026 |
|
9027 |
|
9028 | __proto.findNearestAnchor = function (position) {
|
9029 | return this._mode.findNearestAnchor(position);
|
9030 | };
|
9031 | |
9032 |
|
9033 |
|
9034 |
|
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 |
|
9047 |
|
9048 |
|
9049 |
|
9050 |
|
9051 |
|
9052 |
|
9053 | __proto.clampToReachablePosition = function (position) {
|
9054 | return this._mode.clampToReachablePosition(position);
|
9055 | };
|
9056 | |
9057 |
|
9058 |
|
9059 |
|
9060 |
|
9061 |
|
9062 |
|
9063 |
|
9064 | __proto.canReach = function (panel) {
|
9065 | return this._mode.canReach(panel);
|
9066 | };
|
9067 | |
9068 |
|
9069 |
|
9070 |
|
9071 |
|
9072 |
|
9073 |
|
9074 |
|
9075 | __proto.canSee = function (panel) {
|
9076 | return this._mode.canSee(panel);
|
9077 | };
|
9078 | |
9079 |
|
9080 |
|
9081 |
|
9082 |
|
9083 |
|
9084 |
|
9085 |
|
9086 |
|
9087 |
|
9088 |
|
9089 |
|
9090 |
|
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 |
|
9113 |
|
9114 |
|
9115 |
|
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 |
|
9127 |
|
9128 |
|
9129 |
|
9130 |
|
9131 |
|
9132 |
|
9133 |
|
9134 |
|
9135 |
|
9136 | __proto.updateAnchors = function () {
|
9137 | this._anchors = this._mode.getAnchors();
|
9138 | return this;
|
9139 | };
|
9140 | |
9141 |
|
9142 |
|
9143 |
|
9144 |
|
9145 |
|
9146 |
|
9147 |
|
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 |
|
9161 |
|
9162 |
|
9163 |
|
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 |
|
9184 |
|
9185 |
|
9186 |
|
9187 |
|
9188 |
|
9189 |
|
9190 | __proto.resetNeedPanelHistory = function () {
|
9191 | this._needPanelTriggered = {
|
9192 | prev: false,
|
9193 | next: false
|
9194 | };
|
9195 | return this;
|
9196 | };
|
9197 | |
9198 |
|
9199 |
|
9200 |
|
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 |
|
9365 |
|
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 |
|
9378 |
|
9379 |
|
9380 |
|
9381 |
|
9382 |
|
9383 |
|
9384 |
|
9385 | |
9386 |
|
9387 |
|
9388 |
|
9389 |
|
9390 |
|
9391 |
|
9392 |
|
9393 |
|
9394 |
|
9395 |
|
9396 |
|
9397 |
|
9398 |
|
9399 |
|
9400 |
|
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 |
|
9445 |
|
9446 |
|
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 |
|
9527 |
|
9528 |
|
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 |
|
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 |
|
9603 | return;
|
9604 | }
|
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 |
|
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 |
|
9638 | this.onAlreadyPreReady();
|
9639 | }
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
9791 | _super.prototype.onAlreadyPreReady.call(this);
|
9792 |
|
9793 | this.trigger("reqeustReadyChildren");
|
9794 | };
|
9795 |
|
9796 | ElementLoader.EVENTS = [];
|
9797 | return ElementLoader;
|
9798 | }(Loader);
|
9799 |
|
9800 | |
9801 |
|
9802 |
|
9803 |
|
9804 |
|
9805 | var ImReadyManager =
|
9806 |
|
9807 | function (_super) {
|
9808 | __extends(ImReadyManager, _super);
|
9809 | |
9810 |
|
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 |
|
9835 |
|
9836 |
|
9837 |
|
9838 |
|
9839 |
|
9840 |
|
9841 |
|
9842 |
|
9843 |
|
9844 |
|
9845 |
|
9846 |
|
9847 |
|
9848 |
|
9849 |
|
9850 |
|
9851 |
|
9852 |
|
9853 |
|
9854 |
|
9855 |
|
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);
|
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 |
|
9932 |
|
9933 |
|
9934 |
|
9935 |
|
9936 | __proto.getTotalCount = function () {
|
9937 | return this.totalCount;
|
9938 | };
|
9939 | |
9940 |
|
9941 |
|
9942 |
|
9943 |
|
9944 |
|
9945 | __proto.isPreReady = function () {
|
9946 | return this.elementInfos.every(function (info) {
|
9947 | return info.isPreReady;
|
9948 | });
|
9949 | };
|
9950 | |
9951 |
|
9952 |
|
9953 |
|
9954 |
|
9955 |
|
9956 | __proto.isReady = function () {
|
9957 | return this.elementInfos.every(function (info) {
|
9958 | return info.isReady;
|
9959 | });
|
9960 | };
|
9961 | |
9962 |
|
9963 |
|
9964 |
|
9965 |
|
9966 |
|
9967 | __proto.hasError = function () {
|
9968 | return this.totalErrorCount > 0;
|
9969 | };
|
9970 | |
9971 |
|
9972 |
|
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 |
|
9991 |
|
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 |
|
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 |
|
10035 |
|
10036 |
|
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 |
|
10075 |
|
10076 |
|
10077 |
|
10078 |
|
10079 |
|
10080 |
|
10081 |
|
10082 |
|
10083 |
|
10084 |
|
10085 |
|
10086 |
|
10087 |
|
10088 |
|
10089 |
|
10090 |
|
10091 |
|
10092 |
|
10093 |
|
10094 |
|
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 |
|
10113 |
|
10114 |
|
10115 |
|
10116 |
|
10117 |
|
10118 |
|
10119 |
|
10120 |
|
10121 |
|
10122 |
|
10123 |
|
10124 |
|
10125 |
|
10126 |
|
10127 |
|
10128 |
|
10129 |
|
10130 |
|
10131 |
|
10132 |
|
10133 |
|
10134 |
|
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 |
|
10157 |
|
10158 |
|
10159 |
|
10160 |
|
10161 |
|
10162 |
|
10163 |
|
10164 |
|
10165 |
|
10166 |
|
10167 |
|
10168 |
|
10169 |
|
10170 |
|
10171 |
|
10172 |
|
10173 |
|
10174 |
|
10175 |
|
10176 |
|
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 |
|
10194 |
|
10195 |
|
10196 |
|
10197 |
|
10198 |
|
10199 |
|
10200 |
|
10201 |
|
10202 |
|
10203 |
|
10204 |
|
10205 |
|
10206 |
|
10207 |
|
10208 |
|
10209 |
|
10210 |
|
10211 |
|
10212 |
|
10213 |
|
10214 |
|
10215 |
|
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 |
|
10241 |
|
10242 |
|
10243 |
|
10244 |
|
10245 |
|
10246 |
|
10247 |
|
10248 |
|
10249 |
|
10250 |
|
10251 |
|
10252 |
|
10253 |
|
10254 |
|
10255 |
|
10256 |
|
10257 |
|
10258 |
|
10259 |
|
10260 |
|
10261 |
|
10262 |
|
10263 |
|
10264 |
|
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 |
|
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 |
|
10309 | if (!element.naturalWidth) {
|
10310 | this.onAlreadyError(element);
|
10311 | }
|
10312 |
|
10313 | return false;
|
10314 | } else {
|
10315 |
|
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 |
|
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;
|
10342 |
|
10343 |
|
10344 |
|
10345 |
|
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 |
|
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 |
|
10387 |
|
10388 |
|
10389 |
|
10390 |
|
10391 | var ImReady$1 = ImReady;
|
10392 |
|
10393 | |
10394 |
|
10395 |
|
10396 |
|
10397 |
|
10398 | var Renderer$1 =
|
10399 |
|
10400 | function () {
|
10401 | |
10402 |
|
10403 |
|
10404 |
|
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;
|
10413 |
|
10414 | this._align = align;
|
10415 | this._strategy = strategy;
|
10416 | }
|
10417 |
|
10418 | var __proto = Renderer.prototype;
|
10419 | Object.defineProperty(__proto, "panels", {
|
10420 |
|
10421 |
|
10422 | |
10423 |
|
10424 |
|
10425 |
|
10426 |
|
10427 |
|
10428 |
|
10429 | get: function () {
|
10430 | return this._panels;
|
10431 | },
|
10432 | enumerable: false,
|
10433 | configurable: true
|
10434 | });
|
10435 | Object.defineProperty(__proto, "rendering", {
|
10436 | |
10437 |
|
10438 |
|
10439 |
|
10440 |
|
10441 |
|
10442 |
|
10443 | get: function () {
|
10444 | return this._rendering;
|
10445 | },
|
10446 | enumerable: false,
|
10447 | configurable: true
|
10448 | });
|
10449 | Object.defineProperty(__proto, "panelCount", {
|
10450 | |
10451 |
|
10452 |
|
10453 |
|
10454 |
|
10455 |
|
10456 | get: function () {
|
10457 | return this._panels.length;
|
10458 | },
|
10459 | enumerable: false,
|
10460 | configurable: true
|
10461 | });
|
10462 | Object.defineProperty(__proto, "strategy", {
|
10463 | |
10464 |
|
10465 |
|
10466 | get: function () {
|
10467 | return this._strategy;
|
10468 | },
|
10469 | enumerable: false,
|
10470 | configurable: true
|
10471 | });
|
10472 | Object.defineProperty(__proto, "align", {
|
10473 |
|
10474 |
|
10475 | |
10476 |
|
10477 |
|
10478 |
|
10479 |
|
10480 | get: function () {
|
10481 | return this._align;
|
10482 | },
|
10483 |
|
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 |
|
10497 |
|
10498 |
|
10499 |
|
10500 |
|
10501 |
|
10502 |
|
10503 | __proto.init = function (flicking) {
|
10504 | this._flicking = flicking;
|
10505 |
|
10506 | this._collectPanels();
|
10507 |
|
10508 | return this;
|
10509 | };
|
10510 | |
10511 |
|
10512 |
|
10513 |
|
10514 |
|
10515 |
|
10516 |
|
10517 | __proto.destroy = function () {
|
10518 | this._flicking = null;
|
10519 | this._panels = [];
|
10520 | };
|
10521 | |
10522 |
|
10523 |
|
10524 |
|
10525 |
|
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 |
|
10542 |
|
10543 |
|
10544 |
|
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 |
|
10568 |
|
10569 |
|
10570 |
|
10571 |
|
10572 |
|
10573 |
|
10574 |
|
10575 |
|
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 |
|
10593 |
|
10594 |
|
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 |
|
10627 | _this._insertPanelElements(panelsInserted, (_a = panelsPushed[0]) !== null && _a !== void 0 ? _a : null);
|
10628 | }
|
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 | }
|
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 |
|
10652 |
|
10653 |
|
10654 |
|
10655 |
|
10656 |
|
10657 |
|
10658 |
|
10659 |
|
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 |
|
10677 |
|
10678 |
|
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 [];
|
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 | }
|
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 |
|
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;
|
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 |
|
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 |
|
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 |
|
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 |
|
10875 |
|
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;
|
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 |
|
10957 | function (_super) {
|
10958 | __extends$2(VanillaRenderer, _super);
|
10959 |
|
10960 | function VanillaRenderer() {
|
10961 | return _super !== null && _super.apply(this, arguments) || this;
|
10962 | }
|
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 |
|
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;
|
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;
|
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 |
|
11029 |
|
11030 |
|
11031 | var ExternalRenderer =
|
11032 |
|
11033 | function (_super) {
|
11034 | __extends$2(ExternalRenderer, _super);
|
11035 |
|
11036 | function ExternalRenderer() {
|
11037 | return _super !== null && _super.apply(this, arguments) || this;
|
11038 | }
|
11039 |
|
11040 |
|
11041 |
|
11042 | var __proto = ExternalRenderer.prototype;
|
11043 |
|
11044 | __proto._removePanelElements = function (panels) {
|
11045 | };
|
11046 |
|
11047 | __proto._removeAllChildsFromCamera = function () {
|
11048 | };
|
11049 |
|
11050 | return ExternalRenderer;
|
11051 | }(Renderer$1);
|
11052 |
|
11053 | |
11054 |
|
11055 |
|
11056 |
|
11057 |
|
11058 | var Panel =
|
11059 |
|
11060 | function () {
|
11061 | |
11062 |
|
11063 |
|
11064 |
|
11065 |
|
11066 |
|
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 |
|
11087 |
|
11088 | |
11089 |
|
11090 |
|
11091 |
|
11092 |
|
11093 |
|
11094 | get: function () {
|
11095 | return this._elProvider.element;
|
11096 | },
|
11097 | enumerable: false,
|
11098 | configurable: true
|
11099 | });
|
11100 | Object.defineProperty(__proto, "elementProvider", {
|
11101 | |
11102 |
|
11103 |
|
11104 |
|
11105 | get: function () {
|
11106 | return this._elProvider;
|
11107 | },
|
11108 | enumerable: false,
|
11109 | configurable: true
|
11110 | });
|
11111 | Object.defineProperty(__proto, "index", {
|
11112 | |
11113 |
|
11114 |
|
11115 |
|
11116 |
|
11117 |
|
11118 | get: function () {
|
11119 | return this._index;
|
11120 | },
|
11121 | enumerable: false,
|
11122 | configurable: true
|
11123 | });
|
11124 | Object.defineProperty(__proto, "position", {
|
11125 | |
11126 |
|
11127 |
|
11128 |
|
11129 |
|
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 |
|
11140 |
|
11141 |
|
11142 |
|
11143 |
|
11144 |
|
11145 |
|
11146 | get: function () {
|
11147 | return this._size;
|
11148 | },
|
11149 | enumerable: false,
|
11150 | configurable: true
|
11151 | });
|
11152 | Object.defineProperty(__proto, "sizeIncludingMargin", {
|
11153 | |
11154 |
|
11155 |
|
11156 |
|
11157 |
|
11158 |
|
11159 |
|
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 |
|
11170 |
|
11171 |
|
11172 |
|
11173 |
|
11174 | get: function () {
|
11175 | return this._height;
|
11176 | },
|
11177 | enumerable: false,
|
11178 | configurable: true
|
11179 | });
|
11180 | Object.defineProperty(__proto, "margin", {
|
11181 | |
11182 |
|
11183 |
|
11184 |
|
11185 |
|
11186 |
|
11187 |
|
11188 |
|
11189 |
|
11190 |
|
11191 | get: function () {
|
11192 | return this._margin;
|
11193 | },
|
11194 | enumerable: false,
|
11195 | configurable: true
|
11196 | });
|
11197 | Object.defineProperty(__proto, "alignPosition", {
|
11198 | |
11199 |
|
11200 |
|
11201 |
|
11202 |
|
11203 |
|
11204 | get: function () {
|
11205 | return this._alignPos;
|
11206 | },
|
11207 | enumerable: false,
|
11208 | configurable: true
|
11209 | });
|
11210 | Object.defineProperty(__proto, "removed", {
|
11211 | |
11212 |
|
11213 |
|
11214 |
|
11215 |
|
11216 |
|
11217 | get: function () {
|
11218 | return this._removed;
|
11219 | },
|
11220 | enumerable: false,
|
11221 | configurable: true
|
11222 | });
|
11223 | Object.defineProperty(__proto, "rendered", {
|
11224 | |
11225 |
|
11226 |
|
11227 |
|
11228 |
|
11229 |
|
11230 | get: function () {
|
11231 | return this._rendered;
|
11232 | },
|
11233 | enumerable: false,
|
11234 | configurable: true
|
11235 | });
|
11236 | Object.defineProperty(__proto, "loading", {
|
11237 | |
11238 |
|
11239 |
|
11240 |
|
11241 |
|
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 |
|
11255 |
|
11256 |
|
11257 |
|
11258 |
|
11259 |
|
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 |
|
11273 |
|
11274 |
|
11275 |
|
11276 |
|
11277 | get: function () {
|
11278 | return this._toggled;
|
11279 | },
|
11280 | enumerable: false,
|
11281 | configurable: true
|
11282 | });
|
11283 | Object.defineProperty(__proto, "toggleDirection", {
|
11284 | |
11285 |
|
11286 |
|
11287 |
|
11288 |
|
11289 |
|
11290 | get: function () {
|
11291 | return this._toggleDirection;
|
11292 | },
|
11293 | enumerable: false,
|
11294 | configurable: true
|
11295 | });
|
11296 | Object.defineProperty(__proto, "offset", {
|
11297 | |
11298 |
|
11299 |
|
11300 |
|
11301 |
|
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 |
|
11314 |
|
11315 |
|
11316 |
|
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 |
|
11328 |
|
11329 |
|
11330 |
|
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 |
|
11356 |
|
11357 |
|
11358 |
|
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 |
|
11391 |
|
11392 | |
11393 |
|
11394 |
|
11395 |
|
11396 |
|
11397 | get: function () {
|
11398 | return this._align;
|
11399 | },
|
11400 |
|
11401 | set: function (val) {
|
11402 | this._align = val;
|
11403 | },
|
11404 | enumerable: false,
|
11405 | configurable: true
|
11406 | });
|
11407 | |
11408 |
|
11409 |
|
11410 |
|
11411 |
|
11412 | __proto.markForShow = function () {
|
11413 | this._rendered = true;
|
11414 |
|
11415 | this._elProvider.show(this._flicking);
|
11416 | };
|
11417 | |
11418 |
|
11419 |
|
11420 |
|
11421 |
|
11422 |
|
11423 | __proto.markForHide = function () {
|
11424 | this._rendered = false;
|
11425 |
|
11426 | this._elProvider.hide(this._flicking);
|
11427 | };
|
11428 | |
11429 |
|
11430 |
|
11431 |
|
11432 |
|
11433 |
|
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 |
|
11488 |
|
11489 |
|
11490 |
|
11491 |
|
11492 |
|
11493 |
|
11494 |
|
11495 |
|
11496 |
|
11497 | __proto.setSize = function (size) {
|
11498 | setSize(this.element, size);
|
11499 | return this;
|
11500 | };
|
11501 | |
11502 |
|
11503 |
|
11504 |
|
11505 |
|
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 |
|
11516 |
|
11517 |
|
11518 |
|
11519 |
|
11520 |
|
11521 | __proto.destroy = function () {
|
11522 | this._resetInternalStates();
|
11523 |
|
11524 | this._removed = true;
|
11525 | };
|
11526 | |
11527 |
|
11528 |
|
11529 |
|
11530 |
|
11531 |
|
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 |
|
11544 |
|
11545 |
|
11546 |
|
11547 |
|
11548 |
|
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 |
|
11569 |
|
11570 |
|
11571 |
|
11572 |
|
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 |
|
11582 |
|
11583 |
|
11584 |
|
11585 |
|
11586 |
|
11587 |
|
11588 | __proto.focus = function (duration) {
|
11589 | return this._flicking.moveTo(this._index, duration);
|
11590 | };
|
11591 | |
11592 |
|
11593 |
|
11594 |
|
11595 |
|
11596 |
|
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 |
|
11610 |
|
11611 |
|
11612 |
|
11613 |
|
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 |
|
11627 |
|
11628 |
|
11629 |
|
11630 |
|
11631 |
|
11632 |
|
11633 |
|
11634 |
|
11635 | __proto.increaseIndex = function (val) {
|
11636 | this._index += Math.max(val, 0);
|
11637 | return this;
|
11638 | };
|
11639 | |
11640 |
|
11641 |
|
11642 |
|
11643 |
|
11644 |
|
11645 |
|
11646 |
|
11647 |
|
11648 |
|
11649 | __proto.decreaseIndex = function (val) {
|
11650 | this._index -= Math.max(val, 0);
|
11651 | return this;
|
11652 | };
|
11653 | |
11654 |
|
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 |
|
11665 |
|
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 |
|
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 |
|
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 () {
|
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 |
|
11835 |
|
11836 | panel.markForHide();
|
11837 | }
|
11838 | });
|
11839 | camera.updateOffset();
|
11840 | };
|
11841 |
|
11842 | return NormalRenderingStrategy;
|
11843 | }();
|
11844 |
|
11845 | |
11846 |
|
11847 |
|
11848 |
|
11849 |
|
11850 | var VirtualPanel =
|
11851 |
|
11852 | function (_super) {
|
11853 | __extends$2(VirtualPanel, _super);
|
11854 | |
11855 |
|
11856 |
|
11857 |
|
11858 |
|
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 |
|
11875 |
|
11876 |
|
11877 |
|
11878 |
|
11879 | get: function () {
|
11880 | return this._elProvider.element;
|
11881 | },
|
11882 | enumerable: false,
|
11883 | configurable: true
|
11884 | });
|
11885 | Object.defineProperty(__proto, "cachedInnerHTML", {
|
11886 | |
11887 |
|
11888 |
|
11889 |
|
11890 |
|
11891 |
|
11892 | get: function () {
|
11893 | return this._cachedInnerHTML;
|
11894 | },
|
11895 | enumerable: false,
|
11896 | configurable: true
|
11897 | });
|
11898 | Object.defineProperty(__proto, "elementIndex", {
|
11899 | |
11900 |
|
11901 |
|
11902 |
|
11903 |
|
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 |
|
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 |
|
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 |
|
12066 |
|
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 |
|
12080 |
|
12081 |
|
12082 |
|
12083 |
|
12084 |
|
12085 | var Flicking =
|
12086 |
|
12087 | function (_super) {
|
12088 | __extends$2(Flicking, _super);
|
12089 | |
12090 |
|
12091 |
|
12092 |
|
12093 |
|
12094 |
|
12095 |
|
12096 |
|
12097 |
|
12098 |
|
12099 |
|
12100 |
|
12101 |
|
12102 |
|
12103 |
|
12104 |
|
12105 |
|
12106 |
|
12107 |
|
12108 |
|
12109 |
|
12110 |
|
12111 |
|
12112 |
|
12113 |
|
12114 |
|
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;
|
12195 |
|
12196 |
|
12197 | _this._initialized = false;
|
12198 | _this._plugins = [];
|
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;
|
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 |
|
12253 |
|
12254 | |
12255 |
|
12256 |
|
12257 |
|
12258 |
|
12259 |
|
12260 |
|
12261 |
|
12262 |
|
12263 |
|
12264 | get: function () {
|
12265 | return this._control;
|
12266 | },
|
12267 | enumerable: false,
|
12268 | configurable: true
|
12269 | });
|
12270 | Object.defineProperty(__proto, "camera", {
|
12271 | |
12272 |
|
12273 |
|
12274 |
|
12275 |
|
12276 |
|
12277 |
|
12278 |
|
12279 |
|
12280 |
|
12281 |
|
12282 | get: function () {
|
12283 | return this._camera;
|
12284 | },
|
12285 | enumerable: false,
|
12286 | configurable: true
|
12287 | });
|
12288 | Object.defineProperty(__proto, "renderer", {
|
12289 | |
12290 |
|
12291 |
|
12292 |
|
12293 |
|
12294 |
|
12295 |
|
12296 |
|
12297 |
|
12298 |
|
12299 | get: function () {
|
12300 | return this._renderer;
|
12301 | },
|
12302 | enumerable: false,
|
12303 | configurable: true
|
12304 | });
|
12305 | Object.defineProperty(__proto, "viewport", {
|
12306 | |
12307 |
|
12308 |
|
12309 |
|
12310 |
|
12311 |
|
12312 |
|
12313 | get: function () {
|
12314 | return this._viewport;
|
12315 | },
|
12316 | enumerable: false,
|
12317 | configurable: true
|
12318 | });
|
12319 | Object.defineProperty(__proto, "initialized", {
|
12320 |
|
12321 |
|
12322 | |
12323 |
|
12324 |
|
12325 |
|
12326 |
|
12327 |
|
12328 |
|
12329 |
|
12330 |
|
12331 | get: function () {
|
12332 | return this._initialized;
|
12333 | },
|
12334 | enumerable: false,
|
12335 | configurable: true
|
12336 | });
|
12337 | Object.defineProperty(__proto, "circularEnabled", {
|
12338 | |
12339 |
|
12340 |
|
12341 |
|
12342 |
|
12343 |
|
12344 |
|
12345 |
|
12346 |
|
12347 | get: function () {
|
12348 | return this._camera.circularEnabled;
|
12349 | },
|
12350 | enumerable: false,
|
12351 | configurable: true
|
12352 | });
|
12353 | Object.defineProperty(__proto, "virtualEnabled", {
|
12354 | |
12355 |
|
12356 |
|
12357 |
|
12358 |
|
12359 |
|
12360 |
|
12361 |
|
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 |
|
12372 |
|
12373 |
|
12374 |
|
12375 |
|
12376 |
|
12377 | get: function () {
|
12378 | return this._control.activeIndex;
|
12379 | },
|
12380 | enumerable: false,
|
12381 | configurable: true
|
12382 | });
|
12383 | Object.defineProperty(__proto, "element", {
|
12384 | |
12385 |
|
12386 |
|
12387 |
|
12388 |
|
12389 |
|
12390 | get: function () {
|
12391 | return this._viewport.element;
|
12392 | },
|
12393 | enumerable: false,
|
12394 | configurable: true
|
12395 | });
|
12396 | Object.defineProperty(__proto, "currentPanel", {
|
12397 | |
12398 |
|
12399 |
|
12400 |
|
12401 |
|
12402 |
|
12403 |
|
12404 | get: function () {
|
12405 | return this._control.activePanel;
|
12406 | },
|
12407 | enumerable: false,
|
12408 | configurable: true
|
12409 | });
|
12410 | Object.defineProperty(__proto, "panels", {
|
12411 | |
12412 |
|
12413 |
|
12414 |
|
12415 |
|
12416 |
|
12417 |
|
12418 | get: function () {
|
12419 | return this._renderer.panels;
|
12420 | },
|
12421 | enumerable: false,
|
12422 | configurable: true
|
12423 | });
|
12424 | Object.defineProperty(__proto, "panelCount", {
|
12425 | |
12426 |
|
12427 |
|
12428 |
|
12429 |
|
12430 |
|
12431 | get: function () {
|
12432 | return this._renderer.panelCount;
|
12433 | },
|
12434 | enumerable: false,
|
12435 | configurable: true
|
12436 | });
|
12437 | Object.defineProperty(__proto, "visiblePanels", {
|
12438 | |
12439 |
|
12440 |
|
12441 |
|
12442 |
|
12443 |
|
12444 |
|
12445 | get: function () {
|
12446 | return this._camera.visiblePanels;
|
12447 | },
|
12448 | enumerable: false,
|
12449 | configurable: true
|
12450 | });
|
12451 | Object.defineProperty(__proto, "animating", {
|
12452 | |
12453 |
|
12454 |
|
12455 |
|
12456 |
|
12457 |
|
12458 | get: function () {
|
12459 | return this._control.animating;
|
12460 | },
|
12461 | enumerable: false,
|
12462 | configurable: true
|
12463 | });
|
12464 | Object.defineProperty(__proto, "holding", {
|
12465 | |
12466 |
|
12467 |
|
12468 |
|
12469 |
|
12470 |
|
12471 | get: function () {
|
12472 | return this._control.holding;
|
12473 | },
|
12474 | enumerable: false,
|
12475 | configurable: true
|
12476 | });
|
12477 | Object.defineProperty(__proto, "activePlugins", {
|
12478 | |
12479 |
|
12480 |
|
12481 |
|
12482 |
|
12483 |
|
12484 | get: function () {
|
12485 | return this._plugins;
|
12486 | },
|
12487 | enumerable: false,
|
12488 | configurable: true
|
12489 | });
|
12490 | Object.defineProperty(__proto, "align", {
|
12491 |
|
12492 |
|
12493 |
|
12494 | |
12495 |
|
12496 |
|
12497 |
|
12498 |
|
12499 |
|
12500 |
|
12501 |
|
12502 |
|
12503 |
|
12504 |
|
12505 |
|
12506 |
|
12507 |
|
12508 |
|
12509 |
|
12510 |
|
12511 |
|
12512 |
|
12513 |
|
12514 |
|
12515 |
|
12516 |
|
12517 |
|
12518 |
|
12519 |
|
12520 |
|
12521 | get: function () {
|
12522 | return this._align;
|
12523 | },
|
12524 |
|
12525 |
|
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 |
|
12537 |
|
12538 |
|
12539 |
|
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 |
|
12553 |
|
12554 |
|
12555 |
|
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 |
|
12569 |
|
12570 |
|
12571 |
|
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 |
|
12585 |
|
12586 |
|
12587 |
|
12588 |
|
12589 |
|
12590 |
|
12591 |
|
12592 |
|
12593 |
|
12594 | get: function () {
|
12595 | return this._circularFallback;
|
12596 | },
|
12597 | enumerable: false,
|
12598 | configurable: true
|
12599 | });
|
12600 | Object.defineProperty(__proto, "bound", {
|
12601 | |
12602 |
|
12603 |
|
12604 |
|
12605 |
|
12606 |
|
12607 |
|
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 |
|
12621 |
|
12622 |
|
12623 |
|
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 |
|
12637 |
|
12638 |
|
12639 |
|
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 |
|
12653 |
|
12654 |
|
12655 |
|
12656 |
|
12657 |
|
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 |
|
12671 |
|
12672 |
|
12673 |
|
12674 |
|
12675 |
|
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 |
|
12689 |
|
12690 |
|
12691 |
|
12692 |
|
12693 |
|
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 |
|
12706 |
|
12707 | |
12708 |
|
12709 |
|
12710 |
|
12711 |
|
12712 |
|
12713 | get: function () {
|
12714 | return this._needPanelThreshold;
|
12715 | },
|
12716 |
|
12717 | set: function (val) {
|
12718 | this._needPanelThreshold = val;
|
12719 | },
|
12720 | enumerable: false,
|
12721 | configurable: true
|
12722 | });
|
12723 | Object.defineProperty(__proto, "preventEventsBeforeInit", {
|
12724 | |
12725 |
|
12726 |
|
12727 |
|
12728 |
|
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 |
|
12741 |
|
12742 | |
12743 |
|
12744 |
|
12745 |
|
12746 |
|
12747 |
|
12748 | get: function () {
|
12749 | return this._deceleration;
|
12750 | },
|
12751 |
|
12752 | set: function (val) {
|
12753 | this._deceleration = val;
|
12754 | },
|
12755 | enumerable: false,
|
12756 | configurable: true
|
12757 | });
|
12758 | Object.defineProperty(__proto, "easing", {
|
12759 | |
12760 |
|
12761 |
|
12762 |
|
12763 |
|
12764 |
|
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 |
|
12778 |
|
12779 |
|
12780 |
|
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 |
|
12793 |
|
12794 | |
12795 |
|
12796 |
|
12797 |
|
12798 |
|
12799 |
|
12800 |
|
12801 |
|
12802 | get: function () {
|
12803 | return this._inputType;
|
12804 | },
|
12805 |
|
12806 | set: function (val) {
|
12807 | this._inputType = val;
|
12808 | },
|
12809 | enumerable: false,
|
12810 | configurable: true
|
12811 | });
|
12812 | Object.defineProperty(__proto, "moveType", {
|
12813 | |
12814 |
|
12815 |
|
12816 |
|
12817 |
|
12818 |
|
12819 |
|
12820 |
|
12821 |
|
12822 |
|
12823 |
|
12824 |
|
12825 |
|
12826 |
|
12827 |
|
12828 |
|
12829 |
|
12830 |
|
12831 |
|
12832 |
|
12833 |
|
12834 |
|
12835 |
|
12836 |
|
12837 |
|
12838 |
|
12839 |
|
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 |
|
12855 |
|
12856 |
|
12857 |
|
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 |
|
12871 |
|
12872 |
|
12873 |
|
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 |
|
12887 |
|
12888 |
|
12889 |
|
12890 |
|
12891 |
|
12892 |
|
12893 |
|
12894 |
|
12895 |
|
12896 |
|
12897 |
|
12898 |
|
12899 |
|
12900 |
|
12901 |
|
12902 |
|
12903 |
|
12904 |
|
12905 |
|
12906 |
|
12907 |
|
12908 |
|
12909 |
|
12910 |
|
12911 |
|
12912 |
|
12913 |
|
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 |
|
12928 |
|
12929 |
|
12930 |
|
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 |
|
12944 |
|
12945 |
|
12946 |
|
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 |
|
12970 |
|
12971 |
|
12972 |
|
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 |
|
12986 |
|
12987 |
|
12988 |
|
12989 |
|
12990 |
|
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 |
|
13003 |
|
13004 | |
13005 |
|
13006 |
|
13007 |
|
13008 |
|
13009 |
|
13010 | get: function () {
|
13011 | return this._renderOnlyVisible;
|
13012 | },
|
13013 |
|
13014 | set: function (val) {
|
13015 | this._renderOnlyVisible = val;
|
13016 | },
|
13017 | enumerable: false,
|
13018 | configurable: true
|
13019 | });
|
13020 | Object.defineProperty(__proto, "virtual", {
|
13021 | |
13022 |
|
13023 |
|
13024 |
|
13025 |
|
13026 |
|
13027 |
|
13028 |
|
13029 |
|
13030 |
|
13031 |
|
13032 |
|
13033 |
|
13034 |
|
13035 |
|
13036 |
|
13037 |
|
13038 |
|
13039 |
|
13040 |
|
13041 |
|
13042 |
|
13043 |
|
13044 |
|
13045 |
|
13046 |
|
13047 |
|
13048 |
|
13049 |
|
13050 |
|
13051 |
|
13052 | get: function () {
|
13053 | return this._virtualManager;
|
13054 | },
|
13055 | enumerable: false,
|
13056 | configurable: true
|
13057 | });
|
13058 | Object.defineProperty(__proto, "autoInit", {
|
13059 |
|
13060 |
|
13061 | |
13062 |
|
13063 |
|
13064 |
|
13065 |
|
13066 |
|
13067 |
|
13068 | get: function () {
|
13069 | return this._autoInit;
|
13070 | },
|
13071 | enumerable: false,
|
13072 | configurable: true
|
13073 | });
|
13074 | Object.defineProperty(__proto, "autoResize", {
|
13075 | |
13076 |
|
13077 |
|
13078 |
|
13079 |
|
13080 |
|
13081 | get: function () {
|
13082 | return this._autoResize;
|
13083 | },
|
13084 |
|
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 |
|
13100 |
|
13101 |
|
13102 |
|
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 |
|
13120 |
|
13121 |
|
13122 |
|
13123 |
|
13124 |
|
13125 |
|
13126 |
|
13127 |
|
13128 | get: function () {
|
13129 | return this._resizeDebounce;
|
13130 | },
|
13131 | enumerable: false,
|
13132 | configurable: true
|
13133 | });
|
13134 | Object.defineProperty(__proto, "maxResizeDebounce", {
|
13135 | |
13136 |
|
13137 |
|
13138 |
|
13139 |
|
13140 |
|
13141 |
|
13142 |
|
13143 | get: function () {
|
13144 | return this._maxResizeDebounce;
|
13145 | },
|
13146 | enumerable: false,
|
13147 | configurable: true
|
13148 | });
|
13149 | Object.defineProperty(__proto, "useFractionalSize", {
|
13150 | |
13151 |
|
13152 |
|
13153 |
|
13154 |
|
13155 |
|
13156 |
|
13157 |
|
13158 |
|
13159 |
|
13160 | get: function () {
|
13161 | return this._useFractionalSize;
|
13162 | },
|
13163 | enumerable: false,
|
13164 | configurable: true
|
13165 | });
|
13166 | Object.defineProperty(__proto, "externalRenderer", {
|
13167 | |
13168 |
|
13169 |
|
13170 |
|
13171 |
|
13172 |
|
13173 |
|
13174 | get: function () {
|
13175 | return this._externalRenderer;
|
13176 | },
|
13177 | enumerable: false,
|
13178 | configurable: true
|
13179 | });
|
13180 | Object.defineProperty(__proto, "renderExternal", {
|
13181 | |
13182 |
|
13183 |
|
13184 |
|
13185 |
|
13186 |
|
13187 |
|
13188 |
|
13189 | get: function () {
|
13190 | return this._renderExternal;
|
13191 | },
|
13192 | enumerable: false,
|
13193 | configurable: true
|
13194 | });
|
13195 | |
13196 |
|
13197 |
|
13198 |
|
13199 |
|
13200 |
|
13201 |
|
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();
|
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 |
|
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 |
|
13260 |
|
13261 |
|
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 |
|
13284 |
|
13285 |
|
13286 |
|
13287 |
|
13288 |
|
13289 |
|
13290 |
|
13291 |
|
13292 |
|
13293 |
|
13294 |
|
13295 |
|
13296 |
|
13297 |
|
13298 |
|
13299 |
|
13300 |
|
13301 |
|
13302 |
|
13303 |
|
13304 |
|
13305 |
|
13306 |
|
13307 |
|
13308 |
|
13309 |
|
13310 |
|
13311 |
|
13312 |
|
13313 |
|
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 |
|
13328 |
|
13329 |
|
13330 |
|
13331 |
|
13332 |
|
13333 |
|
13334 |
|
13335 |
|
13336 |
|
13337 |
|
13338 |
|
13339 |
|
13340 |
|
13341 |
|
13342 |
|
13343 |
|
13344 |
|
13345 |
|
13346 |
|
13347 |
|
13348 |
|
13349 |
|
13350 |
|
13351 |
|
13352 |
|
13353 |
|
13354 |
|
13355 |
|
13356 |
|
13357 |
|
13358 |
|
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 |
|
13373 |
|
13374 |
|
13375 |
|
13376 |
|
13377 |
|
13378 |
|
13379 |
|
13380 |
|
13381 |
|
13382 |
|
13383 |
|
13384 |
|
13385 |
|
13386 |
|
13387 |
|
13388 |
|
13389 |
|
13390 |
|
13391 |
|
13392 |
|
13393 |
|
13394 |
|
13395 |
|
13396 |
|
13397 |
|
13398 |
|
13399 |
|
13400 |
|
13401 |
|
13402 |
|
13403 |
|
13404 |
|
13405 |
|
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 |
|
13441 |
|
13442 |
|
13443 |
|
13444 |
|
13445 |
|
13446 |
|
13447 |
|
13448 |
|
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 |
|
13469 |
|
13470 |
|
13471 |
|
13472 |
|
13473 |
|
13474 |
|
13475 | __proto.stopAnimation = function () {
|
13476 | if (!this._control.animating) {
|
13477 | return;
|
13478 | }
|
13479 |
|
13480 | this._control.stopAnimation();
|
13481 | };
|
13482 | |
13483 |
|
13484 |
|
13485 |
|
13486 |
|
13487 |
|
13488 |
|
13489 |
|
13490 |
|
13491 |
|
13492 |
|
13493 |
|
13494 |
|
13495 |
|
13496 | __proto.getPanel = function (index) {
|
13497 | return this._renderer.getPanel(index);
|
13498 | };
|
13499 | |
13500 |
|
13501 |
|
13502 |
|
13503 |
|
13504 |
|
13505 |
|
13506 | __proto.enableInput = function () {
|
13507 | this._control.enable();
|
13508 |
|
13509 | return this;
|
13510 | };
|
13511 | |
13512 |
|
13513 |
|
13514 |
|
13515 |
|
13516 |
|
13517 |
|
13518 | __proto.disableInput = function () {
|
13519 | this._control.disable();
|
13520 |
|
13521 | return this;
|
13522 | };
|
13523 | |
13524 |
|
13525 |
|
13526 |
|
13527 |
|
13528 |
|
13529 |
|
13530 |
|
13531 |
|
13532 |
|
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 |
|
13589 |
|
13590 |
|
13591 |
|
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;
|
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 |
|
13644 |
|
13645 |
|
13646 |
|
13647 |
|
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 |
|
13674 |
|
13675 |
|
13676 |
|
13677 |
|
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 |
|
13705 |
|
13706 |
|
13707 |
|
13708 |
|
13709 |
|
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 |
|
13735 | , renderer.forceRenderAllPanels()];
|
13736 |
|
13737 | case 1:
|
13738 | _a.sent();
|
13739 |
|
13740 |
|
13741 | renderer.updatePanelSize();
|
13742 | camera.updateAlignPos();
|
13743 | camera.updateRange();
|
13744 | camera.updateAnchors();
|
13745 | camera.updateAdaptiveHeight();
|
13746 | camera.updateOffset();
|
13747 | return [4
|
13748 |
|
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 |
|
13774 | ];
|
13775 | }
|
13776 | });
|
13777 | });
|
13778 | };
|
13779 | |
13780 |
|
13781 |
|
13782 |
|
13783 |
|
13784 |
|
13785 |
|
13786 |
|
13787 |
|
13788 |
|
13789 |
|
13790 |
|
13791 |
|
13792 |
|
13793 |
|
13794 |
|
13795 |
|
13796 |
|
13797 |
|
13798 |
|
13799 |
|
13800 |
|
13801 | __proto.append = function (element) {
|
13802 | return this.insert(this._renderer.panelCount, element);
|
13803 | };
|
13804 | |
13805 |
|
13806 |
|
13807 |
|
13808 |
|
13809 |
|
13810 |
|
13811 |
|
13812 |
|
13813 |
|
13814 |
|
13815 |
|
13816 |
|
13817 |
|
13818 |
|
13819 |
|
13820 |
|
13821 |
|
13822 |
|
13823 |
|
13824 |
|
13825 |
|
13826 |
|
13827 | __proto.prepend = function (element) {
|
13828 | return this.insert(0, element);
|
13829 | };
|
13830 | |
13831 |
|
13832 |
|
13833 |
|
13834 |
|
13835 |
|
13836 |
|
13837 |
|
13838 |
|
13839 |
|
13840 |
|
13841 |
|
13842 |
|
13843 |
|
13844 |
|
13845 |
|
13846 |
|
13847 |
|
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 |
|
13865 |
|
13866 |
|
13867 |
|
13868 |
|
13869 |
|
13870 |
|
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 |
|
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 |
|
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 |
|
14015 |
|
14016 |
|
14017 |
|
14018 |
|
14019 |
|
14020 |
|
14021 |
|
14022 |
|
14023 |
|
14024 |
|
14025 | Flicking.VERSION = "4.10.0";
|
14026 | return Flicking;
|
14027 | }(Component);
|
14028 |
|
14029 | |
14030 |
|
14031 |
|
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 |
|
14048 |
|
14049 |
|
14050 |
|
14051 |
|
14052 |
|
14053 |
|
14054 |
|
14055 |
|
14056 |
|
14057 |
|
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 |
|
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 | })
|
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 |
|
14301 |
|
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 |
|