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