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