@egjs/flicking 4.4.1 → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +0 -1
  2. package/declaration/Flicking.d.ts +8 -2
  3. package/declaration/camera/Camera.d.ts +26 -24
  4. package/declaration/camera/index.d.ts +2 -4
  5. package/declaration/camera/mode/BoundCameraMode.d.ts +13 -0
  6. package/declaration/camera/mode/CameraMode.d.ts +19 -0
  7. package/declaration/camera/mode/CircularCameraMode.d.ts +18 -0
  8. package/declaration/camera/mode/LinearCameraMode.d.ts +9 -0
  9. package/declaration/camera/mode/index.d.ts +6 -0
  10. package/declaration/const/external.d.ts +4 -0
  11. package/declaration/control/StrictControl.d.ts +1 -0
  12. package/declaration/type/external.d.ts +1 -3
  13. package/dist/flicking.esm.js +1205 -1093
  14. package/dist/flicking.esm.js.map +1 -1
  15. package/dist/flicking.js +1208 -1095
  16. package/dist/flicking.js.map +1 -1
  17. package/dist/flicking.min.js +2 -2
  18. package/dist/flicking.min.js.map +1 -1
  19. package/dist/flicking.pkgd.js +1208 -1095
  20. package/dist/flicking.pkgd.js.map +1 -1
  21. package/dist/flicking.pkgd.min.js +2 -2
  22. package/dist/flicking.pkgd.min.js.map +1 -1
  23. package/package.json +5 -4
  24. package/src/Flicking.ts +26 -15
  25. package/src/camera/Camera.ts +156 -71
  26. package/src/camera/index.ts +3 -7
  27. package/src/camera/{BoundCamera.ts → mode/BoundCameraMode.ts} +46 -43
  28. package/src/camera/mode/CameraMode.ts +77 -0
  29. package/src/camera/mode/CircularCameraMode.ts +171 -0
  30. package/src/camera/mode/LinearCameraMode.ts +23 -0
  31. package/src/camera/mode/index.ts +14 -0
  32. package/src/cfc/sync.ts +9 -4
  33. package/src/cfc/withFlickingMethods.ts +2 -1
  34. package/src/const/external.ts +12 -0
  35. package/src/control/StrictControl.ts +10 -0
  36. package/declaration/camera/BoundCamera.d.ts +0 -9
  37. package/declaration/camera/CircularCamera.d.ts +0 -37
  38. package/declaration/camera/LinearCamera.d.ts +0 -5
  39. package/src/camera/CircularCamera.ts +0 -268
  40. package/src/camera/LinearCamera.ts +0 -35
@@ -4,7 +4,7 @@ name: @egjs/flicking
4
4
  license: MIT
5
5
  author: NAVER Corp.
6
6
  repository: https://github.com/naver/egjs-flicking
7
- version: 4.4.1
7
+ version: 4.5.1
8
8
  */
9
9
  import Component, { ComponentEvent } from '@egjs/component';
10
10
  import Axes, { PanInput } from '@egjs/axes';
@@ -240,10 +240,12 @@ function __read(o, n) {
240
240
 
241
241
  return ar;
242
242
  }
243
- function __spreadArray(to, from) {
244
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i];
243
+ /** @deprecated */
245
244
 
246
- return to;
245
+ function __spread() {
246
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
247
+
248
+ return ar;
247
249
  }
248
250
 
249
251
  /*
@@ -423,6 +425,18 @@ var CLASS = {
423
425
  HIDDEN: "flicking-hidden",
424
426
  DEFAULT_VIRTUAL: "flicking-panel"
425
427
  };
428
+ /**
429
+ * An object with all possible {@link Flicking#circularFallback circularFallback}s
430
+ * @ko Flicking의 {@link Flicking#circularFallback circularFallback}에 설정 가능한 값들을 담고 있는 객체
431
+ * @type {object}
432
+ * @property {string} LINEAR "linear"
433
+ * @property {string} BOUND "bound"
434
+ */
435
+
436
+ var CIRCULAR_FALLBACK = {
437
+ LINEAR: "linear",
438
+ BOUND: "bound"
439
+ };
426
440
 
427
441
  var merge = function (target) {
428
442
  var sources = [];
@@ -606,7 +620,7 @@ var parseElement = function (element) {
606
620
  if (isString(el)) {
607
621
  var tempDiv = document.createElement("div");
608
622
  tempDiv.innerHTML = el;
609
- elements.push.apply(elements, __spreadArray([], __read(toArray(tempDiv.children))));
623
+ elements.push.apply(elements, __spread(toArray(tempDiv.children)));
610
624
 
611
625
  while (tempDiv.firstChild) {
612
626
  tempDiv.removeChild(tempDiv.firstChild);
@@ -2987,9 +3001,8 @@ function (_super) {
2987
3001
 
2988
3002
 
2989
3003
  function SnapControl(_a) {
2990
- var _b = _a === void 0 ? {} : _a,
2991
- _c = _b.count,
2992
- count = _c === void 0 ? Infinity : _c;
3004
+ var _b = (_a === void 0 ? {} : _a).count,
3005
+ count = _b === void 0 ? Infinity : _b;
2993
3006
 
2994
3007
  var _this = _super.call(this) || this;
2995
3008
 
@@ -3195,9 +3208,8 @@ function (_super) {
3195
3208
 
3196
3209
 
3197
3210
  function FreeControl(_a) {
3198
- var _b = _a === void 0 ? {} : _a,
3199
- _c = _b.stopAtEdge,
3200
- stopAtEdge = _c === void 0 ? true : _c;
3211
+ var _b = (_a === void 0 ? {} : _a).stopAtEdge,
3212
+ stopAtEdge = _b === void 0 ? true : _b;
3201
3213
 
3202
3214
  var _this = _super.call(this) || this;
3203
3215
 
@@ -3331,9 +3343,8 @@ function (_super) {
3331
3343
 
3332
3344
 
3333
3345
  function StrictControl(_a) {
3334
- var _b = _a === void 0 ? {} : _a,
3335
- _c = _b.count,
3336
- count = _c === void 0 ? 1 : _c;
3346
+ var _b = (_a === void 0 ? {} : _a).count,
3347
+ count = _b === void 0 ? 1 : _b;
3337
3348
 
3338
3349
  var _this = _super.call(this) || this;
3339
3350
 
@@ -3456,6 +3467,21 @@ function (_super) {
3456
3467
  };
3457
3468
  return this;
3458
3469
  };
3470
+
3471
+ __proto.moveToPanel = function (panel, options) {
3472
+ return __awaiter(this, void 0, void 0, function () {
3473
+ var flicking, camera, controller;
3474
+ return __generator(this, function (_a) {
3475
+ flicking = getFlickingAttached(this._flicking);
3476
+ camera = flicking.camera;
3477
+ controller = this._controller;
3478
+ controller.update(camera.controlParams);
3479
+ return [2
3480
+ /*return*/
3481
+ , _super.prototype.moveToPanel.call(this, panel, options)];
3482
+ });
3483
+ });
3484
+ };
3459
3485
  /**
3460
3486
  * Move {@link Camera} to the given position
3461
3487
  * @ko {@link Camera}를 주어진 좌표로 이동합니다
@@ -3565,761 +3591,826 @@ function (_super) {
3565
3591
  }(Control);
3566
3592
 
3567
3593
  /**
3568
- * A component that manages actual movement inside the viewport
3569
- * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
3594
+ * A mode of camera
3570
3595
  */
3571
3596
 
3572
- var Camera =
3597
+ var CameraMode =
3573
3598
  /*#__PURE__*/
3574
3599
  function () {
3575
3600
  /** */
3576
- function Camera(_a) {
3577
- var _this = this;
3601
+ function CameraMode(flicking) {
3602
+ this._flicking = flicking;
3603
+ }
3578
3604
 
3579
- var _b = _a === void 0 ? {} : _a,
3580
- _c = _b.align,
3581
- align = _c === void 0 ? ALIGN.CENTER : _c;
3605
+ var __proto = CameraMode.prototype;
3582
3606
 
3583
- this._checkTranslateSupport = function () {
3584
- var e_1, _a;
3607
+ __proto.getAnchors = function () {
3608
+ var panels = this._flicking.renderer.panels;
3609
+ return panels.map(function (panel, index) {
3610
+ return new AnchorPoint({
3611
+ index: index,
3612
+ position: panel.position,
3613
+ panel: panel
3614
+ });
3615
+ });
3616
+ };
3585
3617
 
3586
- var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
3587
- var supportedStyle = document.documentElement.style;
3588
- var transformName = "";
3618
+ __proto.findAnchorIncludePosition = function (position) {
3619
+ var anchors = this._flicking.camera.anchorPoints;
3620
+ var anchorsIncludingPosition = anchors.filter(function (anchor) {
3621
+ return anchor.panel.includePosition(position, true);
3622
+ });
3623
+ return anchorsIncludingPosition.reduce(function (nearest, anchor) {
3624
+ if (!nearest) return anchor;
3625
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3626
+ }, null);
3627
+ };
3589
3628
 
3590
- try {
3591
- for (var transforms_1 = __values(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
3592
- var prefixedTransform = transforms_1_1.value;
3629
+ __proto.clampToReachablePosition = function (position) {
3630
+ var camera = this._flicking.camera;
3631
+ var range = camera.range;
3632
+ return clamp(position, range.min, range.max);
3633
+ };
3593
3634
 
3594
- if (prefixedTransform in supportedStyle) {
3595
- transformName = prefixedTransform;
3596
- }
3597
- }
3598
- } catch (e_1_1) {
3599
- e_1 = {
3600
- error: e_1_1
3601
- };
3602
- } finally {
3603
- try {
3604
- if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
3605
- } finally {
3606
- if (e_1) throw e_1.error;
3607
- }
3608
- }
3635
+ __proto.getCircularOffset = function () {
3636
+ return 0;
3637
+ };
3609
3638
 
3610
- if (!transformName) {
3611
- throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
3612
- }
3639
+ __proto.canReach = function (panel) {
3640
+ var camera = this._flicking.camera;
3641
+ var range = camera.range;
3642
+ if (panel.removed) return false;
3643
+ var panelPos = panel.position;
3644
+ return panelPos >= range.min && panelPos <= range.max;
3645
+ };
3613
3646
 
3614
- _this._transform = transformName;
3647
+ __proto.canSee = function (panel) {
3648
+ var camera = this._flicking.camera;
3649
+ var visibleRange = camera.visibleRange; // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
3650
+
3651
+ return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
3652
+ };
3653
+
3654
+ return CameraMode;
3655
+ }();
3656
+
3657
+ var LinearCameraMode =
3658
+ /*#__PURE__*/
3659
+ function (_super) {
3660
+ __extends(LinearCameraMode, _super);
3661
+
3662
+ function LinearCameraMode() {
3663
+ return _super !== null && _super.apply(this, arguments) || this;
3664
+ }
3665
+
3666
+ var __proto = LinearCameraMode.prototype;
3667
+
3668
+ __proto.checkAvailability = function () {
3669
+ // It's always available
3670
+ return true;
3671
+ };
3672
+
3673
+ __proto.getRange = function () {
3674
+ var _a, _b;
3675
+
3676
+ var renderer = this._flicking.renderer;
3677
+ var firstPanel = renderer.getPanel(0);
3678
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3679
+ return {
3680
+ min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
3681
+ max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
3615
3682
  };
3683
+ };
3616
3684
 
3617
- this._flicking = null;
3685
+ return LinearCameraMode;
3686
+ }(CameraMode);
3618
3687
 
3619
- this._resetInternalValues(); // Options
3688
+ /**
3689
+ * A {@link Camera} mode that connects the last panel and the first panel, enabling continuous loop
3690
+ * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera} 모드
3691
+ */
3620
3692
 
3693
+ var CircularCameraMode =
3694
+ /*#__PURE__*/
3695
+ function (_super) {
3696
+ __extends(CircularCameraMode, _super);
3621
3697
 
3622
- this._align = align;
3698
+ function CircularCameraMode() {
3699
+ return _super !== null && _super.apply(this, arguments) || this;
3623
3700
  }
3624
3701
 
3625
- var __proto = Camera.prototype;
3626
- Object.defineProperty(__proto, "element", {
3627
- // Internal states getter
3702
+ var __proto = CircularCameraMode.prototype;
3628
3703
 
3629
- /**
3630
- * The camera element(`.flicking-camera`)
3631
- * @ko 카메라 엘리먼트(`.flicking-camera`)
3632
- * @type {HTMLElement}
3633
- * @readonly
3634
- */
3635
- get: function () {
3636
- return this._el;
3637
- },
3638
- enumerable: false,
3639
- configurable: true
3640
- });
3641
- Object.defineProperty(__proto, "children", {
3642
- /**
3643
- * An array of the child elements of the camera element(`.flicking-camera`)
3644
- * @ko 카메라 엘리먼트(`.flicking-camera`) 자식 엘리먼트 배열
3645
- * @type {HTMLElement[]}
3646
- * @readonly
3647
- */
3648
- get: function () {
3649
- return toArray(this._el.children);
3650
- },
3651
- enumerable: false,
3652
- configurable: true
3653
- });
3654
- Object.defineProperty(__proto, "position", {
3655
- /**
3656
- * Current position of the camera
3657
- * @ko Camera의 현재 좌표
3658
- * @type {number}
3659
- * @readonly
3660
- */
3661
- get: function () {
3662
- return this._position;
3663
- },
3664
- enumerable: false,
3665
- configurable: true
3666
- });
3667
- Object.defineProperty(__proto, "alignPosition", {
3668
- /**
3669
- * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
3670
- * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
3671
- * @type {number}
3672
- * @readonly
3673
- */
3674
- get: function () {
3675
- return this._alignPos;
3676
- },
3677
- enumerable: false,
3678
- configurable: true
3679
- });
3680
- Object.defineProperty(__proto, "offset", {
3681
- /**
3682
- * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
3683
- * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
3684
- * @type {number}
3685
- * @default 0
3686
- * @readonly
3687
- */
3688
- get: function () {
3689
- return this._offset;
3690
- },
3691
- enumerable: false,
3692
- configurable: true
3693
- });
3694
- Object.defineProperty(__proto, "range", {
3695
- /**
3696
- * A range that Camera's {@link Camera#position position} can reach
3697
- * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
3698
- * @type {object}
3699
- * @property {number} min A minimum position<ko>최소 위치</ko>
3700
- * @property {number} min A maximum position<ko>최대 위치</ko>
3701
- * @readonly
3702
- */
3703
- get: function () {
3704
- return this._range;
3705
- },
3706
- enumerable: false,
3707
- configurable: true
3708
- });
3709
- Object.defineProperty(__proto, "rangeDiff", {
3710
- /**
3711
- * A difference between Camera's minimum and maximum position that can reach
3712
- * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
3713
- * @type {number}
3714
- * @readonly
3715
- */
3716
- get: function () {
3717
- return this._range.max - this._range.min;
3718
- },
3719
- enumerable: false,
3720
- configurable: true
3721
- });
3722
- Object.defineProperty(__proto, "visiblePanels", {
3723
- /**
3724
- * An array of visible panels from the current position
3725
- * @ko 현재 보이는 패널들의 배열
3726
- * @type {Panel[]}
3727
- * @readonly
3728
- */
3729
- get: function () {
3730
- return this._visiblePanels;
3731
- },
3732
- enumerable: false,
3733
- configurable: true
3734
- });
3735
- Object.defineProperty(__proto, "visibleRange", {
3736
- /**
3737
- * A range of the visible area from the current position
3738
- * @ko 현재 위치에서 보이는 범위
3739
- * @type {object}
3740
- * @property {number} min A minimum position<ko>최소 위치</ko>
3741
- * @property {number} min A maximum position<ko>최대 위치</ko>
3742
- * @readonly
3743
- */
3744
- get: function () {
3704
+ __proto.checkAvailability = function () {
3705
+ var flicking = this._flicking;
3706
+ var renderer = flicking.renderer;
3707
+ var panels = renderer.panels;
3708
+
3709
+ if (panels.length <= 0) {
3710
+ return false;
3711
+ }
3712
+
3713
+ var firstPanel = panels[0];
3714
+ var lastPanel = panels[panels.length - 1];
3715
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
3716
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
3717
+ var visibleSize = flicking.camera.size;
3718
+ var panelSizeSum = lastPanelNext - firstPanelPrev;
3719
+ var canSetCircularMode = panels.every(function (panel) {
3720
+ return panelSizeSum - panel.size >= visibleSize;
3721
+ });
3722
+ return canSetCircularMode;
3723
+ };
3724
+
3725
+ __proto.getRange = function () {
3726
+ var flicking = this._flicking;
3727
+ var panels = flicking.renderer.panels;
3728
+
3729
+ if (panels.length <= 0) {
3745
3730
  return {
3746
- min: this._position - this._alignPos,
3747
- max: this._position - this._alignPos + this.size
3731
+ min: 0,
3732
+ max: 0
3748
3733
  };
3749
- },
3750
- enumerable: false,
3751
- configurable: true
3752
- });
3753
- Object.defineProperty(__proto, "anchorPoints", {
3754
- /**
3755
- * An array of {@link AnchorPoint}s that Camera can be stopped at
3756
- * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
3757
- * @type {AnchorPoint[]}
3758
- * @readonly
3759
- */
3760
- get: function () {
3761
- return this._anchors;
3762
- },
3763
- enumerable: false,
3764
- configurable: true
3765
- });
3766
- Object.defineProperty(__proto, "controlParams", {
3767
- /**
3768
- * A current parameters of the Camera for updating {@link AxesController}
3769
- * @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
3770
- * @type {ControlParams}
3771
- * @readonly
3772
- */
3773
- get: function () {
3774
- return {
3775
- range: this._range,
3776
- position: this._position,
3777
- circular: false
3778
- };
3779
- },
3780
- enumerable: false,
3781
- configurable: true
3782
- });
3783
- Object.defineProperty(__proto, "atEdge", {
3784
- /**
3785
- * A Boolean value indicating whether Camera's over the minimum or maximum position reachable
3786
- * @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
3787
- * @type {boolean}
3788
- * @readonly
3789
- */
3790
- get: function () {
3791
- return this._position <= this._range.min || this._position >= this._range.max;
3792
- },
3793
- enumerable: false,
3794
- configurable: true
3795
- });
3796
- Object.defineProperty(__proto, "size", {
3797
- /**
3798
- * Return the size of the viewport
3799
- * @ko 뷰포트 크기를 반환합니다
3800
- * @type {number}
3801
- * @readonly
3802
- */
3803
- get: function () {
3804
- var flicking = this._flicking;
3805
- return flicking ? flicking.horizontal ? flicking.viewport.width : flicking.viewport.height : 0;
3806
- },
3807
- enumerable: false,
3808
- configurable: true
3809
- });
3810
- Object.defineProperty(__proto, "progress", {
3811
- /**
3812
- * Return the camera's position progress from the first panel to last panel
3813
- * Range is from 0 to last panel's index
3814
- * @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
3815
- * 범위는 0부터 마지막 패널의 인덱스까지입니다
3816
- * @type {number}
3817
- * @readonly
3818
- */
3819
- get: function () {
3820
- var flicking = this._flicking;
3821
- var position = this._position + this._offset;
3822
- var nearestAnchor = this.findNearestAnchor(this._position);
3734
+ }
3823
3735
 
3824
- if (!flicking || !nearestAnchor) {
3825
- return NaN;
3826
- }
3736
+ var firstPanel = panels[0];
3737
+ var lastPanel = panels[panels.length - 1];
3738
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
3739
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
3740
+ return {
3741
+ min: firstPanelPrev,
3742
+ max: lastPanelNext
3743
+ };
3744
+ };
3827
3745
 
3828
- var nearestPanel = nearestAnchor.panel;
3829
- var panelPos = nearestPanel.position + nearestPanel.offset;
3830
- var bounceSize = flicking.control.controller.bounce;
3831
- var _a = this.range,
3832
- prevRange = _a.min,
3833
- nextRange = _a.max;
3834
- var rangeDiff = this.rangeDiff;
3746
+ __proto.getAnchors = function () {
3747
+ var flicking = this._flicking;
3748
+ var panels = flicking.renderer.panels;
3749
+ return panels.map(function (panel, index) {
3750
+ return new AnchorPoint({
3751
+ index: index,
3752
+ position: panel.position,
3753
+ panel: panel
3754
+ });
3755
+ });
3756
+ };
3835
3757
 
3836
- if (position === panelPos) {
3837
- return nearestPanel.index;
3838
- }
3758
+ __proto.findAnchorIncludePosition = function (position) {
3759
+ var camera = this._flicking.camera;
3760
+ var range = camera.range;
3761
+ var anchors = camera.anchorPoints;
3762
+ var rangeDiff = camera.rangeDiff;
3763
+ var anchorCount = anchors.length;
3764
+ var positionInRange = circulatePosition(position, range.min, range.max);
3839
3765
 
3840
- if (position < panelPos) {
3841
- var prevPanel = nearestPanel.prev();
3842
- var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
3766
+ var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
3843
3767
 
3844
- if (prevPosition > panelPos) {
3845
- prevPosition -= rangeDiff;
3846
- }
3768
+ if (anchorCount > 0 && (position === range.min || position === range.max)) {
3769
+ var possibleAnchors = [anchorInRange, new AnchorPoint({
3770
+ index: 0,
3771
+ position: anchors[0].position + rangeDiff,
3772
+ panel: anchors[0].panel
3773
+ }), new AnchorPoint({
3774
+ index: anchorCount - 1,
3775
+ position: anchors[anchorCount - 1].position - rangeDiff,
3776
+ panel: anchors[anchorCount - 1].panel
3777
+ })].filter(function (anchor) {
3778
+ return !!anchor;
3779
+ });
3780
+ anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
3781
+ if (!nearest) return anchor;
3782
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3783
+ }, null);
3784
+ }
3847
3785
 
3848
- return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
3849
- } else {
3850
- var nextPanel = nearestPanel.next();
3851
- var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1]; // Looped
3786
+ if (!anchorInRange) return null;
3852
3787
 
3853
- if (nextPosition < panelPos) {
3854
- nextPosition += rangeDiff;
3855
- }
3788
+ if (position < range.min) {
3789
+ var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
3790
+ return new AnchorPoint({
3791
+ index: anchorInRange.index,
3792
+ position: anchorInRange.position + rangeDiff * loopCount,
3793
+ panel: anchorInRange.panel
3794
+ });
3795
+ } else if (position > range.max) {
3796
+ var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
3797
+ return new AnchorPoint({
3798
+ index: anchorInRange.index,
3799
+ position: anchorInRange.position + rangeDiff * loopCount,
3800
+ panel: anchorInRange.panel
3801
+ });
3802
+ }
3856
3803
 
3857
- return nearestPanel.index + getProgress(position, panelPos, nextPosition);
3858
- }
3859
- },
3860
- enumerable: false,
3861
- configurable: true
3862
- });
3863
- Object.defineProperty(__proto, "align", {
3864
- // Options Getter
3804
+ return anchorInRange;
3805
+ };
3865
3806
 
3866
- /**
3867
- * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
3868
- * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
3869
- * @type {ALIGN | string | number}
3870
- */
3871
- get: function () {
3872
- return this._align;
3873
- },
3874
- // Options Setter
3875
- set: function (val) {
3876
- this._align = val;
3877
- },
3878
- enumerable: false,
3879
- configurable: true
3880
- });
3881
- /**
3882
- * Initialize Camera
3883
- * @ko Camera를 초기화합니다
3884
- * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
3885
- * @chainable
3886
- * @throws {FlickingError}
3887
- * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
3888
- * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
3889
- * @return {this}
3890
- */
3807
+ __proto.getCircularOffset = function () {
3808
+ var flicking = this._flicking;
3809
+ var camera = flicking.camera;
3810
+ if (!camera.circularEnabled) return 0;
3811
+ var toggled = flicking.panels.filter(function (panel) {
3812
+ return panel.toggled;
3813
+ });
3814
+ var toggledPrev = toggled.filter(function (panel) {
3815
+ return panel.toggleDirection === DIRECTION.PREV;
3816
+ });
3817
+ var toggledNext = toggled.filter(function (panel) {
3818
+ return panel.toggleDirection === DIRECTION.NEXT;
3819
+ });
3820
+ return this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
3821
+ };
3891
3822
 
3892
- __proto.init = function (flicking) {
3893
- this._flicking = flicking;
3894
- var viewportEl = flicking.viewport.element;
3895
- checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
3896
- this._el = viewportEl.firstElementChild;
3823
+ __proto.clampToReachablePosition = function (position) {
3824
+ // Basically all position is reachable for circular camera
3825
+ return position;
3826
+ };
3897
3827
 
3898
- this._checkTranslateSupport();
3828
+ __proto.canReach = function (panel) {
3829
+ if (panel.removed) return false; // Always reachable on circular mode
3899
3830
 
3900
- return this;
3831
+ return true;
3901
3832
  };
3902
- /**
3903
- * Destroy Camera and return to initial state
3904
- * @ko Camera를 초기 상태로 되돌립니다
3905
- * @return {void}
3906
- */
3907
3833
 
3834
+ __proto.canSee = function (panel) {
3835
+ var camera = this._flicking.camera;
3836
+ var range = camera.range;
3837
+ var rangeDiff = camera.rangeDiff;
3838
+ var visibleRange = camera.visibleRange;
3908
3839
 
3909
- __proto.destroy = function () {
3910
- this._flicking = null;
3840
+ var visibleInCurrentRange = _super.prototype.canSee.call(this, panel); // Check looped visible area for circular case
3911
3841
 
3912
- this._resetInternalValues();
3913
3842
 
3914
- return this;
3843
+ if (visibleRange.min < range.min) {
3844
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
3845
+ } else if (visibleRange.max > range.max) {
3846
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
3847
+ }
3848
+
3849
+ return visibleInCurrentRange;
3915
3850
  };
3916
- /**
3917
- * Move to the given position and apply CSS transform
3918
- * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
3919
- * @param {number} pos A new position<ko>움직일 위치</ko>
3920
- * @throws {FlickingError}
3921
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
3922
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
3923
- * @return {this}
3924
- */
3925
3851
 
3852
+ __proto._calcPanelAreaSum = function (panels) {
3853
+ return panels.reduce(function (sum, panel) {
3854
+ return sum + panel.sizeIncludingMargin;
3855
+ }, 0);
3856
+ };
3926
3857
 
3927
- __proto.lookAt = function (pos) {
3928
- var prevPos = this._position;
3929
- this._position = pos;
3858
+ return CircularCameraMode;
3859
+ }(CameraMode);
3930
3860
 
3931
- this._refreshVisiblePanels();
3861
+ var BoundCameraMode =
3862
+ /*#__PURE__*/
3863
+ function (_super) {
3864
+ __extends(BoundCameraMode, _super);
3932
3865
 
3933
- this._checkNeedPanel();
3866
+ function BoundCameraMode() {
3867
+ return _super !== null && _super.apply(this, arguments) || this;
3868
+ }
3934
3869
 
3935
- this._checkReachEnd(prevPos, pos);
3870
+ var __proto = BoundCameraMode.prototype;
3936
3871
 
3937
- this.applyTransform();
3938
- };
3939
- /**
3940
- * Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
3941
- * If it does not exist, return `null` instead
3942
- * @ko 주어진 {@link AnchorPoint}의 이전 {@link AnchorPoint}를 반환합니다
3943
- * 존재하지 않을 경우 `null`을 반환합니다
3944
- * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
3945
- * @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
3946
- */
3872
+ __proto.checkAvailability = function () {
3873
+ var flicking = this._flicking;
3874
+ var renderer = flicking.renderer;
3875
+ var firstPanel = renderer.getPanel(0);
3876
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3947
3877
 
3878
+ if (!firstPanel || !lastPanel) {
3879
+ return false;
3880
+ }
3948
3881
 
3949
- __proto.getPrevAnchor = function (anchor) {
3950
- return this._anchors[anchor.index - 1] || null;
3882
+ var viewportSize = flicking.camera.size;
3883
+ var firstPanelPrev = firstPanel.range.min;
3884
+ var lastPanelNext = lastPanel.range.max;
3885
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
3886
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
3887
+ return isBiggerThanViewport;
3951
3888
  };
3952
- /**
3953
- * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
3954
- * If it does not exist, return `null` instead
3955
- * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
3956
- * 존재하지 않을 경우 `null`을 반환합니다
3957
- * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
3958
- * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
3959
- */
3960
3889
 
3890
+ __proto.getRange = function () {
3891
+ var flicking = this._flicking;
3892
+ var renderer = flicking.renderer;
3893
+ var alignPos = flicking.camera.alignPosition;
3894
+ var firstPanel = renderer.getPanel(0);
3895
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3961
3896
 
3962
- __proto.getNextAnchor = function (anchor) {
3963
- return this._anchors[anchor.index + 1] || null;
3964
- };
3965
- /**
3966
- * Return the camera's position progress in the panel below
3967
- * Value is from 0 to 1 when the camera's inside panel
3968
- * Value can be lower than 0 or bigger than 1 when it's in the margin area
3969
- * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
3970
- * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
3971
- * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
3972
- */
3897
+ if (!firstPanel || !lastPanel) {
3898
+ return {
3899
+ min: 0,
3900
+ max: 0
3901
+ };
3902
+ }
3973
3903
 
3904
+ var viewportSize = flicking.camera.size;
3905
+ var firstPanelPrev = firstPanel.range.min;
3906
+ var lastPanelNext = lastPanel.range.max;
3907
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
3908
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
3909
+ var firstPos = firstPanelPrev + alignPos;
3910
+ var lastPos = lastPanelNext - viewportSize + alignPos;
3974
3911
 
3975
- __proto.getProgressInPanel = function (panel) {
3976
- var panelRange = panel.range;
3977
- return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
3912
+ if (isBiggerThanViewport) {
3913
+ return {
3914
+ min: firstPos,
3915
+ max: lastPos
3916
+ };
3917
+ } else {
3918
+ var align = flicking.camera.align;
3919
+ var alignVal = typeof align === "object" ? align.camera : align;
3920
+ var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
3921
+ return {
3922
+ min: pos,
3923
+ max: pos
3924
+ };
3925
+ }
3978
3926
  };
3979
- /**
3980
- * Return {@link AnchorPoint} that includes given position
3981
- * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
3982
- * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
3983
- * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
3984
- * @param {number} position A position to check<ko>확인할 좌표</ko>
3985
- * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
3986
- */
3987
3927
 
3928
+ __proto.getAnchors = function () {
3929
+ var flicking = this._flicking;
3930
+ var camera = flicking.camera;
3931
+ var panels = flicking.renderer.panels;
3932
+
3933
+ if (panels.length <= 0) {
3934
+ return [];
3935
+ }
3988
3936
 
3989
- __proto.findAnchorIncludePosition = function (position) {
3990
- var anchors = this._anchors;
3991
- var anchorsIncludingPosition = anchors.filter(function (anchor) {
3992
- return anchor.panel.includePosition(position, true);
3937
+ var range = flicking.camera.range;
3938
+ var reachablePanels = panels.filter(function (panel) {
3939
+ return camera.canReach(panel);
3993
3940
  });
3994
- return anchorsIncludingPosition.reduce(function (nearest, anchor) {
3995
- if (!nearest) return anchor;
3996
- return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3997
- }, null);
3998
- };
3999
- /**
4000
- * Return {@link AnchorPoint} nearest to given position
4001
- * If there're no {@link AnchorPoint}s, return `null` instead
4002
- * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
4003
- * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
4004
- * @param {number} position A position to check<ko>확인할 좌표</ko>
4005
- * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
4006
- */
4007
3941
 
3942
+ if (reachablePanels.length > 0) {
3943
+ var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
3944
+ var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
3945
+ var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
3946
+ var newAnchors = reachablePanels.map(function (panel, idx) {
3947
+ return new AnchorPoint({
3948
+ index: idx + indexOffset_1,
3949
+ position: panel.position,
3950
+ panel: panel
3951
+ });
3952
+ });
3953
+
3954
+ if (shouldPrependBoundAnchor) {
3955
+ newAnchors.splice(0, 0, new AnchorPoint({
3956
+ index: 0,
3957
+ position: range.min,
3958
+ panel: panels[reachablePanels[0].index - 1]
3959
+ }));
3960
+ }
4008
3961
 
4009
- __proto.findNearestAnchor = function (position) {
4010
- var anchors = this._anchors;
3962
+ if (shouldAppendBoundAnchor) {
3963
+ newAnchors.push(new AnchorPoint({
3964
+ index: newAnchors.length,
3965
+ position: range.max,
3966
+ panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
3967
+ }));
3968
+ }
3969
+
3970
+ return newAnchors;
3971
+ } else if (range.min !== range.max) {
3972
+ // There're more than 2 panels
3973
+ var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
3974
+
3975
+ var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
3976
+ var panelAtMax = panelAtMin.next();
3977
+ return [new AnchorPoint({
3978
+ index: 0,
3979
+ position: range.min,
3980
+ panel: panelAtMin
3981
+ }), new AnchorPoint({
3982
+ index: 1,
3983
+ position: range.max,
3984
+ panel: panelAtMax
3985
+ })];
3986
+ } else {
3987
+ return [new AnchorPoint({
3988
+ index: 0,
3989
+ position: range.min,
3990
+ panel: this._findNearestPanel(range.min, panels)
3991
+ })];
3992
+ }
3993
+ };
3994
+
3995
+ __proto.findAnchorIncludePosition = function (position) {
3996
+ var camera = this._flicking.camera;
3997
+ var range = camera.range;
3998
+ var anchors = camera.anchorPoints;
4011
3999
  if (anchors.length <= 0) return null;
4000
+
4001
+ if (position <= range.min) {
4002
+ return anchors[0];
4003
+ } else if (position >= range.max) {
4004
+ return anchors[anchors.length - 1];
4005
+ } else {
4006
+ return _super.prototype.findAnchorIncludePosition.call(this, position);
4007
+ }
4008
+ };
4009
+
4010
+ __proto._findNearestPanel = function (pos, panels) {
4012
4011
  var prevDist = Infinity;
4013
4012
 
4014
- for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
4015
- var anchor = anchors[anchorIdx];
4016
- var dist = Math.abs(anchor.position - position);
4013
+ for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
4014
+ var panel = panels[panelIdx];
4015
+ var dist = Math.abs(panel.position - pos);
4017
4016
 
4018
4017
  if (dist > prevDist) {
4019
4018
  // Return previous anchor
4020
- return anchors[anchorIdx - 1];
4019
+ return panels[panelIdx - 1];
4021
4020
  }
4022
4021
 
4023
4022
  prevDist = dist;
4024
4023
  } // Return last anchor
4025
4024
 
4026
4025
 
4027
- return anchors[anchors.length - 1];
4026
+ return panels[panels.length - 1];
4028
4027
  };
4029
- /**
4030
- * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
4031
- * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
4032
- * @return {AnchorPoint | null}
4033
- */
4034
4028
 
4029
+ return BoundCameraMode;
4030
+ }(CameraMode);
4035
4031
 
4036
- __proto.findActiveAnchor = function () {
4037
- var flicking = getFlickingAttached(this._flicking);
4038
- var activeIndex = flicking.control.activeIndex;
4039
- return find(this._anchors, function (anchor) {
4040
- return anchor.panel.index === activeIndex;
4041
- });
4042
- };
4043
- /**
4044
- * Clamp the given position between camera's range
4045
- * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
4046
- * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
4047
- * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
4048
- */
4032
+ /**
4033
+ * A component that manages actual movement inside the viewport
4034
+ * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
4035
+ */
4049
4036
 
4037
+ var Camera =
4038
+ /*#__PURE__*/
4039
+ function () {
4040
+ /** */
4041
+ function Camera(_a) {
4042
+ var _this = this;
4050
4043
 
4051
- __proto.clampToReachablePosition = function (position) {
4052
- var range = this._range;
4053
- return clamp(position, range.min, range.max);
4054
- };
4055
- /**
4056
- * Check whether the given panel is inside of the Camera's range
4057
- * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
4058
- * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4059
- * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
4060
- */
4044
+ var _b = (_a === void 0 ? {} : _a).align,
4045
+ align = _b === void 0 ? ALIGN.CENTER : _b;
4061
4046
 
4047
+ this._checkTranslateSupport = function () {
4048
+ var e_1, _a;
4062
4049
 
4063
- __proto.canReach = function (panel) {
4064
- var range = this._range;
4065
- if (panel.removed) return false;
4066
- var panelPos = panel.position;
4067
- return panelPos >= range.min && panelPos <= range.max;
4068
- };
4069
- /**
4070
- * Check whether the given panel element is visible at the current position
4071
- * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
4072
- * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4073
- * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
4074
- */
4050
+ var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
4051
+ var supportedStyle = document.documentElement.style;
4052
+ var transformName = "";
4075
4053
 
4054
+ try {
4055
+ for (var transforms_1 = __values(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
4056
+ var prefixedTransform = transforms_1_1.value;
4076
4057
 
4077
- __proto.canSee = function (panel) {
4078
- var visibleRange = this.visibleRange; // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
4079
-
4080
- return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
4081
- };
4082
- /**
4083
- * Update Camera's {@link Camera#alignPosition alignPosition}
4084
- * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
4085
- * @chainable
4086
- * @return {this}
4087
- */
4088
-
4089
-
4090
- __proto.updateAlignPos = function () {
4091
- var align = this._align;
4092
- var alignVal = typeof align === "object" ? align.camera : align;
4093
- this._alignPos = parseAlign$1(alignVal, this.size);
4094
- return this;
4095
- };
4096
- /**
4097
- * Update Camera's {@link Camera#anchorPoints anchorPoints}
4098
- * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
4099
- * @throws {FlickingError}
4100
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4101
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4102
- * @chainable
4103
- * @return {this}
4104
- */
4105
-
4106
-
4107
- __proto.updateAnchors = function () {
4108
- var flicking = getFlickingAttached(this._flicking);
4109
- var panels = flicking.renderer.panels;
4110
- this._anchors = panels.map(function (panel, index) {
4111
- return new AnchorPoint({
4112
- index: index,
4113
- position: panel.position,
4114
- panel: panel
4115
- });
4116
- });
4117
- return this;
4118
- };
4119
- /**
4120
- * Update Viewport's height to active panel's height
4121
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4122
- * @throws {FlickingError}
4123
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4124
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4125
- * @chainable
4126
- * @return {this}
4127
- */
4128
-
4129
-
4130
- __proto.updateAdaptiveHeight = function () {
4131
- var flicking = getFlickingAttached(this._flicking);
4132
- var activePanel = flicking.control.activePanel;
4133
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4134
- flicking.viewport.setSize({
4135
- height: activePanel.height
4136
- });
4137
- };
4138
- /**
4139
- * Update current offset of the camera
4140
- * @ko 현재 카메라의 오프셋을 업데이트합니다
4141
- * @chainable
4142
- * @return {this}
4143
- */
4144
-
4145
-
4146
- __proto.updateOffset = function () {
4147
- var flicking = getFlickingAttached(this._flicking);
4148
- var position = this._position;
4149
- var unRenderedPanels = flicking.panels.filter(function (panel) {
4150
- return !panel.rendered;
4151
- });
4152
- this._offset = unRenderedPanels.filter(function (panel) {
4153
- return panel.position + panel.offset < position;
4154
- }).reduce(function (offset, panel) {
4155
- return offset + panel.sizeIncludingMargin;
4156
- }, 0);
4157
- this.applyTransform();
4158
- return this;
4159
- };
4160
- /**
4161
- * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4162
- * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
4163
- * @chainable
4164
- * @return {this}
4165
- */
4058
+ if (prefixedTransform in supportedStyle) {
4059
+ transformName = prefixedTransform;
4060
+ }
4061
+ }
4062
+ } catch (e_1_1) {
4063
+ e_1 = {
4064
+ error: e_1_1
4065
+ };
4066
+ } finally {
4067
+ try {
4068
+ if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
4069
+ } finally {
4070
+ if (e_1) throw e_1.error;
4071
+ }
4072
+ }
4166
4073
 
4074
+ if (!transformName) {
4075
+ throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
4076
+ }
4167
4077
 
4168
- __proto.resetNeedPanelHistory = function () {
4169
- this._needPanelTriggered = {
4170
- prev: false,
4171
- next: false
4078
+ _this._transform = transformName;
4172
4079
  };
4173
- return this;
4174
- };
4175
- /**
4176
- * Apply "transform" style with the current position to camera element
4177
- * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
4178
- * @chainable
4179
- * @return {this}
4180
- */
4181
4080
 
4081
+ this._flicking = null;
4182
4082
 
4183
- __proto.applyTransform = function () {
4184
- var el = this._el;
4185
- var flicking = getFlickingAttached(this._flicking);
4186
- var actualPosition = this._position - this._alignPos - this._offset;
4187
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4188
- return this;
4189
- };
4083
+ this._resetInternalValues(); // Options
4190
4084
 
4191
- __proto._resetInternalValues = function () {
4192
- this._position = 0;
4193
- this._alignPos = 0;
4194
- this._offset = 0;
4195
- this._range = {
4196
- min: 0,
4197
- max: 0
4198
- };
4199
- this._visiblePanels = [];
4200
- this._anchors = [];
4201
- this._needPanelTriggered = {
4202
- prev: false,
4203
- next: false
4204
- };
4205
- };
4206
4085
 
4207
- __proto._refreshVisiblePanels = function () {
4208
- var _this = this;
4086
+ this._align = align;
4087
+ }
4209
4088
 
4210
- var flicking = getFlickingAttached(this._flicking);
4211
- var panels = flicking.renderer.panels;
4212
- var newVisiblePanels = panels.filter(function (panel) {
4213
- return _this.canSee(panel);
4214
- });
4215
- var prevVisiblePanels = this._visiblePanels;
4216
- this._visiblePanels = newVisiblePanels;
4217
- var added = newVisiblePanels.filter(function (panel) {
4218
- return !includes(prevVisiblePanels, panel);
4219
- });
4220
- var removed = prevVisiblePanels.filter(function (panel) {
4221
- return !includes(newVisiblePanels, panel);
4222
- });
4089
+ var __proto = Camera.prototype;
4090
+ Object.defineProperty(__proto, "element", {
4091
+ // Internal states getter
4092
+
4093
+ /**
4094
+ * The camera element(`.flicking-camera`)
4095
+ * @ko 카메라 엘리먼트(`.flicking-camera`)
4096
+ * @type {HTMLElement}
4097
+ * @readonly
4098
+ */
4099
+ get: function () {
4100
+ return this._el;
4101
+ },
4102
+ enumerable: false,
4103
+ configurable: true
4104
+ });
4105
+ Object.defineProperty(__proto, "children", {
4106
+ /**
4107
+ * An array of the child elements of the camera element(`.flicking-camera`)
4108
+ * @ko 카메라 엘리먼트(`.flicking-camera`)의 자식 엘리먼트 배열
4109
+ * @type {HTMLElement[]}
4110
+ * @readonly
4111
+ */
4112
+ get: function () {
4113
+ return toArray(this._el.children);
4114
+ },
4115
+ enumerable: false,
4116
+ configurable: true
4117
+ });
4118
+ Object.defineProperty(__proto, "position", {
4119
+ /**
4120
+ * Current position of the camera
4121
+ * @ko Camera의 현재 좌표
4122
+ * @type {number}
4123
+ * @readonly
4124
+ */
4125
+ get: function () {
4126
+ return this._position;
4127
+ },
4128
+ enumerable: false,
4129
+ configurable: true
4130
+ });
4131
+ Object.defineProperty(__proto, "alignPosition", {
4132
+ /**
4133
+ * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
4134
+ * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
4135
+ * @type {number}
4136
+ * @readonly
4137
+ */
4138
+ get: function () {
4139
+ return this._alignPos;
4140
+ },
4141
+ enumerable: false,
4142
+ configurable: true
4143
+ });
4144
+ Object.defineProperty(__proto, "offset", {
4145
+ /**
4146
+ * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
4147
+ * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
4148
+ * @type {number}
4149
+ * @default 0
4150
+ * @readonly
4151
+ */
4152
+ get: function () {
4153
+ return this._offset - this._circularOffset;
4154
+ },
4155
+ enumerable: false,
4156
+ configurable: true
4157
+ });
4158
+ Object.defineProperty(__proto, "circularEnabled", {
4159
+ /**
4160
+ * Whether the `circular` option is enabled.
4161
+ * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
4162
+ * @ko {@link Flicking#circular circular} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
4163
+ * {@link Flicking#circular circular} 옵션은 패널의 크기의 합이 충분하지 않을 경우 비활성화됩니다.
4164
+ * @type {boolean}
4165
+ * @default false
4166
+ * @readonly
4167
+ */
4168
+ get: function () {
4169
+ return this._circularEnabled;
4170
+ },
4171
+ enumerable: false,
4172
+ configurable: true
4173
+ });
4174
+ Object.defineProperty(__proto, "mode", {
4175
+ /**
4176
+ * A current camera mode
4177
+ * @type {CameraMode}
4178
+ * @readonly
4179
+ */
4180
+ get: function () {
4181
+ return this._mode;
4182
+ },
4183
+ enumerable: false,
4184
+ configurable: true
4185
+ });
4186
+ Object.defineProperty(__proto, "range", {
4187
+ /**
4188
+ * A range that Camera's {@link Camera#position position} can reach
4189
+ * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
4190
+ * @type {object}
4191
+ * @property {number} min A minimum position<ko>최소 위치</ko>
4192
+ * @property {number} max A maximum position<ko>최대 위치</ko>
4193
+ * @readonly
4194
+ */
4195
+ get: function () {
4196
+ return this._range;
4197
+ },
4198
+ enumerable: false,
4199
+ configurable: true
4200
+ });
4201
+ Object.defineProperty(__proto, "rangeDiff", {
4202
+ /**
4203
+ * A difference between Camera's minimum and maximum position that can reach
4204
+ * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
4205
+ * @type {number}
4206
+ * @readonly
4207
+ */
4208
+ get: function () {
4209
+ return this._range.max - this._range.min;
4210
+ },
4211
+ enumerable: false,
4212
+ configurable: true
4213
+ });
4214
+ Object.defineProperty(__proto, "visiblePanels", {
4215
+ /**
4216
+ * An array of visible panels from the current position
4217
+ * @ko 현재 보이는 패널들의 배열
4218
+ * @type {Panel[]}
4219
+ * @readonly
4220
+ */
4221
+ get: function () {
4222
+ return this._visiblePanels;
4223
+ },
4224
+ enumerable: false,
4225
+ configurable: true
4226
+ });
4227
+ Object.defineProperty(__proto, "visibleRange", {
4228
+ /**
4229
+ * A range of the visible area from the current position
4230
+ * @ko 현재 위치에서 보이는 범위
4231
+ * @type {object}
4232
+ * @property {number} min A minimum position<ko>최소 위치</ko>
4233
+ * @property {number} min A maximum position<ko>최대 위치</ko>
4234
+ * @readonly
4235
+ */
4236
+ get: function () {
4237
+ return {
4238
+ min: this._position - this._alignPos,
4239
+ max: this._position - this._alignPos + this.size
4240
+ };
4241
+ },
4242
+ enumerable: false,
4243
+ configurable: true
4244
+ });
4245
+ Object.defineProperty(__proto, "anchorPoints", {
4246
+ /**
4247
+ * An array of {@link AnchorPoint}s that Camera can be stopped at
4248
+ * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
4249
+ * @type {AnchorPoint[]}
4250
+ * @readonly
4251
+ */
4252
+ get: function () {
4253
+ return this._anchors;
4254
+ },
4255
+ enumerable: false,
4256
+ configurable: true
4257
+ });
4258
+ Object.defineProperty(__proto, "controlParams", {
4259
+ /**
4260
+ * A current parameters of the Camera for updating {@link AxesController}
4261
+ * @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
4262
+ * @type {ControlParams}
4263
+ * @readonly
4264
+ */
4265
+ get: function () {
4266
+ return {
4267
+ range: this._range,
4268
+ position: this._position,
4269
+ circular: this._circularEnabled
4270
+ };
4271
+ },
4272
+ enumerable: false,
4273
+ configurable: true
4274
+ });
4275
+ Object.defineProperty(__proto, "atEdge", {
4276
+ /**
4277
+ * A Boolean value indicating whether Camera's over the minimum or maximum position reachable
4278
+ * @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
4279
+ * @type {boolean}
4280
+ * @readonly
4281
+ */
4282
+ get: function () {
4283
+ return this._position <= this._range.min || this._position >= this._range.max;
4284
+ },
4285
+ enumerable: false,
4286
+ configurable: true
4287
+ });
4288
+ Object.defineProperty(__proto, "size", {
4289
+ /**
4290
+ * Return the size of the viewport
4291
+ * @ko 뷰포트 크기를 반환합니다
4292
+ * @type {number}
4293
+ * @readonly
4294
+ */
4295
+ get: function () {
4296
+ var flicking = this._flicking;
4297
+ return flicking ? flicking.horizontal ? flicking.viewport.width : flicking.viewport.height : 0;
4298
+ },
4299
+ enumerable: false,
4300
+ configurable: true
4301
+ });
4302
+ Object.defineProperty(__proto, "progress", {
4303
+ /**
4304
+ * Return the camera's position progress from the first panel to last panel
4305
+ * Range is from 0 to last panel's index
4306
+ * @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
4307
+ * 범위는 0부터 마지막 패널의 인덱스까지입니다
4308
+ * @type {number}
4309
+ * @readonly
4310
+ */
4311
+ get: function () {
4312
+ var flicking = this._flicking;
4313
+ var position = this._position + this._offset;
4314
+ var nearestAnchor = this.findNearestAnchor(this._position);
4223
4315
 
4224
- if (added.length > 0 || removed.length > 0) {
4225
- void flicking.renderer.render().then(function () {
4226
- flicking.trigger(new ComponentEvent(EVENTS.VISIBLE_CHANGE, {
4227
- added: added,
4228
- removed: removed,
4229
- visiblePanels: newVisiblePanels
4230
- }));
4231
- });
4232
- }
4233
- };
4316
+ if (!flicking || !nearestAnchor) {
4317
+ return NaN;
4318
+ }
4234
4319
 
4235
- __proto._checkNeedPanel = function () {
4236
- var needPanelTriggered = this._needPanelTriggered;
4237
- if (needPanelTriggered.prev && needPanelTriggered.next) return;
4238
- var flicking = getFlickingAttached(this._flicking);
4239
- var panels = flicking.renderer.panels;
4320
+ var nearestPanel = nearestAnchor.panel;
4321
+ var panelPos = nearestPanel.position + nearestPanel.offset;
4322
+ var bounceSize = flicking.control.controller.bounce;
4323
+ var _a = this.range,
4324
+ prevRange = _a.min,
4325
+ nextRange = _a.max;
4326
+ var rangeDiff = this.rangeDiff;
4240
4327
 
4241
- if (panels.length <= 0) {
4242
- if (!needPanelTriggered.prev) {
4243
- flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4244
- direction: DIRECTION.PREV
4245
- }));
4246
- needPanelTriggered.prev = true;
4328
+ if (position === panelPos) {
4329
+ return nearestPanel.index;
4247
4330
  }
4248
4331
 
4249
- if (!needPanelTriggered.next) {
4250
- flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4251
- direction: DIRECTION.NEXT
4252
- }));
4253
- needPanelTriggered.next = true;
4254
- }
4332
+ if (position < panelPos) {
4333
+ var prevPanel = nearestPanel.prev();
4334
+ var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
4255
4335
 
4256
- return;
4257
- }
4336
+ if (prevPosition > panelPos) {
4337
+ prevPosition -= rangeDiff;
4338
+ }
4258
4339
 
4259
- var cameraPosition = this._position;
4260
- var cameraSize = this.size;
4261
- var cameraRange = this._range;
4262
- var needPanelThreshold = flicking.needPanelThreshold;
4263
- var cameraPrev = cameraPosition - this._alignPos;
4264
- var cameraNext = cameraPrev + cameraSize;
4265
- var firstPanel = panels[0];
4266
- var lastPanel = panels[panels.length - 1];
4340
+ return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
4341
+ } else {
4342
+ var nextPanel = nearestPanel.next();
4343
+ var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1]; // Looped
4267
4344
 
4268
- if (!needPanelTriggered.prev) {
4269
- var firstPanelPrev = firstPanel.range.min;
4345
+ if (nextPosition < panelPos) {
4346
+ nextPosition += rangeDiff;
4347
+ }
4270
4348
 
4271
- if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
4272
- flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4273
- direction: DIRECTION.PREV
4274
- }));
4275
- needPanelTriggered.prev = true;
4349
+ return nearestPanel.index + getProgress(position, panelPos, nextPosition);
4276
4350
  }
4277
- }
4351
+ },
4352
+ enumerable: false,
4353
+ configurable: true
4354
+ });
4355
+ Object.defineProperty(__proto, "align", {
4356
+ // Options Getter
4278
4357
 
4279
- if (!needPanelTriggered.next) {
4280
- var lastPanelNext = lastPanel.range.max;
4358
+ /**
4359
+ * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
4360
+ * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
4361
+ * @type {ALIGN | string | number}
4362
+ */
4363
+ get: function () {
4364
+ return this._align;
4365
+ },
4366
+ // Options Setter
4367
+ set: function (val) {
4368
+ this._align = val;
4369
+ },
4370
+ enumerable: false,
4371
+ configurable: true
4372
+ });
4373
+ /**
4374
+ * Initialize Camera
4375
+ * @ko Camera를 초기화합니다
4376
+ * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
4377
+ * @chainable
4378
+ * @throws {FlickingError}
4379
+ * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
4380
+ * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
4381
+ * @return {this}
4382
+ */
4281
4383
 
4282
- if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
4283
- flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4284
- direction: DIRECTION.NEXT
4285
- }));
4286
- needPanelTriggered.next = true;
4287
- }
4288
- }
4289
- };
4384
+ __proto.init = function (flicking) {
4385
+ this._flicking = flicking;
4386
+ var viewportEl = flicking.viewport.element;
4387
+ checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
4388
+ this._el = viewportEl.firstElementChild;
4290
4389
 
4291
- __proto._checkReachEnd = function (prevPos, newPos) {
4292
- var flicking = getFlickingAttached(this._flicking);
4293
- var range = this._range;
4294
- var wasBetweenRange = prevPos > range.min && prevPos < range.max;
4295
- var isBetweenRange = newPos > range.min && newPos < range.max;
4296
- if (!wasBetweenRange || isBetweenRange) return;
4297
- var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
4298
- flicking.trigger(new ComponentEvent(EVENTS.REACH_EDGE, {
4299
- direction: direction
4300
- }));
4390
+ this._checkTranslateSupport();
4391
+
4392
+ this._updateMode();
4393
+
4394
+ return this;
4301
4395
  };
4396
+ /**
4397
+ * Destroy Camera and return to initial state
4398
+ * @ko Camera를 초기 상태로 되돌립니다
4399
+ * @return {void}
4400
+ */
4302
4401
 
4303
- return Camera;
4304
- }();
4305
4402
 
4306
- /**
4307
- * A {@link Camera} that can move from the position of the first panel to the position of the last panel
4308
- * @ko 첫번째 패널의 좌표로부터 마지막 패널의 좌표로까지 이동할 수 있는 종류의 {@link Camera}
4309
- */
4403
+ __proto.destroy = function () {
4404
+ this._flicking = null;
4310
4405
 
4311
- var LinearCamera =
4312
- /*#__PURE__*/
4313
- function (_super) {
4314
- __extends(LinearCamera, _super);
4406
+ this._resetInternalValues();
4315
4407
 
4316
- function LinearCamera() {
4317
- return _super !== null && _super.apply(this, arguments) || this;
4318
- }
4408
+ return this;
4409
+ };
4319
4410
  /**
4320
- * Update {@link Camera#range range} of Camera
4321
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4322
- * @chainable
4411
+ * Move to the given position and apply CSS transform
4412
+ * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
4413
+ * @param {number} pos A new position<ko>움직일 위치</ko>
4323
4414
  * @throws {FlickingError}
4324
4415
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4325
4416
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -4327,170 +4418,190 @@ function (_super) {
4327
4418
  */
4328
4419
 
4329
4420
 
4330
- var __proto = LinearCamera.prototype;
4331
-
4332
- __proto.updateRange = function () {
4333
- var _a, _b;
4421
+ __proto.lookAt = function (pos) {
4422
+ var _this = this;
4334
4423
 
4335
4424
  var flicking = getFlickingAttached(this._flicking);
4336
- var renderer = flicking.renderer;
4337
- var firstPanel = renderer.getPanel(0);
4338
- var lastPanel = renderer.getPanel(renderer.panelCount - 1);
4339
- this._range = {
4340
- min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
4341
- max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
4342
- };
4343
- return this;
4344
- };
4425
+ var prevPos = this._position;
4426
+ this._position = pos;
4345
4427
 
4346
- return LinearCamera;
4347
- }(Camera);
4428
+ var toggled = this._togglePanels(prevPos, pos);
4348
4429
 
4349
- /**
4350
- * A {@link Camera} that connects the last panel and the first panel, enabling continuous loop
4351
- * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera}
4352
- */
4430
+ this._refreshVisiblePanels();
4353
4431
 
4354
- var CircularCamera =
4355
- /*#__PURE__*/
4356
- function (_super) {
4357
- __extends(CircularCamera, _super);
4432
+ this._checkNeedPanel();
4358
4433
 
4359
- function CircularCamera() {
4360
- var _this = _super !== null && _super.apply(this, arguments) || this;
4434
+ this._checkReachEnd(prevPos, pos);
4361
4435
 
4362
- _this._circularOffset = 0;
4363
- _this._circularEnabled = false;
4364
- return _this;
4365
- }
4436
+ this.applyTransform();
4437
+
4438
+ if (toggled) {
4439
+ void flicking.renderer.render().then(function () {
4440
+ _this.updateOffset();
4441
+ });
4442
+ }
4443
+ };
4444
+ /**
4445
+ * Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
4446
+ * If it does not exist, return `null` instead
4447
+ * @ko 주어진 {@link AnchorPoint}의 이전 {@link AnchorPoint}를 반환합니다
4448
+ * 존재하지 않을 경우 `null`을 반환합니다
4449
+ * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
4450
+ * @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
4451
+ */
4366
4452
 
4367
- var __proto = CircularCamera.prototype;
4368
- Object.defineProperty(__proto, "offset", {
4369
- get: function () {
4370
- return this._offset - this._circularOffset;
4371
- },
4372
- enumerable: false,
4373
- configurable: true
4374
- });
4375
- Object.defineProperty(__proto, "controlParams", {
4376
- get: function () {
4377
- return {
4378
- range: this._range,
4379
- position: this._position,
4380
- circular: this._circularEnabled
4381
- };
4382
- },
4383
- enumerable: false,
4384
- configurable: true
4385
- });
4386
4453
 
4387
4454
  __proto.getPrevAnchor = function (anchor) {
4388
- if (!this._circularEnabled || anchor.index !== 0) return _super.prototype.getPrevAnchor.call(this, anchor);
4455
+ if (!this._circularEnabled || anchor.index !== 0) {
4456
+ return this._anchors[anchor.index - 1] || null;
4457
+ } else {
4458
+ var anchors = this._anchors;
4459
+ var rangeDiff = this.rangeDiff;
4460
+ var lastAnchor = anchors[anchors.length - 1];
4461
+ return new AnchorPoint({
4462
+ index: lastAnchor.index,
4463
+ position: lastAnchor.position - rangeDiff,
4464
+ panel: lastAnchor.panel
4465
+ });
4466
+ }
4467
+ };
4468
+ /**
4469
+ * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
4470
+ * If it does not exist, return `null` instead
4471
+ * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
4472
+ * 존재하지 않을 경우 `null`을 반환합니다
4473
+ * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
4474
+ * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
4475
+ */
4476
+
4477
+
4478
+ __proto.getNextAnchor = function (anchor) {
4389
4479
  var anchors = this._anchors;
4390
- var rangeDiff = this.rangeDiff;
4391
- var lastAnchor = anchors[anchors.length - 1];
4392
- return new AnchorPoint({
4393
- index: lastAnchor.index,
4394
- position: lastAnchor.position - rangeDiff,
4395
- panel: lastAnchor.panel
4396
- });
4480
+
4481
+ if (!this._circularEnabled || anchor.index !== anchors.length - 1) {
4482
+ return anchors[anchor.index + 1] || null;
4483
+ } else {
4484
+ var rangeDiff = this.rangeDiff;
4485
+ var firstAnchor = anchors[0];
4486
+ return new AnchorPoint({
4487
+ index: firstAnchor.index,
4488
+ position: firstAnchor.position + rangeDiff,
4489
+ panel: firstAnchor.panel
4490
+ });
4491
+ }
4397
4492
  };
4493
+ /**
4494
+ * Return the camera's position progress in the panel below
4495
+ * Value is from 0 to 1 when the camera's inside panel
4496
+ * Value can be lower than 0 or bigger than 1 when it's in the margin area
4497
+ * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
4498
+ * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
4499
+ * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
4500
+ */
4398
4501
 
4399
- __proto.getNextAnchor = function (anchor) {
4400
- var anchors = this._anchors;
4401
- if (!this._circularEnabled || anchor.index !== anchors.length - 1) return _super.prototype.getNextAnchor.call(this, anchor);
4402
- var rangeDiff = this.rangeDiff;
4403
- var firstAnchor = anchors[0];
4404
- return new AnchorPoint({
4405
- index: firstAnchor.index,
4406
- position: firstAnchor.position + rangeDiff,
4407
- panel: firstAnchor.panel
4408
- });
4502
+
4503
+ __proto.getProgressInPanel = function (panel) {
4504
+ var panelRange = panel.range;
4505
+ return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
4409
4506
  };
4507
+ /**
4508
+ * Return {@link AnchorPoint} that includes given position
4509
+ * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
4510
+ * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
4511
+ * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
4512
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
4513
+ * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
4514
+ */
4515
+
4410
4516
 
4411
4517
  __proto.findAnchorIncludePosition = function (position) {
4412
- if (!this._circularEnabled) return _super.prototype.findAnchorIncludePosition.call(this, position);
4413
- var range = this._range;
4518
+ return this._mode.findAnchorIncludePosition(position);
4519
+ };
4520
+ /**
4521
+ * Return {@link AnchorPoint} nearest to given position
4522
+ * If there're no {@link AnchorPoint}s, return `null` instead
4523
+ * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
4524
+ * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
4525
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
4526
+ * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
4527
+ */
4528
+
4529
+
4530
+ __proto.findNearestAnchor = function (position) {
4414
4531
  var anchors = this._anchors;
4415
- var rangeDiff = this.rangeDiff;
4416
- var anchorCount = anchors.length;
4417
- var positionInRange = circulatePosition(position, range.min, range.max);
4532
+ if (anchors.length <= 0) return null;
4533
+ var prevDist = Infinity;
4418
4534
 
4419
- var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
4535
+ for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
4536
+ var anchor = anchors[anchorIdx];
4537
+ var dist = Math.abs(anchor.position - position);
4420
4538
 
4421
- if (anchorCount > 0 && (position === range.min || position === range.max)) {
4422
- var possibleAnchors = [anchorInRange, new AnchorPoint({
4423
- index: 0,
4424
- position: anchors[0].position + rangeDiff,
4425
- panel: anchors[0].panel
4426
- }), new AnchorPoint({
4427
- index: anchorCount - 1,
4428
- position: anchors[anchorCount - 1].position - rangeDiff,
4429
- panel: anchors[anchorCount - 1].panel
4430
- })].filter(function (anchor) {
4431
- return !!anchor;
4432
- });
4433
- anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
4434
- if (!nearest) return anchor;
4435
- return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
4436
- }, null);
4437
- }
4539
+ if (dist > prevDist) {
4540
+ // Return previous anchor
4541
+ return anchors[anchorIdx - 1];
4542
+ }
4438
4543
 
4439
- if (!anchorInRange) return null;
4544
+ prevDist = dist;
4545
+ } // Return last anchor
4440
4546
 
4441
- if (position < range.min) {
4442
- var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
4443
- return new AnchorPoint({
4444
- index: anchorInRange.index,
4445
- position: anchorInRange.position + rangeDiff * loopCount,
4446
- panel: anchorInRange.panel
4447
- });
4448
- } else if (position > range.max) {
4449
- var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
4450
- return new AnchorPoint({
4451
- index: anchorInRange.index,
4452
- position: anchorInRange.position + rangeDiff * loopCount,
4453
- panel: anchorInRange.panel
4454
- });
4455
- }
4456
4547
 
4457
- return anchorInRange;
4548
+ return anchors[anchors.length - 1];
4458
4549
  };
4550
+ /**
4551
+ * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
4552
+ * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
4553
+ * @return {AnchorPoint | null}
4554
+ */
4459
4555
 
4460
- __proto.clampToReachablePosition = function (position) {
4461
- // Basically all position is reachable for circular camera
4462
- return this._circularEnabled ? position : _super.prototype.clampToReachablePosition.call(this, position);
4463
- };
4464
4556
 
4465
- __proto.canReach = function (panel) {
4466
- if (panel.removed) return false;
4467
- return this._circularEnabled // Always reachable on circular mode
4468
- ? true : _super.prototype.canReach.call(this, panel);
4557
+ __proto.findActiveAnchor = function () {
4558
+ var flicking = getFlickingAttached(this._flicking);
4559
+ var activeIndex = flicking.control.activeIndex;
4560
+ return find(this._anchors, function (anchor) {
4561
+ return anchor.panel.index === activeIndex;
4562
+ });
4469
4563
  };
4564
+ /**
4565
+ * Clamp the given position between camera's range
4566
+ * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
4567
+ * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
4568
+ * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
4569
+ */
4470
4570
 
4471
- __proto.canSee = function (panel) {
4472
- var range = this._range;
4473
- var rangeDiff = this.rangeDiff;
4474
- var visibleRange = this.visibleRange;
4475
4571
 
4476
- var visibleInCurrentRange = _super.prototype.canSee.call(this, panel);
4572
+ __proto.clampToReachablePosition = function (position) {
4573
+ return this._mode.clampToReachablePosition(position);
4574
+ };
4575
+ /**
4576
+ * Check whether the given panel is inside of the Camera's range
4577
+ * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
4578
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4579
+ * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
4580
+ */
4477
4581
 
4478
- if (!this._circularEnabled) {
4479
- return visibleInCurrentRange;
4480
- } // Check looped visible area for circular case
4481
4582
 
4583
+ __proto.canReach = function (panel) {
4584
+ return this._mode.canReach(panel);
4585
+ };
4586
+ /**
4587
+ * Check whether the given panel element is visible at the current position
4588
+ * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
4589
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4590
+ * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
4591
+ */
4482
4592
 
4483
- if (visibleRange.min < range.min) {
4484
- return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
4485
- } else if (visibleRange.max > range.max) {
4486
- return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
4487
- }
4488
4593
 
4489
- return visibleInCurrentRange;
4594
+ __proto.canSee = function (panel) {
4595
+ return this._mode.canSee(panel);
4490
4596
  };
4491
4597
  /**
4492
4598
  * Update {@link Camera#range range} of Camera
4493
4599
  * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4600
+ * @method
4601
+ * @abstract
4602
+ * @memberof Camera
4603
+ * @instance
4604
+ * @name updateRange
4494
4605
  * @chainable
4495
4606
  * @throws {FlickingError}
4496
4607
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
@@ -4504,287 +4615,269 @@ function (_super) {
4504
4615
  var renderer = flicking.renderer;
4505
4616
  var panels = renderer.panels;
4506
4617
 
4507
- if (panels.length <= 0) {
4508
- this._resetInternalValues();
4509
-
4510
- return this;
4511
- }
4618
+ this._updateMode();
4512
4619
 
4513
- var firstPanel = panels[0];
4514
- var lastPanel = panels[panels.length - 1];
4515
- var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
4516
- var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
4517
- var visibleSize = this.size;
4518
- var panelSizeSum = lastPanelNext - firstPanelPrev;
4519
- var canSetCircularMode = panels.every(function (panel) {
4520
- return panelSizeSum - panel.size >= visibleSize;
4521
- });
4522
- this._circularEnabled = canSetCircularMode;
4620
+ this._range = this._mode.getRange();
4523
4621
 
4524
- if (canSetCircularMode) {
4525
- this._range = {
4526
- min: firstPanelPrev,
4527
- max: lastPanelNext
4528
- };
4622
+ if (this._circularEnabled) {
4529
4623
  panels.forEach(function (panel) {
4530
4624
  return panel.updateCircularToggleDirection();
4531
4625
  });
4532
- } else {
4533
- this._range = {
4534
- min: firstPanel.position,
4535
- max: lastPanel.position
4536
- };
4537
4626
  }
4538
4627
 
4539
4628
  this.updateOffset();
4540
4629
  return this;
4541
4630
  };
4631
+ /**
4632
+ * Update Camera's {@link Camera#alignPosition alignPosition}
4633
+ * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
4634
+ * @chainable
4635
+ * @return {this}
4636
+ */
4542
4637
 
4543
- __proto.updateOffset = function () {
4544
- this._updateCircularOffset();
4545
4638
 
4546
- return _super.prototype.updateOffset.call(this);
4639
+ __proto.updateAlignPos = function () {
4640
+ var align = this._align;
4641
+ var alignVal = typeof align === "object" ? align.camera : align;
4642
+ this._alignPos = parseAlign$1(alignVal, this.size);
4643
+ return this;
4547
4644
  };
4645
+ /**
4646
+ * Update Camera's {@link Camera#anchorPoints anchorPoints}
4647
+ * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
4648
+ * @throws {FlickingError}
4649
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4650
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4651
+ * @chainable
4652
+ * @return {this}
4653
+ */
4548
4654
 
4549
- __proto.lookAt = function (pos) {
4550
- var _this = this;
4551
-
4552
- var flicking = getFlickingAttached(this._flicking);
4553
- var prevPos = this._position;
4554
- if (pos === prevPos) return _super.prototype.lookAt.call(this, pos);
4555
- var panels = flicking.renderer.panels;
4556
- var toggled = panels.map(function (panel) {
4557
- return panel.toggle(prevPos, pos);
4558
- });
4559
- this._position = pos;
4560
-
4561
- _super.prototype.lookAt.call(this, pos);
4562
-
4563
- if (toggled.some(function (isToggled) {
4564
- return isToggled;
4565
- })) {
4566
- void flicking.renderer.render().then(function () {
4567
- _this.updateOffset();
4568
- });
4569
- }
4570
- };
4571
4655
 
4572
- __proto.applyTransform = function () {
4573
- var el = this._el;
4574
- var flicking = getFlickingAttached(this._flicking);
4575
- var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4576
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4656
+ __proto.updateAnchors = function () {
4657
+ this._anchors = this._mode.getAnchors();
4577
4658
  return this;
4578
4659
  };
4660
+ /**
4661
+ * Update Viewport's height to active panel's height
4662
+ * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4663
+ * @throws {FlickingError}
4664
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4665
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4666
+ * @chainable
4667
+ * @return {this}
4668
+ */
4579
4669
 
4580
- __proto._resetInternalValues = function () {
4581
- _super.prototype._resetInternalValues.call(this);
4582
-
4583
- this._circularOffset = 0;
4584
- this._circularEnabled = false;
4585
- };
4586
4670
 
4587
- __proto._calcPanelAreaSum = function (panels) {
4588
- return panels.reduce(function (sum, panel) {
4589
- return sum + panel.sizeIncludingMargin;
4590
- }, 0);
4671
+ __proto.updateAdaptiveHeight = function () {
4672
+ var flicking = getFlickingAttached(this._flicking);
4673
+ var activePanel = flicking.control.activePanel;
4674
+ if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4675
+ flicking.viewport.setSize({
4676
+ height: activePanel.height
4677
+ });
4591
4678
  };
4679
+ /**
4680
+ * Update current offset of the camera
4681
+ * @ko 현재 카메라의 오프셋을 업데이트합니다
4682
+ * @chainable
4683
+ * @return {this}
4684
+ */
4592
4685
 
4593
- __proto._updateCircularOffset = function () {
4594
- if (!this._circularEnabled) {
4595
- this._circularOffset = 0;
4596
- return;
4597
- }
4598
4686
 
4687
+ __proto.updateOffset = function () {
4599
4688
  var flicking = getFlickingAttached(this._flicking);
4600
- var toggled = flicking.panels.filter(function (panel) {
4601
- return panel.toggled;
4602
- });
4603
- var toggledPrev = toggled.filter(function (panel) {
4604
- return panel.toggleDirection === DIRECTION.PREV;
4605
- });
4606
- var toggledNext = toggled.filter(function (panel) {
4607
- return panel.toggleDirection === DIRECTION.NEXT;
4689
+ var position = this._position;
4690
+ var unRenderedPanels = flicking.panels.filter(function (panel) {
4691
+ return !panel.rendered;
4608
4692
  });
4609
- this._circularOffset = this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
4693
+ this._offset = unRenderedPanels.filter(function (panel) {
4694
+ return panel.position + panel.offset < position;
4695
+ }).reduce(function (offset, panel) {
4696
+ return offset + panel.sizeIncludingMargin;
4697
+ }, 0);
4698
+ this._circularOffset = this._mode.getCircularOffset();
4699
+ this.applyTransform();
4700
+ return this;
4610
4701
  };
4702
+ /**
4703
+ * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4704
+ * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
4705
+ * @chainable
4706
+ * @return {this}
4707
+ */
4611
4708
 
4612
- return CircularCamera;
4613
- }(Camera);
4614
-
4615
- /**
4616
- * A {@link Camera} that set range not to go out of the first/last panel, so it won't show empty spaces before/after the first/last panel
4617
- * @ko 첫번째와 마지막 패널 밖으로 넘어가지 못하도록 범위를 설정하여, 첫번째/마지막 패널 전/후의 빈 공간을 보이지 않도록 하는 종류의 {@link Camera}
4618
- */
4619
-
4620
- var BoundCamera =
4621
- /*#__PURE__*/
4622
- function (_super) {
4623
- __extends(BoundCamera, _super);
4624
4709
 
4625
- function BoundCamera() {
4626
- return _super !== null && _super.apply(this, arguments) || this;
4627
- }
4710
+ __proto.resetNeedPanelHistory = function () {
4711
+ this._needPanelTriggered = {
4712
+ prev: false,
4713
+ next: false
4714
+ };
4715
+ return this;
4716
+ };
4628
4717
  /**
4629
- * Update {@link Camera#range range} of Camera
4630
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4718
+ * Apply "transform" style with the current position to camera element
4719
+ * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
4631
4720
  * @chainable
4632
- * @throws {FlickingError}
4633
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4634
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4635
4721
  * @return {this}
4636
4722
  */
4637
4723
 
4638
4724
 
4639
- var __proto = BoundCamera.prototype;
4640
-
4641
- __proto.updateRange = function () {
4725
+ __proto.applyTransform = function () {
4726
+ var el = this._el;
4642
4727
  var flicking = getFlickingAttached(this._flicking);
4643
- var renderer = flicking.renderer;
4644
- var alignPos = this._alignPos;
4645
- var firstPanel = renderer.getPanel(0);
4646
- var lastPanel = renderer.getPanel(renderer.panelCount - 1);
4647
-
4648
- if (!firstPanel || !lastPanel) {
4649
- this._range = {
4650
- min: 0,
4651
- max: 0
4652
- };
4653
- return this;
4654
- }
4655
-
4656
- var viewportSize = this.size;
4657
- var firstPanelPrev = firstPanel.range.min;
4658
- var lastPanelNext = lastPanel.range.max;
4659
- var panelAreaSize = lastPanelNext - firstPanelPrev;
4660
- var isBiggerThanViewport = viewportSize < panelAreaSize;
4661
- var firstPos = firstPanelPrev + alignPos;
4662
- var lastPos = lastPanelNext - viewportSize + alignPos;
4663
-
4664
- if (isBiggerThanViewport) {
4665
- this._range = {
4666
- min: firstPos,
4667
- max: lastPos
4668
- };
4669
- } else {
4670
- var align = this._align;
4671
- var alignVal = typeof align === "object" ? align.camera : align;
4672
- var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
4673
- this._range = {
4674
- min: pos,
4675
- max: pos
4676
- };
4677
- }
4678
-
4728
+ var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4729
+ el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4679
4730
  return this;
4680
4731
  };
4681
4732
 
4682
- __proto.updateAnchors = function () {
4733
+ __proto._resetInternalValues = function () {
4734
+ this._position = 0;
4735
+ this._alignPos = 0;
4736
+ this._offset = 0;
4737
+ this._circularOffset = 0;
4738
+ this._circularEnabled = false;
4739
+ this._range = {
4740
+ min: 0,
4741
+ max: 0
4742
+ };
4743
+ this._visiblePanels = [];
4744
+ this._anchors = [];
4745
+ this._needPanelTriggered = {
4746
+ prev: false,
4747
+ next: false
4748
+ };
4749
+ };
4750
+
4751
+ __proto._refreshVisiblePanels = function () {
4683
4752
  var _this = this;
4684
4753
 
4685
4754
  var flicking = getFlickingAttached(this._flicking);
4686
4755
  var panels = flicking.renderer.panels;
4687
-
4688
- if (panels.length <= 0) {
4689
- this._anchors = [];
4690
- return this;
4691
- }
4692
-
4693
- var range = this._range;
4694
- var reachablePanels = panels.filter(function (panel) {
4695
- return _this.canReach(panel);
4756
+ var newVisiblePanels = panels.filter(function (panel) {
4757
+ return _this.canSee(panel);
4758
+ });
4759
+ var prevVisiblePanels = this._visiblePanels;
4760
+ this._visiblePanels = newVisiblePanels;
4761
+ var added = newVisiblePanels.filter(function (panel) {
4762
+ return !includes(prevVisiblePanels, panel);
4763
+ });
4764
+ var removed = prevVisiblePanels.filter(function (panel) {
4765
+ return !includes(newVisiblePanels, panel);
4696
4766
  });
4697
4767
 
4698
- if (reachablePanels.length > 0) {
4699
- var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
4700
- var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
4701
- var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
4702
- var newAnchors = reachablePanels.map(function (panel, idx) {
4703
- return new AnchorPoint({
4704
- index: idx + indexOffset_1,
4705
- position: panel.position,
4706
- panel: panel
4707
- });
4768
+ if (added.length > 0 || removed.length > 0) {
4769
+ void flicking.renderer.render().then(function () {
4770
+ flicking.trigger(new ComponentEvent(EVENTS.VISIBLE_CHANGE, {
4771
+ added: added,
4772
+ removed: removed,
4773
+ visiblePanels: newVisiblePanels
4774
+ }));
4708
4775
  });
4776
+ }
4777
+ };
4709
4778
 
4710
- if (shouldPrependBoundAnchor) {
4711
- newAnchors.splice(0, 0, new AnchorPoint({
4712
- index: 0,
4713
- position: range.min,
4714
- panel: panels[reachablePanels[0].index - 1]
4779
+ __proto._checkNeedPanel = function () {
4780
+ var needPanelTriggered = this._needPanelTriggered;
4781
+ if (needPanelTriggered.prev && needPanelTriggered.next) return;
4782
+ var flicking = getFlickingAttached(this._flicking);
4783
+ var panels = flicking.renderer.panels;
4784
+
4785
+ if (panels.length <= 0) {
4786
+ if (!needPanelTriggered.prev) {
4787
+ flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4788
+ direction: DIRECTION.PREV
4715
4789
  }));
4790
+ needPanelTriggered.prev = true;
4716
4791
  }
4717
4792
 
4718
- if (shouldAppendBoundAnchor) {
4719
- newAnchors.push(new AnchorPoint({
4720
- index: newAnchors.length,
4721
- position: range.max,
4722
- panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
4793
+ if (!needPanelTriggered.next) {
4794
+ flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4795
+ direction: DIRECTION.NEXT
4723
4796
  }));
4797
+ needPanelTriggered.next = true;
4724
4798
  }
4725
4799
 
4726
- this._anchors = newAnchors;
4727
- } else if (range.min !== range.max) {
4728
- // There're more than 2 panels
4729
- var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
4800
+ return;
4801
+ }
4730
4802
 
4731
- var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
4732
- var panelAtMax = panelAtMin.next();
4733
- this._anchors = [new AnchorPoint({
4734
- index: 0,
4735
- position: range.min,
4736
- panel: panelAtMin
4737
- }), new AnchorPoint({
4738
- index: 1,
4739
- position: range.max,
4740
- panel: panelAtMax
4741
- })];
4742
- } else {
4743
- this._anchors = [new AnchorPoint({
4744
- index: 0,
4745
- position: range.min,
4746
- panel: this._findNearestPanel(range.min, panels)
4747
- })];
4803
+ var cameraPosition = this._position;
4804
+ var cameraSize = this.size;
4805
+ var cameraRange = this._range;
4806
+ var needPanelThreshold = flicking.needPanelThreshold;
4807
+ var cameraPrev = cameraPosition - this._alignPos;
4808
+ var cameraNext = cameraPrev + cameraSize;
4809
+ var firstPanel = panels[0];
4810
+ var lastPanel = panels[panels.length - 1];
4811
+
4812
+ if (!needPanelTriggered.prev) {
4813
+ var firstPanelPrev = firstPanel.range.min;
4814
+
4815
+ if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
4816
+ flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4817
+ direction: DIRECTION.PREV
4818
+ }));
4819
+ needPanelTriggered.prev = true;
4820
+ }
4748
4821
  }
4749
4822
 
4750
- return this;
4823
+ if (!needPanelTriggered.next) {
4824
+ var lastPanelNext = lastPanel.range.max;
4825
+
4826
+ if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
4827
+ flicking.trigger(new ComponentEvent(EVENTS.NEED_PANEL, {
4828
+ direction: DIRECTION.NEXT
4829
+ }));
4830
+ needPanelTriggered.next = true;
4831
+ }
4832
+ }
4751
4833
  };
4752
4834
 
4753
- __proto.findAnchorIncludePosition = function (position) {
4835
+ __proto._checkReachEnd = function (prevPos, newPos) {
4836
+ var flicking = getFlickingAttached(this._flicking);
4754
4837
  var range = this._range;
4755
- var anchors = this._anchors;
4756
- if (anchors.length <= 0) return null;
4757
-
4758
- if (position <= range.min) {
4759
- return anchors[0];
4760
- } else if (position >= range.max) {
4761
- return anchors[anchors.length - 1];
4762
- } else {
4763
- return _super.prototype.findAnchorIncludePosition.call(this, position);
4764
- }
4838
+ var wasBetweenRange = prevPos > range.min && prevPos < range.max;
4839
+ var isBetweenRange = newPos > range.min && newPos < range.max;
4840
+ if (!wasBetweenRange || isBetweenRange) return;
4841
+ var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
4842
+ flicking.trigger(new ComponentEvent(EVENTS.REACH_EDGE, {
4843
+ direction: direction
4844
+ }));
4765
4845
  };
4766
4846
 
4767
- __proto._findNearestPanel = function (pos, panels) {
4768
- var prevDist = Infinity;
4847
+ __proto._updateMode = function () {
4848
+ var flicking = getFlickingAttached(this._flicking);
4769
4849
 
4770
- for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
4771
- var panel = panels[panelIdx];
4772
- var dist = Math.abs(panel.position - pos);
4850
+ if (flicking.circular) {
4851
+ var circularMode = new CircularCameraMode(flicking);
4852
+ var canSetCircularMode = circularMode.checkAvailability();
4773
4853
 
4774
- if (dist > prevDist) {
4775
- // Return previous anchor
4776
- return panels[panelIdx - 1];
4854
+ if (canSetCircularMode) {
4855
+ this._mode = circularMode;
4856
+ } else {
4857
+ var fallbackMode = flicking.circularFallback;
4858
+ this._mode = fallbackMode === CIRCULAR_FALLBACK.BOUND ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
4777
4859
  }
4778
4860
 
4779
- prevDist = dist;
4780
- } // Return last anchor
4781
-
4861
+ this._circularEnabled = canSetCircularMode;
4862
+ } else {
4863
+ this._mode = flicking.bound ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
4864
+ }
4865
+ };
4782
4866
 
4783
- return panels[panels.length - 1];
4867
+ __proto._togglePanels = function (prevPos, pos) {
4868
+ if (pos === prevPos) return false;
4869
+ var flicking = getFlickingAttached(this._flicking);
4870
+ var panels = flicking.renderer.panels;
4871
+ var toggled = panels.map(function (panel) {
4872
+ return panel.toggle(prevPos, pos);
4873
+ });
4874
+ return toggled.some(function (isToggled) {
4875
+ return isToggled;
4876
+ });
4784
4877
  };
4785
4878
 
4786
- return BoundCamera;
4787
- }(Camera);
4879
+ return Camera;
4880
+ }();
4788
4881
 
4789
4882
  /**
4790
4883
  * A component that manages {@link Panel} and its elements
@@ -4983,7 +5076,7 @@ function () {
4983
5076
  flicking: flicking
4984
5077
  });
4985
5078
  });
4986
- panels.splice.apply(panels, __spreadArray([insertingIdx, 0], __read(panelsInserted)));
5079
+ panels.splice.apply(panels, __spread([insertingIdx, 0], panelsInserted));
4987
5080
 
4988
5081
  if (item.hasDOMInElements) {
4989
5082
  // Insert the actual elements as camera element's children
@@ -5006,7 +5099,7 @@ function () {
5006
5099
  panel.increaseIndex(panelsInserted.length);
5007
5100
  panel.updatePosition();
5008
5101
  });
5009
- return __spreadArray(__spreadArray([], __read(addedPanels), false), __read(panelsInserted));
5102
+ return __spread(addedPanels, panelsInserted);
5010
5103
  }, []);
5011
5104
  if (allPanelsInserted.length <= 0) return []; // Update camera & control
5012
5105
 
@@ -5085,7 +5178,7 @@ function () {
5085
5178
  control.resetActive();
5086
5179
  }
5087
5180
 
5088
- return __spreadArray(__spreadArray([], __read(removed), false), __read(panelsRemoved));
5181
+ return __spread(removed, panelsRemoved);
5089
5182
  }, []); // Update camera & control
5090
5183
 
5091
5184
  this._updateCameraAndControl();
@@ -6084,7 +6177,7 @@ function () {
6084
6177
  var notToggled = renderedPanels.filter(function (panel) {
6085
6178
  return !panel.toggled;
6086
6179
  });
6087
- return __spreadArray(__spreadArray(__spreadArray([], __read(toggledPrev), false), __read(notToggled), false), __read(toggledNext)).map(function (panel) {
6180
+ return __spread(toggledPrev, notToggled, toggledNext).map(function (panel) {
6088
6181
  return panel.index;
6089
6182
  });
6090
6183
  };
@@ -6294,7 +6387,7 @@ function () {
6294
6387
  __proto.getRenderingIndexesByOrder = function (flicking) {
6295
6388
  var virtualManager = flicking.virtual;
6296
6389
 
6297
- var visiblePanels = __spreadArray([], __read(flicking.visiblePanels)).filter(function (panel) {
6390
+ var visiblePanels = __spread(flicking.visiblePanels).filter(function (panel) {
6298
6391
  return panel.rendered;
6299
6392
  }).sort(function (panel1, panel2) {
6300
6393
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
@@ -6315,7 +6408,7 @@ function () {
6315
6408
  }).map(function (el) {
6316
6409
  return el.idx;
6317
6410
  });
6318
- return __spreadArray(__spreadArray([], __read(visibleIndexes), false), __read(invisibleIndexes));
6411
+ return __spread(visibleIndexes, invisibleIndexes);
6319
6412
  };
6320
6413
 
6321
6414
  __proto.getRenderingElementsByOrder = function (flicking) {
@@ -6424,58 +6517,60 @@ function (_super) {
6424
6517
  horizontal = _e === void 0 ? true : _e,
6425
6518
  _f = _b.circular,
6426
6519
  circular = _f === void 0 ? false : _f,
6427
- _g = _b.bound,
6428
- bound = _g === void 0 ? false : _g,
6429
- _h = _b.adaptive,
6430
- adaptive = _h === void 0 ? false : _h,
6431
- _j = _b.panelsPerView,
6432
- panelsPerView = _j === void 0 ? -1 : _j,
6433
- _k = _b.noPanelStyleOverride,
6434
- noPanelStyleOverride = _k === void 0 ? false : _k,
6435
- _l = _b.resizeOnContentsReady,
6436
- resizeOnContentsReady = _l === void 0 ? false : _l,
6437
- _m = _b.needPanelThreshold,
6438
- needPanelThreshold = _m === void 0 ? 0 : _m,
6439
- _o = _b.preventEventsBeforeInit,
6440
- preventEventsBeforeInit = _o === void 0 ? true : _o,
6441
- _p = _b.deceleration,
6442
- deceleration = _p === void 0 ? 0.0075 : _p,
6443
- _q = _b.duration,
6444
- duration = _q === void 0 ? 500 : _q,
6445
- _r = _b.easing,
6446
- easing = _r === void 0 ? function (x) {
6520
+ _g = _b.circularFallback,
6521
+ circularFallback = _g === void 0 ? CIRCULAR_FALLBACK.LINEAR : _g,
6522
+ _h = _b.bound,
6523
+ bound = _h === void 0 ? false : _h,
6524
+ _j = _b.adaptive,
6525
+ adaptive = _j === void 0 ? false : _j,
6526
+ _k = _b.panelsPerView,
6527
+ panelsPerView = _k === void 0 ? -1 : _k,
6528
+ _l = _b.noPanelStyleOverride,
6529
+ noPanelStyleOverride = _l === void 0 ? false : _l,
6530
+ _m = _b.resizeOnContentsReady,
6531
+ resizeOnContentsReady = _m === void 0 ? false : _m,
6532
+ _o = _b.needPanelThreshold,
6533
+ needPanelThreshold = _o === void 0 ? 0 : _o,
6534
+ _p = _b.preventEventsBeforeInit,
6535
+ preventEventsBeforeInit = _p === void 0 ? true : _p,
6536
+ _q = _b.deceleration,
6537
+ deceleration = _q === void 0 ? 0.0075 : _q,
6538
+ _r = _b.duration,
6539
+ duration = _r === void 0 ? 500 : _r,
6540
+ _s = _b.easing,
6541
+ easing = _s === void 0 ? function (x) {
6447
6542
  return 1 - Math.pow(1 - x, 3);
6448
- } : _r,
6449
- _s = _b.inputType,
6450
- inputType = _s === void 0 ? ["mouse", "touch"] : _s,
6451
- _t = _b.moveType,
6452
- moveType = _t === void 0 ? "snap" : _t,
6453
- _u = _b.threshold,
6454
- threshold = _u === void 0 ? 40 : _u,
6455
- _v = _b.interruptable,
6456
- interruptable = _v === void 0 ? true : _v,
6457
- _w = _b.bounce,
6458
- bounce = _w === void 0 ? "20%" : _w,
6459
- _x = _b.iOSEdgeSwipeThreshold,
6460
- iOSEdgeSwipeThreshold = _x === void 0 ? 30 : _x,
6461
- _y = _b.preventClickOnDrag,
6462
- preventClickOnDrag = _y === void 0 ? true : _y,
6463
- _z = _b.disableOnInit,
6464
- disableOnInit = _z === void 0 ? false : _z,
6465
- _0 = _b.renderOnlyVisible,
6466
- renderOnlyVisible = _0 === void 0 ? false : _0,
6467
- _1 = _b.virtual,
6468
- virtual = _1 === void 0 ? null : _1,
6469
- _2 = _b.autoInit,
6470
- autoInit = _2 === void 0 ? true : _2,
6471
- _3 = _b.autoResize,
6472
- autoResize = _3 === void 0 ? true : _3,
6473
- _4 = _b.useResizeObserver,
6474
- useResizeObserver = _4 === void 0 ? true : _4,
6475
- _5 = _b.externalRenderer,
6476
- externalRenderer = _5 === void 0 ? null : _5,
6477
- _6 = _b.renderExternal,
6478
- renderExternal = _6 === void 0 ? null : _6;
6543
+ } : _s,
6544
+ _t = _b.inputType,
6545
+ inputType = _t === void 0 ? ["mouse", "touch"] : _t,
6546
+ _u = _b.moveType,
6547
+ moveType = _u === void 0 ? "snap" : _u,
6548
+ _v = _b.threshold,
6549
+ threshold = _v === void 0 ? 40 : _v,
6550
+ _w = _b.interruptable,
6551
+ interruptable = _w === void 0 ? true : _w,
6552
+ _x = _b.bounce,
6553
+ bounce = _x === void 0 ? "20%" : _x,
6554
+ _y = _b.iOSEdgeSwipeThreshold,
6555
+ iOSEdgeSwipeThreshold = _y === void 0 ? 30 : _y,
6556
+ _z = _b.preventClickOnDrag,
6557
+ preventClickOnDrag = _z === void 0 ? true : _z,
6558
+ _0 = _b.disableOnInit,
6559
+ disableOnInit = _0 === void 0 ? false : _0,
6560
+ _1 = _b.renderOnlyVisible,
6561
+ renderOnlyVisible = _1 === void 0 ? false : _1,
6562
+ _2 = _b.virtual,
6563
+ virtual = _2 === void 0 ? null : _2,
6564
+ _3 = _b.autoInit,
6565
+ autoInit = _3 === void 0 ? true : _3,
6566
+ _4 = _b.autoResize,
6567
+ autoResize = _4 === void 0 ? true : _4,
6568
+ _5 = _b.useResizeObserver,
6569
+ useResizeObserver = _5 === void 0 ? true : _5,
6570
+ _6 = _b.externalRenderer,
6571
+ externalRenderer = _6 === void 0 ? null : _6,
6572
+ _7 = _b.renderExternal,
6573
+ renderExternal = _7 === void 0 ? null : _7;
6479
6574
 
6480
6575
  var _this = _super.call(this) || this; // Internal states
6481
6576
 
@@ -6487,6 +6582,7 @@ function (_super) {
6487
6582
  _this._defaultIndex = defaultIndex;
6488
6583
  _this._horizontal = horizontal;
6489
6584
  _this._circular = circular;
6585
+ _this._circularFallback = circularFallback;
6490
6586
  _this._bound = bound;
6491
6587
  _this._adaptive = adaptive;
6492
6588
  _this._panelsPerView = panelsPerView;
@@ -6625,7 +6721,7 @@ function (_super) {
6625
6721
  * @readonly
6626
6722
  */
6627
6723
  get: function () {
6628
- return this._camera.controlParams.circular;
6724
+ return this._camera.circularEnabled;
6629
6725
  },
6630
6726
  enumerable: false,
6631
6727
  configurable: true
@@ -6859,6 +6955,24 @@ function (_super) {
6859
6955
  enumerable: false,
6860
6956
  configurable: true
6861
6957
  });
6958
+ Object.defineProperty(__proto, "circularFallback", {
6959
+ /**
6960
+ * Set panel control mode for the case when circular cannot be enabled.
6961
+ * "linear" will set the view's range from the top of the first panel to the top of the last panel.
6962
+ * "bound" will prevent the view from going out of the first/last panel, so it won't show empty spaces before/after the first/last panel.
6963
+ * @ko 순환 모드 사용 불가능시 사용할 패널 조작 범위 설정 방식을 변경합니다.
6964
+ * "linear" 사용시 시점이 첫번째 엘리먼트 위에서부터 마지막 엘리먼트 위까지 움직일 수 있도록 설정합니다.
6965
+ * "bound" 사용시 시점이 첫번째 엘리먼트와 마지막 엘리먼트의 끝과 끝 사이에서 움직일 수 있도록 설정합니다.
6966
+ * @see CIRCULAR_FALLBACK
6967
+ * @type {string}
6968
+ * @default "linear"
6969
+ */
6970
+ get: function () {
6971
+ return this._circularFallback;
6972
+ },
6973
+ enumerable: false,
6974
+ configurable: true
6975
+ });
6862
6976
  Object.defineProperty(__proto, "bound", {
6863
6977
  /**
6864
6978
  * Prevent the view(camera element) from going out of the first/last panel, so it won't show empty spaces before/after the first/last panel
@@ -7819,7 +7933,7 @@ function (_super) {
7819
7933
  });
7820
7934
  }
7821
7935
 
7822
- (_a = this._plugins).push.apply(_a, __spreadArray([], __read(plugins)));
7936
+ (_a = this._plugins).push.apply(_a, __spread(plugins));
7823
7937
 
7824
7938
  return this;
7825
7939
  };
@@ -8066,22 +8180,14 @@ function (_super) {
8066
8180
  };
8067
8181
 
8068
8182
  __proto._createCamera = function () {
8069
- var cameraOption = {
8070
- align: this._align
8071
- };
8072
-
8073
- if (this._circular) {
8074
- if (this._bound) {
8075
- // eslint-disable-next-line no-console
8076
- console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
8077
- }
8078
-
8079
- return new CircularCamera(cameraOption);
8080
- } else if (this._bound) {
8081
- return new BoundCamera(cameraOption);
8082
- } else {
8083
- return new LinearCamera(cameraOption);
8183
+ if (this._circular && this._bound) {
8184
+ // eslint-disable-next-line no-console
8185
+ console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
8084
8186
  }
8187
+
8188
+ return new Camera({
8189
+ align: this._align
8190
+ });
8085
8191
  };
8086
8192
 
8087
8193
  __proto._createRenderer = function () {
@@ -8145,7 +8251,7 @@ function (_super) {
8145
8251
  */
8146
8252
 
8147
8253
 
8148
- Flicking.VERSION = "4.4.1";
8254
+ Flicking.VERSION = "4.5.1";
8149
8255
  return Flicking;
8150
8256
  }(Component);
8151
8257
 
@@ -8184,7 +8290,7 @@ var withFlickingMethods = function (prototype, flickingName) {
8184
8290
  args[_i] = arguments[_i];
8185
8291
  }
8186
8292
 
8187
- return (_a = descriptor.value).call.apply(_a, __spreadArray([this[flickingName]], __read(args)));
8293
+ return (_a = descriptor.value).call.apply(_a, __spread([this[flickingName]], args));
8188
8294
  }
8189
8295
  });
8190
8296
  } else {
@@ -8194,7 +8300,8 @@ var withFlickingMethods = function (prototype, flickingName) {
8194
8300
  getterDescriptor.get = function () {
8195
8301
  var _a;
8196
8302
 
8197
- return (_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(this[flickingName]);
8303
+ var flicking = this[flickingName];
8304
+ return flicking && ((_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(flicking));
8198
8305
  };
8199
8306
  }
8200
8307
 
@@ -8208,7 +8315,7 @@ var withFlickingMethods = function (prototype, flickingName) {
8208
8315
  args[_i] = arguments[_i];
8209
8316
  }
8210
8317
 
8211
- return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([this[flickingName]], __read(args)));
8318
+ return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spread([this[flickingName]], args));
8212
8319
  };
8213
8320
  }
8214
8321
 
@@ -8222,6 +8329,8 @@ var sync = (function (flicking, diffResult, rendered) {
8222
8329
  var renderer = flicking.renderer;
8223
8330
  var panels = renderer.panels;
8224
8331
 
8332
+ var prevList = __spread(diffResult.prevList);
8333
+
8225
8334
  if (diffResult.removed.length > 0) {
8226
8335
  var endIdx_1 = -1;
8227
8336
  var prevIdx_1 = -1;
@@ -8237,6 +8346,8 @@ var sync = (function (flicking, diffResult, rendered) {
8237
8346
  } else {
8238
8347
  prevIdx_1 = removedIdx;
8239
8348
  }
8349
+
8350
+ prevList.splice(removedIdx, 1);
8240
8351
  });
8241
8352
  batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
8242
8353
  }
@@ -8276,13 +8387,14 @@ var sync = (function (flicking, diffResult, rendered) {
8276
8387
  if (diffResult.added.length > 0) {
8277
8388
  var startIdx_1 = -1;
8278
8389
  var prevIdx_2 = -1;
8390
+ var addedElements_1 = rendered.slice(prevList.length);
8279
8391
  diffResult.added.forEach(function (addedIdx, idx) {
8280
8392
  if (startIdx_1 < 0) {
8281
8393
  startIdx_1 = idx;
8282
8394
  }
8283
8395
 
8284
8396
  if (prevIdx_2 >= 0 && addedIdx !== prevIdx_2 + 1) {
8285
- batchInsert(renderer, diffResult, rendered, startIdx_1, idx + 1);
8397
+ batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1);
8286
8398
  startIdx_1 = -1;
8287
8399
  prevIdx_2 = -1;
8288
8400
  } else {
@@ -8291,19 +8403,19 @@ var sync = (function (flicking, diffResult, rendered) {
8291
8403
  });
8292
8404
 
8293
8405
  if (startIdx_1 >= 0) {
8294
- batchInsert(renderer, diffResult, rendered, startIdx_1);
8406
+ batchInsert(renderer, diffResult, addedElements_1, startIdx_1);
8295
8407
  }
8296
8408
  }
8297
8409
  });
8298
8410
 
8299
- var batchInsert = function (renderer, diffResult, rendered, startIdx, endIdx) {
8300
- renderer.batchInsert.apply(renderer, __spreadArray([], __read(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
8411
+ var batchInsert = function (renderer, diffResult, addedElements, startIdx, endIdx) {
8412
+ renderer.batchInsert.apply(renderer, __spread(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
8301
8413
  return {
8302
8414
  index: index,
8303
- elements: [rendered[elIdx + diffResult.prevList.length]],
8415
+ elements: [addedElements[elIdx]],
8304
8416
  hasDOMInElements: false
8305
8417
  };
8306
- }))));
8418
+ })));
8307
8419
  };
8308
8420
 
8309
8421
  var batchRemove = function (renderer, startIdx, endIdx) {
@@ -8328,16 +8440,16 @@ var getRenderingPanels = (function (flicking, diffResult) {
8328
8440
  map[prev] = current;
8329
8441
  return map;
8330
8442
  }, {});
8331
- return __spreadArray(__spreadArray([], __read(flicking.panels.filter(function (panel) {
8443
+ return __spread(flicking.panels.filter(function (panel) {
8332
8444
  return !removedPanels[panel.index];
8333
8445
  }) // Sort panels by position
8334
8446
  .sort(function (panel1, panel2) {
8335
8447
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8336
8448
  }).map(function (panel) {
8337
8449
  return diffResult.list[maintainedMap[panel.index]];
8338
- })), false), __read(diffResult.added.map(function (idx) {
8450
+ }), diffResult.added.map(function (idx) {
8339
8451
  return diffResult.list[idx];
8340
- })));
8452
+ }));
8341
8453
  });
8342
8454
 
8343
8455
  var getDefaultCameraTransform = (function (align, horizontal, firstPanelSize) {
@@ -8391,5 +8503,5 @@ var parseAlign = function (alignVal) {
8391
8503
  * egjs projects are licensed under the MIT license
8392
8504
  */
8393
8505
 
8394
- export { ALIGN, AnchorPoint, AnimatingState, AxesController, BoundCamera, CLASS, Camera, CircularCamera, Control, DIRECTION, DisabledState, DraggingState, CODE as ERROR_CODE, EVENTS, ExternalRenderer, FlickingError, FreeControl, HoldingState, IdleState, LinearCamera, MOVE_TYPE, NormalRenderingStrategy, 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, 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 };
8506
+ 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, 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, 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 };
8395
8507
  //# sourceMappingURL=flicking.esm.js.map