@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
package/dist/flicking.js CHANGED
@@ -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
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@egjs/component'), require('@egjs/axes'), require('@egjs/imready')) :
@@ -242,10 +242,12 @@ version: 4.4.1
242
242
 
243
243
  return ar;
244
244
  }
245
- function __spreadArray(to, from) {
246
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i];
245
+ /** @deprecated */
247
246
 
248
- return to;
247
+ function __spread() {
248
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
249
+
250
+ return ar;
249
251
  }
250
252
 
251
253
  /*
@@ -425,6 +427,18 @@ version: 4.4.1
425
427
  HIDDEN: "flicking-hidden",
426
428
  DEFAULT_VIRTUAL: "flicking-panel"
427
429
  };
430
+ /**
431
+ * An object with all possible {@link Flicking#circularFallback circularFallback}s
432
+ * @ko Flicking의 {@link Flicking#circularFallback circularFallback}에 설정 가능한 값들을 담고 있는 객체
433
+ * @type {object}
434
+ * @property {string} LINEAR "linear"
435
+ * @property {string} BOUND "bound"
436
+ */
437
+
438
+ var CIRCULAR_FALLBACK = {
439
+ LINEAR: "linear",
440
+ BOUND: "bound"
441
+ };
428
442
 
429
443
  var Constants = {
430
444
  __proto__: null,
@@ -433,6 +447,7 @@ version: 4.4.1
433
447
  DIRECTION: DIRECTION,
434
448
  MOVE_TYPE: MOVE_TYPE,
435
449
  CLASS: CLASS,
450
+ CIRCULAR_FALLBACK: CIRCULAR_FALLBACK,
436
451
  ERROR_CODE: CODE
437
452
  };
438
453
 
@@ -618,7 +633,7 @@ version: 4.4.1
618
633
  if (isString(el)) {
619
634
  var tempDiv = document.createElement("div");
620
635
  tempDiv.innerHTML = el;
621
- elements.push.apply(elements, __spreadArray([], __read(toArray(tempDiv.children))));
636
+ elements.push.apply(elements, __spread(toArray(tempDiv.children)));
622
637
 
623
638
  while (tempDiv.firstChild) {
624
639
  tempDiv.removeChild(tempDiv.firstChild);
@@ -3031,9 +3046,8 @@ version: 4.4.1
3031
3046
 
3032
3047
 
3033
3048
  function SnapControl(_a) {
3034
- var _b = _a === void 0 ? {} : _a,
3035
- _c = _b.count,
3036
- count = _c === void 0 ? Infinity : _c;
3049
+ var _b = (_a === void 0 ? {} : _a).count,
3050
+ count = _b === void 0 ? Infinity : _b;
3037
3051
 
3038
3052
  var _this = _super.call(this) || this;
3039
3053
 
@@ -3239,9 +3253,8 @@ version: 4.4.1
3239
3253
 
3240
3254
 
3241
3255
  function FreeControl(_a) {
3242
- var _b = _a === void 0 ? {} : _a,
3243
- _c = _b.stopAtEdge,
3244
- stopAtEdge = _c === void 0 ? true : _c;
3256
+ var _b = (_a === void 0 ? {} : _a).stopAtEdge,
3257
+ stopAtEdge = _b === void 0 ? true : _b;
3245
3258
 
3246
3259
  var _this = _super.call(this) || this;
3247
3260
 
@@ -3375,9 +3388,8 @@ version: 4.4.1
3375
3388
 
3376
3389
 
3377
3390
  function StrictControl(_a) {
3378
- var _b = _a === void 0 ? {} : _a,
3379
- _c = _b.count,
3380
- count = _c === void 0 ? 1 : _c;
3391
+ var _b = (_a === void 0 ? {} : _a).count,
3392
+ count = _b === void 0 ? 1 : _b;
3381
3393
 
3382
3394
  var _this = _super.call(this) || this;
3383
3395
 
@@ -3500,6 +3512,21 @@ version: 4.4.1
3500
3512
  };
3501
3513
  return this;
3502
3514
  };
3515
+
3516
+ __proto.moveToPanel = function (panel, options) {
3517
+ return __awaiter(this, void 0, void 0, function () {
3518
+ var flicking, camera, controller;
3519
+ return __generator(this, function (_a) {
3520
+ flicking = getFlickingAttached(this._flicking);
3521
+ camera = flicking.camera;
3522
+ controller = this._controller;
3523
+ controller.update(camera.controlParams);
3524
+ return [2
3525
+ /*return*/
3526
+ , _super.prototype.moveToPanel.call(this, panel, options)];
3527
+ });
3528
+ });
3529
+ };
3503
3530
  /**
3504
3531
  * Move {@link Camera} to the given position
3505
3532
  * @ko {@link Camera}를 주어진 좌표로 이동합니다
@@ -3630,761 +3657,826 @@ version: 4.4.1
3630
3657
  };
3631
3658
 
3632
3659
  /**
3633
- * A component that manages actual movement inside the viewport
3634
- * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
3660
+ * A mode of camera
3635
3661
  */
3636
3662
 
3637
- var Camera$1 =
3663
+ var CameraMode =
3638
3664
  /*#__PURE__*/
3639
3665
  function () {
3640
3666
  /** */
3641
- function Camera(_a) {
3642
- var _this = this;
3667
+ function CameraMode(flicking) {
3668
+ this._flicking = flicking;
3669
+ }
3643
3670
 
3644
- var _b = _a === void 0 ? {} : _a,
3645
- _c = _b.align,
3646
- align = _c === void 0 ? ALIGN.CENTER : _c;
3671
+ var __proto = CameraMode.prototype;
3647
3672
 
3648
- this._checkTranslateSupport = function () {
3649
- var e_1, _a;
3673
+ __proto.getAnchors = function () {
3674
+ var panels = this._flicking.renderer.panels;
3675
+ return panels.map(function (panel, index) {
3676
+ return new AnchorPoint({
3677
+ index: index,
3678
+ position: panel.position,
3679
+ panel: panel
3680
+ });
3681
+ });
3682
+ };
3650
3683
 
3651
- var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
3652
- var supportedStyle = document.documentElement.style;
3653
- var transformName = "";
3684
+ __proto.findAnchorIncludePosition = function (position) {
3685
+ var anchors = this._flicking.camera.anchorPoints;
3686
+ var anchorsIncludingPosition = anchors.filter(function (anchor) {
3687
+ return anchor.panel.includePosition(position, true);
3688
+ });
3689
+ return anchorsIncludingPosition.reduce(function (nearest, anchor) {
3690
+ if (!nearest) return anchor;
3691
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3692
+ }, null);
3693
+ };
3654
3694
 
3655
- try {
3656
- for (var transforms_1 = __values(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
3657
- var prefixedTransform = transforms_1_1.value;
3695
+ __proto.clampToReachablePosition = function (position) {
3696
+ var camera = this._flicking.camera;
3697
+ var range = camera.range;
3698
+ return clamp(position, range.min, range.max);
3699
+ };
3658
3700
 
3659
- if (prefixedTransform in supportedStyle) {
3660
- transformName = prefixedTransform;
3661
- }
3662
- }
3663
- } catch (e_1_1) {
3664
- e_1 = {
3665
- error: e_1_1
3666
- };
3667
- } finally {
3668
- try {
3669
- if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
3670
- } finally {
3671
- if (e_1) throw e_1.error;
3672
- }
3673
- }
3701
+ __proto.getCircularOffset = function () {
3702
+ return 0;
3703
+ };
3674
3704
 
3675
- if (!transformName) {
3676
- throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
3677
- }
3705
+ __proto.canReach = function (panel) {
3706
+ var camera = this._flicking.camera;
3707
+ var range = camera.range;
3708
+ if (panel.removed) return false;
3709
+ var panelPos = panel.position;
3710
+ return panelPos >= range.min && panelPos <= range.max;
3711
+ };
3678
3712
 
3679
- _this._transform = transformName;
3713
+ __proto.canSee = function (panel) {
3714
+ var camera = this._flicking.camera;
3715
+ var visibleRange = camera.visibleRange; // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
3716
+
3717
+ return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
3718
+ };
3719
+
3720
+ return CameraMode;
3721
+ }();
3722
+
3723
+ var LinearCameraMode =
3724
+ /*#__PURE__*/
3725
+ function (_super) {
3726
+ __extends(LinearCameraMode, _super);
3727
+
3728
+ function LinearCameraMode() {
3729
+ return _super !== null && _super.apply(this, arguments) || this;
3730
+ }
3731
+
3732
+ var __proto = LinearCameraMode.prototype;
3733
+
3734
+ __proto.checkAvailability = function () {
3735
+ // It's always available
3736
+ return true;
3737
+ };
3738
+
3739
+ __proto.getRange = function () {
3740
+ var _a, _b;
3741
+
3742
+ var renderer = this._flicking.renderer;
3743
+ var firstPanel = renderer.getPanel(0);
3744
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3745
+ return {
3746
+ min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
3747
+ max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
3680
3748
  };
3749
+ };
3681
3750
 
3682
- this._flicking = null;
3751
+ return LinearCameraMode;
3752
+ }(CameraMode);
3683
3753
 
3684
- this._resetInternalValues(); // Options
3754
+ /**
3755
+ * A {@link Camera} mode that connects the last panel and the first panel, enabling continuous loop
3756
+ * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera} 모드
3757
+ */
3685
3758
 
3759
+ var CircularCameraMode =
3760
+ /*#__PURE__*/
3761
+ function (_super) {
3762
+ __extends(CircularCameraMode, _super);
3686
3763
 
3687
- this._align = align;
3764
+ function CircularCameraMode() {
3765
+ return _super !== null && _super.apply(this, arguments) || this;
3688
3766
  }
3689
3767
 
3690
- var __proto = Camera.prototype;
3691
- Object.defineProperty(__proto, "element", {
3692
- // Internal states getter
3768
+ var __proto = CircularCameraMode.prototype;
3693
3769
 
3694
- /**
3695
- * The camera element(`.flicking-camera`)
3696
- * @ko 카메라 엘리먼트(`.flicking-camera`)
3697
- * @type {HTMLElement}
3698
- * @readonly
3699
- */
3700
- get: function () {
3701
- return this._el;
3702
- },
3703
- enumerable: false,
3704
- configurable: true
3705
- });
3706
- Object.defineProperty(__proto, "children", {
3707
- /**
3708
- * An array of the child elements of the camera element(`.flicking-camera`)
3709
- * @ko 카메라 엘리먼트(`.flicking-camera`) 자식 엘리먼트 배열
3710
- * @type {HTMLElement[]}
3711
- * @readonly
3712
- */
3713
- get: function () {
3714
- return toArray(this._el.children);
3715
- },
3716
- enumerable: false,
3717
- configurable: true
3718
- });
3719
- Object.defineProperty(__proto, "position", {
3720
- /**
3721
- * Current position of the camera
3722
- * @ko Camera의 현재 좌표
3723
- * @type {number}
3724
- * @readonly
3725
- */
3726
- get: function () {
3727
- return this._position;
3728
- },
3729
- enumerable: false,
3730
- configurable: true
3731
- });
3732
- Object.defineProperty(__proto, "alignPosition", {
3733
- /**
3734
- * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
3735
- * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
3736
- * @type {number}
3737
- * @readonly
3738
- */
3739
- get: function () {
3740
- return this._alignPos;
3741
- },
3742
- enumerable: false,
3743
- configurable: true
3744
- });
3745
- Object.defineProperty(__proto, "offset", {
3746
- /**
3747
- * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
3748
- * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
3749
- * @type {number}
3750
- * @default 0
3751
- * @readonly
3752
- */
3753
- get: function () {
3754
- return this._offset;
3755
- },
3756
- enumerable: false,
3757
- configurable: true
3758
- });
3759
- Object.defineProperty(__proto, "range", {
3760
- /**
3761
- * A range that Camera's {@link Camera#position position} can reach
3762
- * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
3763
- * @type {object}
3764
- * @property {number} min A minimum position<ko>최소 위치</ko>
3765
- * @property {number} min A maximum position<ko>최대 위치</ko>
3766
- * @readonly
3767
- */
3768
- get: function () {
3769
- return this._range;
3770
- },
3771
- enumerable: false,
3772
- configurable: true
3773
- });
3774
- Object.defineProperty(__proto, "rangeDiff", {
3775
- /**
3776
- * A difference between Camera's minimum and maximum position that can reach
3777
- * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
3778
- * @type {number}
3779
- * @readonly
3780
- */
3781
- get: function () {
3782
- return this._range.max - this._range.min;
3783
- },
3784
- enumerable: false,
3785
- configurable: true
3786
- });
3787
- Object.defineProperty(__proto, "visiblePanels", {
3788
- /**
3789
- * An array of visible panels from the current position
3790
- * @ko 현재 보이는 패널들의 배열
3791
- * @type {Panel[]}
3792
- * @readonly
3793
- */
3794
- get: function () {
3795
- return this._visiblePanels;
3796
- },
3797
- enumerable: false,
3798
- configurable: true
3799
- });
3800
- Object.defineProperty(__proto, "visibleRange", {
3801
- /**
3802
- * A range of the visible area from the current position
3803
- * @ko 현재 위치에서 보이는 범위
3804
- * @type {object}
3805
- * @property {number} min A minimum position<ko>최소 위치</ko>
3806
- * @property {number} min A maximum position<ko>최대 위치</ko>
3807
- * @readonly
3808
- */
3809
- get: function () {
3770
+ __proto.checkAvailability = function () {
3771
+ var flicking = this._flicking;
3772
+ var renderer = flicking.renderer;
3773
+ var panels = renderer.panels;
3774
+
3775
+ if (panels.length <= 0) {
3776
+ return false;
3777
+ }
3778
+
3779
+ var firstPanel = panels[0];
3780
+ var lastPanel = panels[panels.length - 1];
3781
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
3782
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
3783
+ var visibleSize = flicking.camera.size;
3784
+ var panelSizeSum = lastPanelNext - firstPanelPrev;
3785
+ var canSetCircularMode = panels.every(function (panel) {
3786
+ return panelSizeSum - panel.size >= visibleSize;
3787
+ });
3788
+ return canSetCircularMode;
3789
+ };
3790
+
3791
+ __proto.getRange = function () {
3792
+ var flicking = this._flicking;
3793
+ var panels = flicking.renderer.panels;
3794
+
3795
+ if (panels.length <= 0) {
3810
3796
  return {
3811
- min: this._position - this._alignPos,
3812
- max: this._position - this._alignPos + this.size
3797
+ min: 0,
3798
+ max: 0
3813
3799
  };
3814
- },
3815
- enumerable: false,
3816
- configurable: true
3817
- });
3818
- Object.defineProperty(__proto, "anchorPoints", {
3819
- /**
3820
- * An array of {@link AnchorPoint}s that Camera can be stopped at
3821
- * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
3822
- * @type {AnchorPoint[]}
3823
- * @readonly
3824
- */
3825
- get: function () {
3826
- return this._anchors;
3827
- },
3828
- enumerable: false,
3829
- configurable: true
3830
- });
3831
- Object.defineProperty(__proto, "controlParams", {
3832
- /**
3833
- * A current parameters of the Camera for updating {@link AxesController}
3834
- * @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
3835
- * @type {ControlParams}
3836
- * @readonly
3837
- */
3838
- get: function () {
3839
- return {
3840
- range: this._range,
3841
- position: this._position,
3842
- circular: false
3843
- };
3844
- },
3845
- enumerable: false,
3846
- configurable: true
3847
- });
3848
- Object.defineProperty(__proto, "atEdge", {
3849
- /**
3850
- * A Boolean value indicating whether Camera's over the minimum or maximum position reachable
3851
- * @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
3852
- * @type {boolean}
3853
- * @readonly
3854
- */
3855
- get: function () {
3856
- return this._position <= this._range.min || this._position >= this._range.max;
3857
- },
3858
- enumerable: false,
3859
- configurable: true
3860
- });
3861
- Object.defineProperty(__proto, "size", {
3862
- /**
3863
- * Return the size of the viewport
3864
- * @ko 뷰포트 크기를 반환합니다
3865
- * @type {number}
3866
- * @readonly
3867
- */
3868
- get: function () {
3869
- var flicking = this._flicking;
3870
- return flicking ? flicking.horizontal ? flicking.viewport.width : flicking.viewport.height : 0;
3871
- },
3872
- enumerable: false,
3873
- configurable: true
3874
- });
3875
- Object.defineProperty(__proto, "progress", {
3876
- /**
3877
- * Return the camera's position progress from the first panel to last panel
3878
- * Range is from 0 to last panel's index
3879
- * @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
3880
- * 범위는 0부터 마지막 패널의 인덱스까지입니다
3881
- * @type {number}
3882
- * @readonly
3883
- */
3884
- get: function () {
3885
- var flicking = this._flicking;
3886
- var position = this._position + this._offset;
3887
- var nearestAnchor = this.findNearestAnchor(this._position);
3800
+ }
3888
3801
 
3889
- if (!flicking || !nearestAnchor) {
3890
- return NaN;
3891
- }
3802
+ var firstPanel = panels[0];
3803
+ var lastPanel = panels[panels.length - 1];
3804
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
3805
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
3806
+ return {
3807
+ min: firstPanelPrev,
3808
+ max: lastPanelNext
3809
+ };
3810
+ };
3892
3811
 
3893
- var nearestPanel = nearestAnchor.panel;
3894
- var panelPos = nearestPanel.position + nearestPanel.offset;
3895
- var bounceSize = flicking.control.controller.bounce;
3896
- var _a = this.range,
3897
- prevRange = _a.min,
3898
- nextRange = _a.max;
3899
- var rangeDiff = this.rangeDiff;
3812
+ __proto.getAnchors = function () {
3813
+ var flicking = this._flicking;
3814
+ var panels = flicking.renderer.panels;
3815
+ return panels.map(function (panel, index) {
3816
+ return new AnchorPoint({
3817
+ index: index,
3818
+ position: panel.position,
3819
+ panel: panel
3820
+ });
3821
+ });
3822
+ };
3900
3823
 
3901
- if (position === panelPos) {
3902
- return nearestPanel.index;
3903
- }
3824
+ __proto.findAnchorIncludePosition = function (position) {
3825
+ var camera = this._flicking.camera;
3826
+ var range = camera.range;
3827
+ var anchors = camera.anchorPoints;
3828
+ var rangeDiff = camera.rangeDiff;
3829
+ var anchorCount = anchors.length;
3830
+ var positionInRange = circulatePosition(position, range.min, range.max);
3904
3831
 
3905
- if (position < panelPos) {
3906
- var prevPanel = nearestPanel.prev();
3907
- var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
3832
+ var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
3908
3833
 
3909
- if (prevPosition > panelPos) {
3910
- prevPosition -= rangeDiff;
3911
- }
3834
+ if (anchorCount > 0 && (position === range.min || position === range.max)) {
3835
+ var possibleAnchors = [anchorInRange, new AnchorPoint({
3836
+ index: 0,
3837
+ position: anchors[0].position + rangeDiff,
3838
+ panel: anchors[0].panel
3839
+ }), new AnchorPoint({
3840
+ index: anchorCount - 1,
3841
+ position: anchors[anchorCount - 1].position - rangeDiff,
3842
+ panel: anchors[anchorCount - 1].panel
3843
+ })].filter(function (anchor) {
3844
+ return !!anchor;
3845
+ });
3846
+ anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
3847
+ if (!nearest) return anchor;
3848
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3849
+ }, null);
3850
+ }
3912
3851
 
3913
- return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
3914
- } else {
3915
- var nextPanel = nearestPanel.next();
3916
- var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1]; // Looped
3852
+ if (!anchorInRange) return null;
3917
3853
 
3918
- if (nextPosition < panelPos) {
3919
- nextPosition += rangeDiff;
3920
- }
3854
+ if (position < range.min) {
3855
+ var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
3856
+ return new AnchorPoint({
3857
+ index: anchorInRange.index,
3858
+ position: anchorInRange.position + rangeDiff * loopCount,
3859
+ panel: anchorInRange.panel
3860
+ });
3861
+ } else if (position > range.max) {
3862
+ var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
3863
+ return new AnchorPoint({
3864
+ index: anchorInRange.index,
3865
+ position: anchorInRange.position + rangeDiff * loopCount,
3866
+ panel: anchorInRange.panel
3867
+ });
3868
+ }
3921
3869
 
3922
- return nearestPanel.index + getProgress(position, panelPos, nextPosition);
3923
- }
3924
- },
3925
- enumerable: false,
3926
- configurable: true
3927
- });
3928
- Object.defineProperty(__proto, "align", {
3929
- // Options Getter
3870
+ return anchorInRange;
3871
+ };
3930
3872
 
3931
- /**
3932
- * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
3933
- * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
3934
- * @type {ALIGN | string | number}
3935
- */
3936
- get: function () {
3937
- return this._align;
3938
- },
3939
- // Options Setter
3940
- set: function (val) {
3941
- this._align = val;
3942
- },
3943
- enumerable: false,
3944
- configurable: true
3945
- });
3946
- /**
3947
- * Initialize Camera
3948
- * @ko Camera를 초기화합니다
3949
- * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
3950
- * @chainable
3951
- * @throws {FlickingError}
3952
- * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
3953
- * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
3954
- * @return {this}
3955
- */
3873
+ __proto.getCircularOffset = function () {
3874
+ var flicking = this._flicking;
3875
+ var camera = flicking.camera;
3876
+ if (!camera.circularEnabled) return 0;
3877
+ var toggled = flicking.panels.filter(function (panel) {
3878
+ return panel.toggled;
3879
+ });
3880
+ var toggledPrev = toggled.filter(function (panel) {
3881
+ return panel.toggleDirection === DIRECTION.PREV;
3882
+ });
3883
+ var toggledNext = toggled.filter(function (panel) {
3884
+ return panel.toggleDirection === DIRECTION.NEXT;
3885
+ });
3886
+ return this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
3887
+ };
3956
3888
 
3957
- __proto.init = function (flicking) {
3958
- this._flicking = flicking;
3959
- var viewportEl = flicking.viewport.element;
3960
- checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
3961
- this._el = viewportEl.firstElementChild;
3889
+ __proto.clampToReachablePosition = function (position) {
3890
+ // Basically all position is reachable for circular camera
3891
+ return position;
3892
+ };
3962
3893
 
3963
- this._checkTranslateSupport();
3894
+ __proto.canReach = function (panel) {
3895
+ if (panel.removed) return false; // Always reachable on circular mode
3964
3896
 
3965
- return this;
3897
+ return true;
3966
3898
  };
3967
- /**
3968
- * Destroy Camera and return to initial state
3969
- * @ko Camera를 초기 상태로 되돌립니다
3970
- * @return {void}
3971
- */
3972
3899
 
3900
+ __proto.canSee = function (panel) {
3901
+ var camera = this._flicking.camera;
3902
+ var range = camera.range;
3903
+ var rangeDiff = camera.rangeDiff;
3904
+ var visibleRange = camera.visibleRange;
3973
3905
 
3974
- __proto.destroy = function () {
3975
- this._flicking = null;
3906
+ var visibleInCurrentRange = _super.prototype.canSee.call(this, panel); // Check looped visible area for circular case
3976
3907
 
3977
- this._resetInternalValues();
3978
3908
 
3979
- return this;
3909
+ if (visibleRange.min < range.min) {
3910
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
3911
+ } else if (visibleRange.max > range.max) {
3912
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
3913
+ }
3914
+
3915
+ return visibleInCurrentRange;
3980
3916
  };
3981
- /**
3982
- * Move to the given position and apply CSS transform
3983
- * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
3984
- * @param {number} pos A new position<ko>움직일 위치</ko>
3985
- * @throws {FlickingError}
3986
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
3987
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
3988
- * @return {this}
3989
- */
3990
3917
 
3918
+ __proto._calcPanelAreaSum = function (panels) {
3919
+ return panels.reduce(function (sum, panel) {
3920
+ return sum + panel.sizeIncludingMargin;
3921
+ }, 0);
3922
+ };
3991
3923
 
3992
- __proto.lookAt = function (pos) {
3993
- var prevPos = this._position;
3994
- this._position = pos;
3924
+ return CircularCameraMode;
3925
+ }(CameraMode);
3995
3926
 
3996
- this._refreshVisiblePanels();
3927
+ var BoundCameraMode =
3928
+ /*#__PURE__*/
3929
+ function (_super) {
3930
+ __extends(BoundCameraMode, _super);
3997
3931
 
3998
- this._checkNeedPanel();
3932
+ function BoundCameraMode() {
3933
+ return _super !== null && _super.apply(this, arguments) || this;
3934
+ }
3999
3935
 
4000
- this._checkReachEnd(prevPos, pos);
3936
+ var __proto = BoundCameraMode.prototype;
4001
3937
 
4002
- this.applyTransform();
4003
- };
4004
- /**
4005
- * Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
4006
- * If it does not exist, return `null` instead
4007
- * @ko 주어진 {@link AnchorPoint}의 이전 {@link AnchorPoint}를 반환합니다
4008
- * 존재하지 않을 경우 `null`을 반환합니다
4009
- * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
4010
- * @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
4011
- */
3938
+ __proto.checkAvailability = function () {
3939
+ var flicking = this._flicking;
3940
+ var renderer = flicking.renderer;
3941
+ var firstPanel = renderer.getPanel(0);
3942
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
4012
3943
 
3944
+ if (!firstPanel || !lastPanel) {
3945
+ return false;
3946
+ }
4013
3947
 
4014
- __proto.getPrevAnchor = function (anchor) {
4015
- return this._anchors[anchor.index - 1] || null;
3948
+ var viewportSize = flicking.camera.size;
3949
+ var firstPanelPrev = firstPanel.range.min;
3950
+ var lastPanelNext = lastPanel.range.max;
3951
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
3952
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
3953
+ return isBiggerThanViewport;
4016
3954
  };
4017
- /**
4018
- * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
4019
- * If it does not exist, return `null` instead
4020
- * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
4021
- * 존재하지 않을 경우 `null`을 반환합니다
4022
- * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
4023
- * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
4024
- */
4025
3955
 
3956
+ __proto.getRange = function () {
3957
+ var flicking = this._flicking;
3958
+ var renderer = flicking.renderer;
3959
+ var alignPos = flicking.camera.alignPosition;
3960
+ var firstPanel = renderer.getPanel(0);
3961
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
4026
3962
 
4027
- __proto.getNextAnchor = function (anchor) {
4028
- return this._anchors[anchor.index + 1] || null;
4029
- };
4030
- /**
4031
- * Return the camera's position progress in the panel below
4032
- * Value is from 0 to 1 when the camera's inside panel
4033
- * Value can be lower than 0 or bigger than 1 when it's in the margin area
4034
- * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
4035
- * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
4036
- * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
4037
- */
3963
+ if (!firstPanel || !lastPanel) {
3964
+ return {
3965
+ min: 0,
3966
+ max: 0
3967
+ };
3968
+ }
4038
3969
 
3970
+ var viewportSize = flicking.camera.size;
3971
+ var firstPanelPrev = firstPanel.range.min;
3972
+ var lastPanelNext = lastPanel.range.max;
3973
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
3974
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
3975
+ var firstPos = firstPanelPrev + alignPos;
3976
+ var lastPos = lastPanelNext - viewportSize + alignPos;
4039
3977
 
4040
- __proto.getProgressInPanel = function (panel) {
4041
- var panelRange = panel.range;
4042
- return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
3978
+ if (isBiggerThanViewport) {
3979
+ return {
3980
+ min: firstPos,
3981
+ max: lastPos
3982
+ };
3983
+ } else {
3984
+ var align = flicking.camera.align;
3985
+ var alignVal = typeof align === "object" ? align.camera : align;
3986
+ var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
3987
+ return {
3988
+ min: pos,
3989
+ max: pos
3990
+ };
3991
+ }
4043
3992
  };
4044
- /**
4045
- * Return {@link AnchorPoint} that includes given position
4046
- * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
4047
- * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
4048
- * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
4049
- * @param {number} position A position to check<ko>확인할 좌표</ko>
4050
- * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
4051
- */
4052
3993
 
3994
+ __proto.getAnchors = function () {
3995
+ var flicking = this._flicking;
3996
+ var camera = flicking.camera;
3997
+ var panels = flicking.renderer.panels;
3998
+
3999
+ if (panels.length <= 0) {
4000
+ return [];
4001
+ }
4053
4002
 
4054
- __proto.findAnchorIncludePosition = function (position) {
4055
- var anchors = this._anchors;
4056
- var anchorsIncludingPosition = anchors.filter(function (anchor) {
4057
- return anchor.panel.includePosition(position, true);
4003
+ var range = flicking.camera.range;
4004
+ var reachablePanels = panels.filter(function (panel) {
4005
+ return camera.canReach(panel);
4058
4006
  });
4059
- return anchorsIncludingPosition.reduce(function (nearest, anchor) {
4060
- if (!nearest) return anchor;
4061
- return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
4062
- }, null);
4063
- };
4064
- /**
4065
- * Return {@link AnchorPoint} nearest to given position
4066
- * If there're no {@link AnchorPoint}s, return `null` instead
4067
- * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
4068
- * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
4069
- * @param {number} position A position to check<ko>확인할 좌표</ko>
4070
- * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
4071
- */
4072
4007
 
4008
+ if (reachablePanels.length > 0) {
4009
+ var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
4010
+ var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
4011
+ var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
4012
+ var newAnchors = reachablePanels.map(function (panel, idx) {
4013
+ return new AnchorPoint({
4014
+ index: idx + indexOffset_1,
4015
+ position: panel.position,
4016
+ panel: panel
4017
+ });
4018
+ });
4019
+
4020
+ if (shouldPrependBoundAnchor) {
4021
+ newAnchors.splice(0, 0, new AnchorPoint({
4022
+ index: 0,
4023
+ position: range.min,
4024
+ panel: panels[reachablePanels[0].index - 1]
4025
+ }));
4026
+ }
4073
4027
 
4074
- __proto.findNearestAnchor = function (position) {
4075
- var anchors = this._anchors;
4028
+ if (shouldAppendBoundAnchor) {
4029
+ newAnchors.push(new AnchorPoint({
4030
+ index: newAnchors.length,
4031
+ position: range.max,
4032
+ panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
4033
+ }));
4034
+ }
4035
+
4036
+ return newAnchors;
4037
+ } else if (range.min !== range.max) {
4038
+ // There're more than 2 panels
4039
+ var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
4040
+
4041
+ var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
4042
+ var panelAtMax = panelAtMin.next();
4043
+ return [new AnchorPoint({
4044
+ index: 0,
4045
+ position: range.min,
4046
+ panel: panelAtMin
4047
+ }), new AnchorPoint({
4048
+ index: 1,
4049
+ position: range.max,
4050
+ panel: panelAtMax
4051
+ })];
4052
+ } else {
4053
+ return [new AnchorPoint({
4054
+ index: 0,
4055
+ position: range.min,
4056
+ panel: this._findNearestPanel(range.min, panels)
4057
+ })];
4058
+ }
4059
+ };
4060
+
4061
+ __proto.findAnchorIncludePosition = function (position) {
4062
+ var camera = this._flicking.camera;
4063
+ var range = camera.range;
4064
+ var anchors = camera.anchorPoints;
4076
4065
  if (anchors.length <= 0) return null;
4066
+
4067
+ if (position <= range.min) {
4068
+ return anchors[0];
4069
+ } else if (position >= range.max) {
4070
+ return anchors[anchors.length - 1];
4071
+ } else {
4072
+ return _super.prototype.findAnchorIncludePosition.call(this, position);
4073
+ }
4074
+ };
4075
+
4076
+ __proto._findNearestPanel = function (pos, panels) {
4077
4077
  var prevDist = Infinity;
4078
4078
 
4079
- for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
4080
- var anchor = anchors[anchorIdx];
4081
- var dist = Math.abs(anchor.position - position);
4079
+ for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
4080
+ var panel = panels[panelIdx];
4081
+ var dist = Math.abs(panel.position - pos);
4082
4082
 
4083
4083
  if (dist > prevDist) {
4084
4084
  // Return previous anchor
4085
- return anchors[anchorIdx - 1];
4085
+ return panels[panelIdx - 1];
4086
4086
  }
4087
4087
 
4088
4088
  prevDist = dist;
4089
4089
  } // Return last anchor
4090
4090
 
4091
4091
 
4092
- return anchors[anchors.length - 1];
4092
+ return panels[panels.length - 1];
4093
4093
  };
4094
- /**
4095
- * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
4096
- * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
4097
- * @return {AnchorPoint | null}
4098
- */
4099
4094
 
4095
+ return BoundCameraMode;
4096
+ }(CameraMode);
4100
4097
 
4101
- __proto.findActiveAnchor = function () {
4102
- var flicking = getFlickingAttached(this._flicking);
4103
- var activeIndex = flicking.control.activeIndex;
4104
- return find(this._anchors, function (anchor) {
4105
- return anchor.panel.index === activeIndex;
4106
- });
4107
- };
4108
- /**
4109
- * Clamp the given position between camera's range
4110
- * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
4111
- * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
4112
- * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
4113
- */
4098
+ /**
4099
+ * A component that manages actual movement inside the viewport
4100
+ * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
4101
+ */
4114
4102
 
4103
+ var Camera$1 =
4104
+ /*#__PURE__*/
4105
+ function () {
4106
+ /** */
4107
+ function Camera(_a) {
4108
+ var _this = this;
4115
4109
 
4116
- __proto.clampToReachablePosition = function (position) {
4117
- var range = this._range;
4118
- return clamp(position, range.min, range.max);
4119
- };
4120
- /**
4121
- * Check whether the given panel is inside of the Camera's range
4122
- * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
4123
- * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4124
- * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
4125
- */
4110
+ var _b = (_a === void 0 ? {} : _a).align,
4111
+ align = _b === void 0 ? ALIGN.CENTER : _b;
4126
4112
 
4113
+ this._checkTranslateSupport = function () {
4114
+ var e_1, _a;
4127
4115
 
4128
- __proto.canReach = function (panel) {
4129
- var range = this._range;
4130
- if (panel.removed) return false;
4131
- var panelPos = panel.position;
4132
- return panelPos >= range.min && panelPos <= range.max;
4133
- };
4134
- /**
4135
- * Check whether the given panel element is visible at the current position
4136
- * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
4137
- * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4138
- * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
4139
- */
4116
+ var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
4117
+ var supportedStyle = document.documentElement.style;
4118
+ var transformName = "";
4140
4119
 
4120
+ try {
4121
+ for (var transforms_1 = __values(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
4122
+ var prefixedTransform = transforms_1_1.value;
4141
4123
 
4142
- __proto.canSee = function (panel) {
4143
- var visibleRange = this.visibleRange; // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
4144
-
4145
- return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
4146
- };
4147
- /**
4148
- * Update Camera's {@link Camera#alignPosition alignPosition}
4149
- * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
4150
- * @chainable
4151
- * @return {this}
4152
- */
4153
-
4154
-
4155
- __proto.updateAlignPos = function () {
4156
- var align = this._align;
4157
- var alignVal = typeof align === "object" ? align.camera : align;
4158
- this._alignPos = parseAlign$1(alignVal, this.size);
4159
- return this;
4160
- };
4161
- /**
4162
- * Update Camera's {@link Camera#anchorPoints anchorPoints}
4163
- * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
4164
- * @throws {FlickingError}
4165
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4166
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4167
- * @chainable
4168
- * @return {this}
4169
- */
4170
-
4171
-
4172
- __proto.updateAnchors = function () {
4173
- var flicking = getFlickingAttached(this._flicking);
4174
- var panels = flicking.renderer.panels;
4175
- this._anchors = panels.map(function (panel, index) {
4176
- return new AnchorPoint({
4177
- index: index,
4178
- position: panel.position,
4179
- panel: panel
4180
- });
4181
- });
4182
- return this;
4183
- };
4184
- /**
4185
- * Update Viewport's height to active panel's height
4186
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4187
- * @throws {FlickingError}
4188
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4189
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4190
- * @chainable
4191
- * @return {this}
4192
- */
4193
-
4194
-
4195
- __proto.updateAdaptiveHeight = function () {
4196
- var flicking = getFlickingAttached(this._flicking);
4197
- var activePanel = flicking.control.activePanel;
4198
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4199
- flicking.viewport.setSize({
4200
- height: activePanel.height
4201
- });
4202
- };
4203
- /**
4204
- * Update current offset of the camera
4205
- * @ko 현재 카메라의 오프셋을 업데이트합니다
4206
- * @chainable
4207
- * @return {this}
4208
- */
4209
-
4210
-
4211
- __proto.updateOffset = function () {
4212
- var flicking = getFlickingAttached(this._flicking);
4213
- var position = this._position;
4214
- var unRenderedPanels = flicking.panels.filter(function (panel) {
4215
- return !panel.rendered;
4216
- });
4217
- this._offset = unRenderedPanels.filter(function (panel) {
4218
- return panel.position + panel.offset < position;
4219
- }).reduce(function (offset, panel) {
4220
- return offset + panel.sizeIncludingMargin;
4221
- }, 0);
4222
- this.applyTransform();
4223
- return this;
4224
- };
4225
- /**
4226
- * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4227
- * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
4228
- * @chainable
4229
- * @return {this}
4230
- */
4124
+ if (prefixedTransform in supportedStyle) {
4125
+ transformName = prefixedTransform;
4126
+ }
4127
+ }
4128
+ } catch (e_1_1) {
4129
+ e_1 = {
4130
+ error: e_1_1
4131
+ };
4132
+ } finally {
4133
+ try {
4134
+ if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
4135
+ } finally {
4136
+ if (e_1) throw e_1.error;
4137
+ }
4138
+ }
4231
4139
 
4140
+ if (!transformName) {
4141
+ throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
4142
+ }
4232
4143
 
4233
- __proto.resetNeedPanelHistory = function () {
4234
- this._needPanelTriggered = {
4235
- prev: false,
4236
- next: false
4144
+ _this._transform = transformName;
4237
4145
  };
4238
- return this;
4239
- };
4240
- /**
4241
- * Apply "transform" style with the current position to camera element
4242
- * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
4243
- * @chainable
4244
- * @return {this}
4245
- */
4246
4146
 
4147
+ this._flicking = null;
4247
4148
 
4248
- __proto.applyTransform = function () {
4249
- var el = this._el;
4250
- var flicking = getFlickingAttached(this._flicking);
4251
- var actualPosition = this._position - this._alignPos - this._offset;
4252
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4253
- return this;
4254
- };
4149
+ this._resetInternalValues(); // Options
4255
4150
 
4256
- __proto._resetInternalValues = function () {
4257
- this._position = 0;
4258
- this._alignPos = 0;
4259
- this._offset = 0;
4260
- this._range = {
4261
- min: 0,
4262
- max: 0
4263
- };
4264
- this._visiblePanels = [];
4265
- this._anchors = [];
4266
- this._needPanelTriggered = {
4267
- prev: false,
4268
- next: false
4269
- };
4270
- };
4271
4151
 
4272
- __proto._refreshVisiblePanels = function () {
4273
- var _this = this;
4152
+ this._align = align;
4153
+ }
4274
4154
 
4275
- var flicking = getFlickingAttached(this._flicking);
4276
- var panels = flicking.renderer.panels;
4277
- var newVisiblePanels = panels.filter(function (panel) {
4278
- return _this.canSee(panel);
4279
- });
4280
- var prevVisiblePanels = this._visiblePanels;
4281
- this._visiblePanels = newVisiblePanels;
4282
- var added = newVisiblePanels.filter(function (panel) {
4283
- return !includes(prevVisiblePanels, panel);
4284
- });
4285
- var removed = prevVisiblePanels.filter(function (panel) {
4286
- return !includes(newVisiblePanels, panel);
4287
- });
4155
+ var __proto = Camera.prototype;
4156
+ Object.defineProperty(__proto, "element", {
4157
+ // Internal states getter
4158
+
4159
+ /**
4160
+ * The camera element(`.flicking-camera`)
4161
+ * @ko 카메라 엘리먼트(`.flicking-camera`)
4162
+ * @type {HTMLElement}
4163
+ * @readonly
4164
+ */
4165
+ get: function () {
4166
+ return this._el;
4167
+ },
4168
+ enumerable: false,
4169
+ configurable: true
4170
+ });
4171
+ Object.defineProperty(__proto, "children", {
4172
+ /**
4173
+ * An array of the child elements of the camera element(`.flicking-camera`)
4174
+ * @ko 카메라 엘리먼트(`.flicking-camera`)의 자식 엘리먼트 배열
4175
+ * @type {HTMLElement[]}
4176
+ * @readonly
4177
+ */
4178
+ get: function () {
4179
+ return toArray(this._el.children);
4180
+ },
4181
+ enumerable: false,
4182
+ configurable: true
4183
+ });
4184
+ Object.defineProperty(__proto, "position", {
4185
+ /**
4186
+ * Current position of the camera
4187
+ * @ko Camera의 현재 좌표
4188
+ * @type {number}
4189
+ * @readonly
4190
+ */
4191
+ get: function () {
4192
+ return this._position;
4193
+ },
4194
+ enumerable: false,
4195
+ configurable: true
4196
+ });
4197
+ Object.defineProperty(__proto, "alignPosition", {
4198
+ /**
4199
+ * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
4200
+ * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
4201
+ * @type {number}
4202
+ * @readonly
4203
+ */
4204
+ get: function () {
4205
+ return this._alignPos;
4206
+ },
4207
+ enumerable: false,
4208
+ configurable: true
4209
+ });
4210
+ Object.defineProperty(__proto, "offset", {
4211
+ /**
4212
+ * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
4213
+ * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
4214
+ * @type {number}
4215
+ * @default 0
4216
+ * @readonly
4217
+ */
4218
+ get: function () {
4219
+ return this._offset - this._circularOffset;
4220
+ },
4221
+ enumerable: false,
4222
+ configurable: true
4223
+ });
4224
+ Object.defineProperty(__proto, "circularEnabled", {
4225
+ /**
4226
+ * Whether the `circular` option is enabled.
4227
+ * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
4228
+ * @ko {@link Flicking#circular circular} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
4229
+ * {@link Flicking#circular circular} 옵션은 패널의 크기의 합이 충분하지 않을 경우 비활성화됩니다.
4230
+ * @type {boolean}
4231
+ * @default false
4232
+ * @readonly
4233
+ */
4234
+ get: function () {
4235
+ return this._circularEnabled;
4236
+ },
4237
+ enumerable: false,
4238
+ configurable: true
4239
+ });
4240
+ Object.defineProperty(__proto, "mode", {
4241
+ /**
4242
+ * A current camera mode
4243
+ * @type {CameraMode}
4244
+ * @readonly
4245
+ */
4246
+ get: function () {
4247
+ return this._mode;
4248
+ },
4249
+ enumerable: false,
4250
+ configurable: true
4251
+ });
4252
+ Object.defineProperty(__proto, "range", {
4253
+ /**
4254
+ * A range that Camera's {@link Camera#position position} can reach
4255
+ * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
4256
+ * @type {object}
4257
+ * @property {number} min A minimum position<ko>최소 위치</ko>
4258
+ * @property {number} max A maximum position<ko>최대 위치</ko>
4259
+ * @readonly
4260
+ */
4261
+ get: function () {
4262
+ return this._range;
4263
+ },
4264
+ enumerable: false,
4265
+ configurable: true
4266
+ });
4267
+ Object.defineProperty(__proto, "rangeDiff", {
4268
+ /**
4269
+ * A difference between Camera's minimum and maximum position that can reach
4270
+ * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
4271
+ * @type {number}
4272
+ * @readonly
4273
+ */
4274
+ get: function () {
4275
+ return this._range.max - this._range.min;
4276
+ },
4277
+ enumerable: false,
4278
+ configurable: true
4279
+ });
4280
+ Object.defineProperty(__proto, "visiblePanels", {
4281
+ /**
4282
+ * An array of visible panels from the current position
4283
+ * @ko 현재 보이는 패널들의 배열
4284
+ * @type {Panel[]}
4285
+ * @readonly
4286
+ */
4287
+ get: function () {
4288
+ return this._visiblePanels;
4289
+ },
4290
+ enumerable: false,
4291
+ configurable: true
4292
+ });
4293
+ Object.defineProperty(__proto, "visibleRange", {
4294
+ /**
4295
+ * A range of the visible area from the current position
4296
+ * @ko 현재 위치에서 보이는 범위
4297
+ * @type {object}
4298
+ * @property {number} min A minimum position<ko>최소 위치</ko>
4299
+ * @property {number} min A maximum position<ko>최대 위치</ko>
4300
+ * @readonly
4301
+ */
4302
+ get: function () {
4303
+ return {
4304
+ min: this._position - this._alignPos,
4305
+ max: this._position - this._alignPos + this.size
4306
+ };
4307
+ },
4308
+ enumerable: false,
4309
+ configurable: true
4310
+ });
4311
+ Object.defineProperty(__proto, "anchorPoints", {
4312
+ /**
4313
+ * An array of {@link AnchorPoint}s that Camera can be stopped at
4314
+ * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
4315
+ * @type {AnchorPoint[]}
4316
+ * @readonly
4317
+ */
4318
+ get: function () {
4319
+ return this._anchors;
4320
+ },
4321
+ enumerable: false,
4322
+ configurable: true
4323
+ });
4324
+ Object.defineProperty(__proto, "controlParams", {
4325
+ /**
4326
+ * A current parameters of the Camera for updating {@link AxesController}
4327
+ * @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
4328
+ * @type {ControlParams}
4329
+ * @readonly
4330
+ */
4331
+ get: function () {
4332
+ return {
4333
+ range: this._range,
4334
+ position: this._position,
4335
+ circular: this._circularEnabled
4336
+ };
4337
+ },
4338
+ enumerable: false,
4339
+ configurable: true
4340
+ });
4341
+ Object.defineProperty(__proto, "atEdge", {
4342
+ /**
4343
+ * A Boolean value indicating whether Camera's over the minimum or maximum position reachable
4344
+ * @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
4345
+ * @type {boolean}
4346
+ * @readonly
4347
+ */
4348
+ get: function () {
4349
+ return this._position <= this._range.min || this._position >= this._range.max;
4350
+ },
4351
+ enumerable: false,
4352
+ configurable: true
4353
+ });
4354
+ Object.defineProperty(__proto, "size", {
4355
+ /**
4356
+ * Return the size of the viewport
4357
+ * @ko 뷰포트 크기를 반환합니다
4358
+ * @type {number}
4359
+ * @readonly
4360
+ */
4361
+ get: function () {
4362
+ var flicking = this._flicking;
4363
+ return flicking ? flicking.horizontal ? flicking.viewport.width : flicking.viewport.height : 0;
4364
+ },
4365
+ enumerable: false,
4366
+ configurable: true
4367
+ });
4368
+ Object.defineProperty(__proto, "progress", {
4369
+ /**
4370
+ * Return the camera's position progress from the first panel to last panel
4371
+ * Range is from 0 to last panel's index
4372
+ * @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
4373
+ * 범위는 0부터 마지막 패널의 인덱스까지입니다
4374
+ * @type {number}
4375
+ * @readonly
4376
+ */
4377
+ get: function () {
4378
+ var flicking = this._flicking;
4379
+ var position = this._position + this._offset;
4380
+ var nearestAnchor = this.findNearestAnchor(this._position);
4288
4381
 
4289
- if (added.length > 0 || removed.length > 0) {
4290
- void flicking.renderer.render().then(function () {
4291
- flicking.trigger(new Component.ComponentEvent(EVENTS.VISIBLE_CHANGE, {
4292
- added: added,
4293
- removed: removed,
4294
- visiblePanels: newVisiblePanels
4295
- }));
4296
- });
4297
- }
4298
- };
4382
+ if (!flicking || !nearestAnchor) {
4383
+ return NaN;
4384
+ }
4299
4385
 
4300
- __proto._checkNeedPanel = function () {
4301
- var needPanelTriggered = this._needPanelTriggered;
4302
- if (needPanelTriggered.prev && needPanelTriggered.next) return;
4303
- var flicking = getFlickingAttached(this._flicking);
4304
- var panels = flicking.renderer.panels;
4386
+ var nearestPanel = nearestAnchor.panel;
4387
+ var panelPos = nearestPanel.position + nearestPanel.offset;
4388
+ var bounceSize = flicking.control.controller.bounce;
4389
+ var _a = this.range,
4390
+ prevRange = _a.min,
4391
+ nextRange = _a.max;
4392
+ var rangeDiff = this.rangeDiff;
4305
4393
 
4306
- if (panels.length <= 0) {
4307
- if (!needPanelTriggered.prev) {
4308
- flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4309
- direction: DIRECTION.PREV
4310
- }));
4311
- needPanelTriggered.prev = true;
4394
+ if (position === panelPos) {
4395
+ return nearestPanel.index;
4312
4396
  }
4313
4397
 
4314
- if (!needPanelTriggered.next) {
4315
- flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4316
- direction: DIRECTION.NEXT
4317
- }));
4318
- needPanelTriggered.next = true;
4319
- }
4398
+ if (position < panelPos) {
4399
+ var prevPanel = nearestPanel.prev();
4400
+ var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
4320
4401
 
4321
- return;
4322
- }
4402
+ if (prevPosition > panelPos) {
4403
+ prevPosition -= rangeDiff;
4404
+ }
4323
4405
 
4324
- var cameraPosition = this._position;
4325
- var cameraSize = this.size;
4326
- var cameraRange = this._range;
4327
- var needPanelThreshold = flicking.needPanelThreshold;
4328
- var cameraPrev = cameraPosition - this._alignPos;
4329
- var cameraNext = cameraPrev + cameraSize;
4330
- var firstPanel = panels[0];
4331
- var lastPanel = panels[panels.length - 1];
4406
+ return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
4407
+ } else {
4408
+ var nextPanel = nearestPanel.next();
4409
+ var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1]; // Looped
4332
4410
 
4333
- if (!needPanelTriggered.prev) {
4334
- var firstPanelPrev = firstPanel.range.min;
4411
+ if (nextPosition < panelPos) {
4412
+ nextPosition += rangeDiff;
4413
+ }
4335
4414
 
4336
- if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
4337
- flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4338
- direction: DIRECTION.PREV
4339
- }));
4340
- needPanelTriggered.prev = true;
4415
+ return nearestPanel.index + getProgress(position, panelPos, nextPosition);
4341
4416
  }
4342
- }
4417
+ },
4418
+ enumerable: false,
4419
+ configurable: true
4420
+ });
4421
+ Object.defineProperty(__proto, "align", {
4422
+ // Options Getter
4343
4423
 
4344
- if (!needPanelTriggered.next) {
4345
- var lastPanelNext = lastPanel.range.max;
4424
+ /**
4425
+ * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
4426
+ * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
4427
+ * @type {ALIGN | string | number}
4428
+ */
4429
+ get: function () {
4430
+ return this._align;
4431
+ },
4432
+ // Options Setter
4433
+ set: function (val) {
4434
+ this._align = val;
4435
+ },
4436
+ enumerable: false,
4437
+ configurable: true
4438
+ });
4439
+ /**
4440
+ * Initialize Camera
4441
+ * @ko Camera를 초기화합니다
4442
+ * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
4443
+ * @chainable
4444
+ * @throws {FlickingError}
4445
+ * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
4446
+ * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
4447
+ * @return {this}
4448
+ */
4346
4449
 
4347
- if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
4348
- flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4349
- direction: DIRECTION.NEXT
4350
- }));
4351
- needPanelTriggered.next = true;
4352
- }
4353
- }
4354
- };
4450
+ __proto.init = function (flicking) {
4451
+ this._flicking = flicking;
4452
+ var viewportEl = flicking.viewport.element;
4453
+ checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
4454
+ this._el = viewportEl.firstElementChild;
4355
4455
 
4356
- __proto._checkReachEnd = function (prevPos, newPos) {
4357
- var flicking = getFlickingAttached(this._flicking);
4358
- var range = this._range;
4359
- var wasBetweenRange = prevPos > range.min && prevPos < range.max;
4360
- var isBetweenRange = newPos > range.min && newPos < range.max;
4361
- if (!wasBetweenRange || isBetweenRange) return;
4362
- var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
4363
- flicking.trigger(new Component.ComponentEvent(EVENTS.REACH_EDGE, {
4364
- direction: direction
4365
- }));
4456
+ this._checkTranslateSupport();
4457
+
4458
+ this._updateMode();
4459
+
4460
+ return this;
4366
4461
  };
4462
+ /**
4463
+ * Destroy Camera and return to initial state
4464
+ * @ko Camera를 초기 상태로 되돌립니다
4465
+ * @return {void}
4466
+ */
4367
4467
 
4368
- return Camera;
4369
- }();
4370
4468
 
4371
- /**
4372
- * A {@link Camera} that can move from the position of the first panel to the position of the last panel
4373
- * @ko 첫번째 패널의 좌표로부터 마지막 패널의 좌표로까지 이동할 수 있는 종류의 {@link Camera}
4374
- */
4469
+ __proto.destroy = function () {
4470
+ this._flicking = null;
4375
4471
 
4376
- var LinearCamera =
4377
- /*#__PURE__*/
4378
- function (_super) {
4379
- __extends(LinearCamera, _super);
4472
+ this._resetInternalValues();
4380
4473
 
4381
- function LinearCamera() {
4382
- return _super !== null && _super.apply(this, arguments) || this;
4383
- }
4474
+ return this;
4475
+ };
4384
4476
  /**
4385
- * Update {@link Camera#range range} of Camera
4386
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4387
- * @chainable
4477
+ * Move to the given position and apply CSS transform
4478
+ * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
4479
+ * @param {number} pos A new position<ko>움직일 위치</ko>
4388
4480
  * @throws {FlickingError}
4389
4481
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4390
4482
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -4392,170 +4484,190 @@ version: 4.4.1
4392
4484
  */
4393
4485
 
4394
4486
 
4395
- var __proto = LinearCamera.prototype;
4396
-
4397
- __proto.updateRange = function () {
4398
- var _a, _b;
4487
+ __proto.lookAt = function (pos) {
4488
+ var _this = this;
4399
4489
 
4400
4490
  var flicking = getFlickingAttached(this._flicking);
4401
- var renderer = flicking.renderer;
4402
- var firstPanel = renderer.getPanel(0);
4403
- var lastPanel = renderer.getPanel(renderer.panelCount - 1);
4404
- this._range = {
4405
- min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
4406
- max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
4407
- };
4408
- return this;
4409
- };
4491
+ var prevPos = this._position;
4492
+ this._position = pos;
4410
4493
 
4411
- return LinearCamera;
4412
- }(Camera$1);
4494
+ var toggled = this._togglePanels(prevPos, pos);
4413
4495
 
4414
- /**
4415
- * A {@link Camera} that connects the last panel and the first panel, enabling continuous loop
4416
- * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera}
4417
- */
4496
+ this._refreshVisiblePanels();
4418
4497
 
4419
- var CircularCamera =
4420
- /*#__PURE__*/
4421
- function (_super) {
4422
- __extends(CircularCamera, _super);
4498
+ this._checkNeedPanel();
4423
4499
 
4424
- function CircularCamera() {
4425
- var _this = _super !== null && _super.apply(this, arguments) || this;
4500
+ this._checkReachEnd(prevPos, pos);
4426
4501
 
4427
- _this._circularOffset = 0;
4428
- _this._circularEnabled = false;
4429
- return _this;
4430
- }
4502
+ this.applyTransform();
4503
+
4504
+ if (toggled) {
4505
+ void flicking.renderer.render().then(function () {
4506
+ _this.updateOffset();
4507
+ });
4508
+ }
4509
+ };
4510
+ /**
4511
+ * Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
4512
+ * If it does not exist, return `null` instead
4513
+ * @ko 주어진 {@link AnchorPoint}의 이전 {@link AnchorPoint}를 반환합니다
4514
+ * 존재하지 않을 경우 `null`을 반환합니다
4515
+ * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
4516
+ * @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
4517
+ */
4431
4518
 
4432
- var __proto = CircularCamera.prototype;
4433
- Object.defineProperty(__proto, "offset", {
4434
- get: function () {
4435
- return this._offset - this._circularOffset;
4436
- },
4437
- enumerable: false,
4438
- configurable: true
4439
- });
4440
- Object.defineProperty(__proto, "controlParams", {
4441
- get: function () {
4442
- return {
4443
- range: this._range,
4444
- position: this._position,
4445
- circular: this._circularEnabled
4446
- };
4447
- },
4448
- enumerable: false,
4449
- configurable: true
4450
- });
4451
4519
 
4452
4520
  __proto.getPrevAnchor = function (anchor) {
4453
- if (!this._circularEnabled || anchor.index !== 0) return _super.prototype.getPrevAnchor.call(this, anchor);
4521
+ if (!this._circularEnabled || anchor.index !== 0) {
4522
+ return this._anchors[anchor.index - 1] || null;
4523
+ } else {
4524
+ var anchors = this._anchors;
4525
+ var rangeDiff = this.rangeDiff;
4526
+ var lastAnchor = anchors[anchors.length - 1];
4527
+ return new AnchorPoint({
4528
+ index: lastAnchor.index,
4529
+ position: lastAnchor.position - rangeDiff,
4530
+ panel: lastAnchor.panel
4531
+ });
4532
+ }
4533
+ };
4534
+ /**
4535
+ * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
4536
+ * If it does not exist, return `null` instead
4537
+ * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
4538
+ * 존재하지 않을 경우 `null`을 반환합니다
4539
+ * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
4540
+ * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
4541
+ */
4542
+
4543
+
4544
+ __proto.getNextAnchor = function (anchor) {
4454
4545
  var anchors = this._anchors;
4455
- var rangeDiff = this.rangeDiff;
4456
- var lastAnchor = anchors[anchors.length - 1];
4457
- return new AnchorPoint({
4458
- index: lastAnchor.index,
4459
- position: lastAnchor.position - rangeDiff,
4460
- panel: lastAnchor.panel
4461
- });
4546
+
4547
+ if (!this._circularEnabled || anchor.index !== anchors.length - 1) {
4548
+ return anchors[anchor.index + 1] || null;
4549
+ } else {
4550
+ var rangeDiff = this.rangeDiff;
4551
+ var firstAnchor = anchors[0];
4552
+ return new AnchorPoint({
4553
+ index: firstAnchor.index,
4554
+ position: firstAnchor.position + rangeDiff,
4555
+ panel: firstAnchor.panel
4556
+ });
4557
+ }
4462
4558
  };
4559
+ /**
4560
+ * Return the camera's position progress in the panel below
4561
+ * Value is from 0 to 1 when the camera's inside panel
4562
+ * Value can be lower than 0 or bigger than 1 when it's in the margin area
4563
+ * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
4564
+ * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
4565
+ * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
4566
+ */
4463
4567
 
4464
- __proto.getNextAnchor = function (anchor) {
4465
- var anchors = this._anchors;
4466
- if (!this._circularEnabled || anchor.index !== anchors.length - 1) return _super.prototype.getNextAnchor.call(this, anchor);
4467
- var rangeDiff = this.rangeDiff;
4468
- var firstAnchor = anchors[0];
4469
- return new AnchorPoint({
4470
- index: firstAnchor.index,
4471
- position: firstAnchor.position + rangeDiff,
4472
- panel: firstAnchor.panel
4473
- });
4568
+
4569
+ __proto.getProgressInPanel = function (panel) {
4570
+ var panelRange = panel.range;
4571
+ return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
4474
4572
  };
4573
+ /**
4574
+ * Return {@link AnchorPoint} that includes given position
4575
+ * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
4576
+ * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
4577
+ * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
4578
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
4579
+ * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
4580
+ */
4581
+
4475
4582
 
4476
4583
  __proto.findAnchorIncludePosition = function (position) {
4477
- if (!this._circularEnabled) return _super.prototype.findAnchorIncludePosition.call(this, position);
4478
- var range = this._range;
4584
+ return this._mode.findAnchorIncludePosition(position);
4585
+ };
4586
+ /**
4587
+ * Return {@link AnchorPoint} nearest to given position
4588
+ * If there're no {@link AnchorPoint}s, return `null` instead
4589
+ * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
4590
+ * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
4591
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
4592
+ * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
4593
+ */
4594
+
4595
+
4596
+ __proto.findNearestAnchor = function (position) {
4479
4597
  var anchors = this._anchors;
4480
- var rangeDiff = this.rangeDiff;
4481
- var anchorCount = anchors.length;
4482
- var positionInRange = circulatePosition(position, range.min, range.max);
4598
+ if (anchors.length <= 0) return null;
4599
+ var prevDist = Infinity;
4483
4600
 
4484
- var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
4601
+ for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
4602
+ var anchor = anchors[anchorIdx];
4603
+ var dist = Math.abs(anchor.position - position);
4485
4604
 
4486
- if (anchorCount > 0 && (position === range.min || position === range.max)) {
4487
- var possibleAnchors = [anchorInRange, new AnchorPoint({
4488
- index: 0,
4489
- position: anchors[0].position + rangeDiff,
4490
- panel: anchors[0].panel
4491
- }), new AnchorPoint({
4492
- index: anchorCount - 1,
4493
- position: anchors[anchorCount - 1].position - rangeDiff,
4494
- panel: anchors[anchorCount - 1].panel
4495
- })].filter(function (anchor) {
4496
- return !!anchor;
4497
- });
4498
- anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
4499
- if (!nearest) return anchor;
4500
- return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
4501
- }, null);
4502
- }
4605
+ if (dist > prevDist) {
4606
+ // Return previous anchor
4607
+ return anchors[anchorIdx - 1];
4608
+ }
4503
4609
 
4504
- if (!anchorInRange) return null;
4610
+ prevDist = dist;
4611
+ } // Return last anchor
4505
4612
 
4506
- if (position < range.min) {
4507
- var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
4508
- return new AnchorPoint({
4509
- index: anchorInRange.index,
4510
- position: anchorInRange.position + rangeDiff * loopCount,
4511
- panel: anchorInRange.panel
4512
- });
4513
- } else if (position > range.max) {
4514
- var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
4515
- return new AnchorPoint({
4516
- index: anchorInRange.index,
4517
- position: anchorInRange.position + rangeDiff * loopCount,
4518
- panel: anchorInRange.panel
4519
- });
4520
- }
4521
4613
 
4522
- return anchorInRange;
4614
+ return anchors[anchors.length - 1];
4523
4615
  };
4616
+ /**
4617
+ * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
4618
+ * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
4619
+ * @return {AnchorPoint | null}
4620
+ */
4524
4621
 
4525
- __proto.clampToReachablePosition = function (position) {
4526
- // Basically all position is reachable for circular camera
4527
- return this._circularEnabled ? position : _super.prototype.clampToReachablePosition.call(this, position);
4528
- };
4529
4622
 
4530
- __proto.canReach = function (panel) {
4531
- if (panel.removed) return false;
4532
- return this._circularEnabled // Always reachable on circular mode
4533
- ? true : _super.prototype.canReach.call(this, panel);
4623
+ __proto.findActiveAnchor = function () {
4624
+ var flicking = getFlickingAttached(this._flicking);
4625
+ var activeIndex = flicking.control.activeIndex;
4626
+ return find(this._anchors, function (anchor) {
4627
+ return anchor.panel.index === activeIndex;
4628
+ });
4534
4629
  };
4630
+ /**
4631
+ * Clamp the given position between camera's range
4632
+ * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
4633
+ * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
4634
+ * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
4635
+ */
4535
4636
 
4536
- __proto.canSee = function (panel) {
4537
- var range = this._range;
4538
- var rangeDiff = this.rangeDiff;
4539
- var visibleRange = this.visibleRange;
4540
4637
 
4541
- var visibleInCurrentRange = _super.prototype.canSee.call(this, panel);
4638
+ __proto.clampToReachablePosition = function (position) {
4639
+ return this._mode.clampToReachablePosition(position);
4640
+ };
4641
+ /**
4642
+ * Check whether the given panel is inside of the Camera's range
4643
+ * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
4644
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4645
+ * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
4646
+ */
4542
4647
 
4543
- if (!this._circularEnabled) {
4544
- return visibleInCurrentRange;
4545
- } // Check looped visible area for circular case
4546
4648
 
4649
+ __proto.canReach = function (panel) {
4650
+ return this._mode.canReach(panel);
4651
+ };
4652
+ /**
4653
+ * Check whether the given panel element is visible at the current position
4654
+ * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
4655
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4656
+ * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
4657
+ */
4547
4658
 
4548
- if (visibleRange.min < range.min) {
4549
- return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
4550
- } else if (visibleRange.max > range.max) {
4551
- return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
4552
- }
4553
4659
 
4554
- return visibleInCurrentRange;
4660
+ __proto.canSee = function (panel) {
4661
+ return this._mode.canSee(panel);
4555
4662
  };
4556
4663
  /**
4557
4664
  * Update {@link Camera#range range} of Camera
4558
4665
  * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4666
+ * @method
4667
+ * @abstract
4668
+ * @memberof Camera
4669
+ * @instance
4670
+ * @name updateRange
4559
4671
  * @chainable
4560
4672
  * @throws {FlickingError}
4561
4673
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
@@ -4569,287 +4681,269 @@ version: 4.4.1
4569
4681
  var renderer = flicking.renderer;
4570
4682
  var panels = renderer.panels;
4571
4683
 
4572
- if (panels.length <= 0) {
4573
- this._resetInternalValues();
4574
-
4575
- return this;
4576
- }
4684
+ this._updateMode();
4577
4685
 
4578
- var firstPanel = panels[0];
4579
- var lastPanel = panels[panels.length - 1];
4580
- var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
4581
- var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
4582
- var visibleSize = this.size;
4583
- var panelSizeSum = lastPanelNext - firstPanelPrev;
4584
- var canSetCircularMode = panels.every(function (panel) {
4585
- return panelSizeSum - panel.size >= visibleSize;
4586
- });
4587
- this._circularEnabled = canSetCircularMode;
4686
+ this._range = this._mode.getRange();
4588
4687
 
4589
- if (canSetCircularMode) {
4590
- this._range = {
4591
- min: firstPanelPrev,
4592
- max: lastPanelNext
4593
- };
4688
+ if (this._circularEnabled) {
4594
4689
  panels.forEach(function (panel) {
4595
4690
  return panel.updateCircularToggleDirection();
4596
4691
  });
4597
- } else {
4598
- this._range = {
4599
- min: firstPanel.position,
4600
- max: lastPanel.position
4601
- };
4602
4692
  }
4603
4693
 
4604
4694
  this.updateOffset();
4605
4695
  return this;
4606
4696
  };
4697
+ /**
4698
+ * Update Camera's {@link Camera#alignPosition alignPosition}
4699
+ * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
4700
+ * @chainable
4701
+ * @return {this}
4702
+ */
4607
4703
 
4608
- __proto.updateOffset = function () {
4609
- this._updateCircularOffset();
4610
4704
 
4611
- return _super.prototype.updateOffset.call(this);
4705
+ __proto.updateAlignPos = function () {
4706
+ var align = this._align;
4707
+ var alignVal = typeof align === "object" ? align.camera : align;
4708
+ this._alignPos = parseAlign$1(alignVal, this.size);
4709
+ return this;
4612
4710
  };
4711
+ /**
4712
+ * Update Camera's {@link Camera#anchorPoints anchorPoints}
4713
+ * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
4714
+ * @throws {FlickingError}
4715
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4716
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4717
+ * @chainable
4718
+ * @return {this}
4719
+ */
4613
4720
 
4614
- __proto.lookAt = function (pos) {
4615
- var _this = this;
4616
-
4617
- var flicking = getFlickingAttached(this._flicking);
4618
- var prevPos = this._position;
4619
- if (pos === prevPos) return _super.prototype.lookAt.call(this, pos);
4620
- var panels = flicking.renderer.panels;
4621
- var toggled = panels.map(function (panel) {
4622
- return panel.toggle(prevPos, pos);
4623
- });
4624
- this._position = pos;
4625
-
4626
- _super.prototype.lookAt.call(this, pos);
4627
-
4628
- if (toggled.some(function (isToggled) {
4629
- return isToggled;
4630
- })) {
4631
- void flicking.renderer.render().then(function () {
4632
- _this.updateOffset();
4633
- });
4634
- }
4635
- };
4636
4721
 
4637
- __proto.applyTransform = function () {
4638
- var el = this._el;
4639
- var flicking = getFlickingAttached(this._flicking);
4640
- var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4641
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4722
+ __proto.updateAnchors = function () {
4723
+ this._anchors = this._mode.getAnchors();
4642
4724
  return this;
4643
4725
  };
4726
+ /**
4727
+ * Update Viewport's height to active panel's height
4728
+ * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4729
+ * @throws {FlickingError}
4730
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4731
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4732
+ * @chainable
4733
+ * @return {this}
4734
+ */
4644
4735
 
4645
- __proto._resetInternalValues = function () {
4646
- _super.prototype._resetInternalValues.call(this);
4647
-
4648
- this._circularOffset = 0;
4649
- this._circularEnabled = false;
4650
- };
4651
4736
 
4652
- __proto._calcPanelAreaSum = function (panels) {
4653
- return panels.reduce(function (sum, panel) {
4654
- return sum + panel.sizeIncludingMargin;
4655
- }, 0);
4737
+ __proto.updateAdaptiveHeight = function () {
4738
+ var flicking = getFlickingAttached(this._flicking);
4739
+ var activePanel = flicking.control.activePanel;
4740
+ if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4741
+ flicking.viewport.setSize({
4742
+ height: activePanel.height
4743
+ });
4656
4744
  };
4745
+ /**
4746
+ * Update current offset of the camera
4747
+ * @ko 현재 카메라의 오프셋을 업데이트합니다
4748
+ * @chainable
4749
+ * @return {this}
4750
+ */
4657
4751
 
4658
- __proto._updateCircularOffset = function () {
4659
- if (!this._circularEnabled) {
4660
- this._circularOffset = 0;
4661
- return;
4662
- }
4663
4752
 
4753
+ __proto.updateOffset = function () {
4664
4754
  var flicking = getFlickingAttached(this._flicking);
4665
- var toggled = flicking.panels.filter(function (panel) {
4666
- return panel.toggled;
4667
- });
4668
- var toggledPrev = toggled.filter(function (panel) {
4669
- return panel.toggleDirection === DIRECTION.PREV;
4670
- });
4671
- var toggledNext = toggled.filter(function (panel) {
4672
- return panel.toggleDirection === DIRECTION.NEXT;
4755
+ var position = this._position;
4756
+ var unRenderedPanels = flicking.panels.filter(function (panel) {
4757
+ return !panel.rendered;
4673
4758
  });
4674
- this._circularOffset = this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
4759
+ this._offset = unRenderedPanels.filter(function (panel) {
4760
+ return panel.position + panel.offset < position;
4761
+ }).reduce(function (offset, panel) {
4762
+ return offset + panel.sizeIncludingMargin;
4763
+ }, 0);
4764
+ this._circularOffset = this._mode.getCircularOffset();
4765
+ this.applyTransform();
4766
+ return this;
4675
4767
  };
4768
+ /**
4769
+ * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4770
+ * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
4771
+ * @chainable
4772
+ * @return {this}
4773
+ */
4676
4774
 
4677
- return CircularCamera;
4678
- }(Camera$1);
4679
-
4680
- /**
4681
- * 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
4682
- * @ko 첫번째와 마지막 패널 밖으로 넘어가지 못하도록 범위를 설정하여, 첫번째/마지막 패널 전/후의 빈 공간을 보이지 않도록 하는 종류의 {@link Camera}
4683
- */
4684
-
4685
- var BoundCamera =
4686
- /*#__PURE__*/
4687
- function (_super) {
4688
- __extends(BoundCamera, _super);
4689
4775
 
4690
- function BoundCamera() {
4691
- return _super !== null && _super.apply(this, arguments) || this;
4692
- }
4776
+ __proto.resetNeedPanelHistory = function () {
4777
+ this._needPanelTriggered = {
4778
+ prev: false,
4779
+ next: false
4780
+ };
4781
+ return this;
4782
+ };
4693
4783
  /**
4694
- * Update {@link Camera#range range} of Camera
4695
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4784
+ * Apply "transform" style with the current position to camera element
4785
+ * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
4696
4786
  * @chainable
4697
- * @throws {FlickingError}
4698
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4699
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4700
4787
  * @return {this}
4701
4788
  */
4702
4789
 
4703
4790
 
4704
- var __proto = BoundCamera.prototype;
4705
-
4706
- __proto.updateRange = function () {
4791
+ __proto.applyTransform = function () {
4792
+ var el = this._el;
4707
4793
  var flicking = getFlickingAttached(this._flicking);
4708
- var renderer = flicking.renderer;
4709
- var alignPos = this._alignPos;
4710
- var firstPanel = renderer.getPanel(0);
4711
- var lastPanel = renderer.getPanel(renderer.panelCount - 1);
4712
-
4713
- if (!firstPanel || !lastPanel) {
4714
- this._range = {
4715
- min: 0,
4716
- max: 0
4717
- };
4718
- return this;
4719
- }
4720
-
4721
- var viewportSize = this.size;
4722
- var firstPanelPrev = firstPanel.range.min;
4723
- var lastPanelNext = lastPanel.range.max;
4724
- var panelAreaSize = lastPanelNext - firstPanelPrev;
4725
- var isBiggerThanViewport = viewportSize < panelAreaSize;
4726
- var firstPos = firstPanelPrev + alignPos;
4727
- var lastPos = lastPanelNext - viewportSize + alignPos;
4728
-
4729
- if (isBiggerThanViewport) {
4730
- this._range = {
4731
- min: firstPos,
4732
- max: lastPos
4733
- };
4734
- } else {
4735
- var align = this._align;
4736
- var alignVal = typeof align === "object" ? align.camera : align;
4737
- var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
4738
- this._range = {
4739
- min: pos,
4740
- max: pos
4741
- };
4742
- }
4743
-
4794
+ var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4795
+ el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4744
4796
  return this;
4745
4797
  };
4746
4798
 
4747
- __proto.updateAnchors = function () {
4799
+ __proto._resetInternalValues = function () {
4800
+ this._position = 0;
4801
+ this._alignPos = 0;
4802
+ this._offset = 0;
4803
+ this._circularOffset = 0;
4804
+ this._circularEnabled = false;
4805
+ this._range = {
4806
+ min: 0,
4807
+ max: 0
4808
+ };
4809
+ this._visiblePanels = [];
4810
+ this._anchors = [];
4811
+ this._needPanelTriggered = {
4812
+ prev: false,
4813
+ next: false
4814
+ };
4815
+ };
4816
+
4817
+ __proto._refreshVisiblePanels = function () {
4748
4818
  var _this = this;
4749
4819
 
4750
4820
  var flicking = getFlickingAttached(this._flicking);
4751
4821
  var panels = flicking.renderer.panels;
4752
-
4753
- if (panels.length <= 0) {
4754
- this._anchors = [];
4755
- return this;
4756
- }
4757
-
4758
- var range = this._range;
4759
- var reachablePanels = panels.filter(function (panel) {
4760
- return _this.canReach(panel);
4822
+ var newVisiblePanels = panels.filter(function (panel) {
4823
+ return _this.canSee(panel);
4824
+ });
4825
+ var prevVisiblePanels = this._visiblePanels;
4826
+ this._visiblePanels = newVisiblePanels;
4827
+ var added = newVisiblePanels.filter(function (panel) {
4828
+ return !includes(prevVisiblePanels, panel);
4829
+ });
4830
+ var removed = prevVisiblePanels.filter(function (panel) {
4831
+ return !includes(newVisiblePanels, panel);
4761
4832
  });
4762
4833
 
4763
- if (reachablePanels.length > 0) {
4764
- var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
4765
- var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
4766
- var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
4767
- var newAnchors = reachablePanels.map(function (panel, idx) {
4768
- return new AnchorPoint({
4769
- index: idx + indexOffset_1,
4770
- position: panel.position,
4771
- panel: panel
4772
- });
4834
+ if (added.length > 0 || removed.length > 0) {
4835
+ void flicking.renderer.render().then(function () {
4836
+ flicking.trigger(new Component.ComponentEvent(EVENTS.VISIBLE_CHANGE, {
4837
+ added: added,
4838
+ removed: removed,
4839
+ visiblePanels: newVisiblePanels
4840
+ }));
4773
4841
  });
4842
+ }
4843
+ };
4774
4844
 
4775
- if (shouldPrependBoundAnchor) {
4776
- newAnchors.splice(0, 0, new AnchorPoint({
4777
- index: 0,
4778
- position: range.min,
4779
- panel: panels[reachablePanels[0].index - 1]
4845
+ __proto._checkNeedPanel = function () {
4846
+ var needPanelTriggered = this._needPanelTriggered;
4847
+ if (needPanelTriggered.prev && needPanelTriggered.next) return;
4848
+ var flicking = getFlickingAttached(this._flicking);
4849
+ var panels = flicking.renderer.panels;
4850
+
4851
+ if (panels.length <= 0) {
4852
+ if (!needPanelTriggered.prev) {
4853
+ flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4854
+ direction: DIRECTION.PREV
4780
4855
  }));
4856
+ needPanelTriggered.prev = true;
4781
4857
  }
4782
4858
 
4783
- if (shouldAppendBoundAnchor) {
4784
- newAnchors.push(new AnchorPoint({
4785
- index: newAnchors.length,
4786
- position: range.max,
4787
- panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
4859
+ if (!needPanelTriggered.next) {
4860
+ flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4861
+ direction: DIRECTION.NEXT
4788
4862
  }));
4863
+ needPanelTriggered.next = true;
4789
4864
  }
4790
4865
 
4791
- this._anchors = newAnchors;
4792
- } else if (range.min !== range.max) {
4793
- // There're more than 2 panels
4794
- var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
4866
+ return;
4867
+ }
4795
4868
 
4796
- var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
4797
- var panelAtMax = panelAtMin.next();
4798
- this._anchors = [new AnchorPoint({
4799
- index: 0,
4800
- position: range.min,
4801
- panel: panelAtMin
4802
- }), new AnchorPoint({
4803
- index: 1,
4804
- position: range.max,
4805
- panel: panelAtMax
4806
- })];
4807
- } else {
4808
- this._anchors = [new AnchorPoint({
4809
- index: 0,
4810
- position: range.min,
4811
- panel: this._findNearestPanel(range.min, panels)
4812
- })];
4869
+ var cameraPosition = this._position;
4870
+ var cameraSize = this.size;
4871
+ var cameraRange = this._range;
4872
+ var needPanelThreshold = flicking.needPanelThreshold;
4873
+ var cameraPrev = cameraPosition - this._alignPos;
4874
+ var cameraNext = cameraPrev + cameraSize;
4875
+ var firstPanel = panels[0];
4876
+ var lastPanel = panels[panels.length - 1];
4877
+
4878
+ if (!needPanelTriggered.prev) {
4879
+ var firstPanelPrev = firstPanel.range.min;
4880
+
4881
+ if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
4882
+ flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4883
+ direction: DIRECTION.PREV
4884
+ }));
4885
+ needPanelTriggered.prev = true;
4886
+ }
4813
4887
  }
4814
4888
 
4815
- return this;
4889
+ if (!needPanelTriggered.next) {
4890
+ var lastPanelNext = lastPanel.range.max;
4891
+
4892
+ if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
4893
+ flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4894
+ direction: DIRECTION.NEXT
4895
+ }));
4896
+ needPanelTriggered.next = true;
4897
+ }
4898
+ }
4816
4899
  };
4817
4900
 
4818
- __proto.findAnchorIncludePosition = function (position) {
4901
+ __proto._checkReachEnd = function (prevPos, newPos) {
4902
+ var flicking = getFlickingAttached(this._flicking);
4819
4903
  var range = this._range;
4820
- var anchors = this._anchors;
4821
- if (anchors.length <= 0) return null;
4822
-
4823
- if (position <= range.min) {
4824
- return anchors[0];
4825
- } else if (position >= range.max) {
4826
- return anchors[anchors.length - 1];
4827
- } else {
4828
- return _super.prototype.findAnchorIncludePosition.call(this, position);
4829
- }
4904
+ var wasBetweenRange = prevPos > range.min && prevPos < range.max;
4905
+ var isBetweenRange = newPos > range.min && newPos < range.max;
4906
+ if (!wasBetweenRange || isBetweenRange) return;
4907
+ var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
4908
+ flicking.trigger(new Component.ComponentEvent(EVENTS.REACH_EDGE, {
4909
+ direction: direction
4910
+ }));
4830
4911
  };
4831
4912
 
4832
- __proto._findNearestPanel = function (pos, panels) {
4833
- var prevDist = Infinity;
4913
+ __proto._updateMode = function () {
4914
+ var flicking = getFlickingAttached(this._flicking);
4834
4915
 
4835
- for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
4836
- var panel = panels[panelIdx];
4837
- var dist = Math.abs(panel.position - pos);
4916
+ if (flicking.circular) {
4917
+ var circularMode = new CircularCameraMode(flicking);
4918
+ var canSetCircularMode = circularMode.checkAvailability();
4838
4919
 
4839
- if (dist > prevDist) {
4840
- // Return previous anchor
4841
- return panels[panelIdx - 1];
4920
+ if (canSetCircularMode) {
4921
+ this._mode = circularMode;
4922
+ } else {
4923
+ var fallbackMode = flicking.circularFallback;
4924
+ this._mode = fallbackMode === CIRCULAR_FALLBACK.BOUND ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
4842
4925
  }
4843
4926
 
4844
- prevDist = dist;
4845
- } // Return last anchor
4846
-
4927
+ this._circularEnabled = canSetCircularMode;
4928
+ } else {
4929
+ this._mode = flicking.bound ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
4930
+ }
4931
+ };
4847
4932
 
4848
- return panels[panels.length - 1];
4933
+ __proto._togglePanels = function (prevPos, pos) {
4934
+ if (pos === prevPos) return false;
4935
+ var flicking = getFlickingAttached(this._flicking);
4936
+ var panels = flicking.renderer.panels;
4937
+ var toggled = panels.map(function (panel) {
4938
+ return panel.toggle(prevPos, pos);
4939
+ });
4940
+ return toggled.some(function (isToggled) {
4941
+ return isToggled;
4942
+ });
4849
4943
  };
4850
4944
 
4851
- return BoundCamera;
4852
- }(Camera$1);
4945
+ return Camera;
4946
+ }();
4853
4947
 
4854
4948
  /*
4855
4949
  * Copyright (c) 2015 NAVER Corp.
@@ -4859,9 +4953,9 @@ version: 4.4.1
4859
4953
  var Camera = {
4860
4954
  __proto__: null,
4861
4955
  Camera: Camera$1,
4862
- LinearCamera: LinearCamera,
4863
- CircularCamera: CircularCamera,
4864
- BoundCamera: BoundCamera
4956
+ LinearCameraMode: LinearCameraMode,
4957
+ CircularCameraMode: CircularCameraMode,
4958
+ BoundCameraMode: BoundCameraMode
4865
4959
  };
4866
4960
 
4867
4961
  /**
@@ -5061,7 +5155,7 @@ version: 4.4.1
5061
5155
  flicking: flicking
5062
5156
  });
5063
5157
  });
5064
- panels.splice.apply(panels, __spreadArray([insertingIdx, 0], __read(panelsInserted)));
5158
+ panels.splice.apply(panels, __spread([insertingIdx, 0], panelsInserted));
5065
5159
 
5066
5160
  if (item.hasDOMInElements) {
5067
5161
  // Insert the actual elements as camera element's children
@@ -5084,7 +5178,7 @@ version: 4.4.1
5084
5178
  panel.increaseIndex(panelsInserted.length);
5085
5179
  panel.updatePosition();
5086
5180
  });
5087
- return __spreadArray(__spreadArray([], __read(addedPanels), false), __read(panelsInserted));
5181
+ return __spread(addedPanels, panelsInserted);
5088
5182
  }, []);
5089
5183
  if (allPanelsInserted.length <= 0) return []; // Update camera & control
5090
5184
 
@@ -5163,7 +5257,7 @@ version: 4.4.1
5163
5257
  control.resetActive();
5164
5258
  }
5165
5259
 
5166
- return __spreadArray(__spreadArray([], __read(removed), false), __read(panelsRemoved));
5260
+ return __spread(removed, panelsRemoved);
5167
5261
  }, []); // Update camera & control
5168
5262
 
5169
5263
  this._updateCameraAndControl();
@@ -6162,7 +6256,7 @@ version: 4.4.1
6162
6256
  var notToggled = renderedPanels.filter(function (panel) {
6163
6257
  return !panel.toggled;
6164
6258
  });
6165
- return __spreadArray(__spreadArray(__spreadArray([], __read(toggledPrev), false), __read(notToggled), false), __read(toggledNext)).map(function (panel) {
6259
+ return __spread(toggledPrev, notToggled, toggledNext).map(function (panel) {
6166
6260
  return panel.index;
6167
6261
  });
6168
6262
  };
@@ -6372,7 +6466,7 @@ version: 4.4.1
6372
6466
  __proto.getRenderingIndexesByOrder = function (flicking) {
6373
6467
  var virtualManager = flicking.virtual;
6374
6468
 
6375
- var visiblePanels = __spreadArray([], __read(flicking.visiblePanels)).filter(function (panel) {
6469
+ var visiblePanels = __spread(flicking.visiblePanels).filter(function (panel) {
6376
6470
  return panel.rendered;
6377
6471
  }).sort(function (panel1, panel2) {
6378
6472
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
@@ -6393,7 +6487,7 @@ version: 4.4.1
6393
6487
  }).map(function (el) {
6394
6488
  return el.idx;
6395
6489
  });
6396
- return __spreadArray(__spreadArray([], __read(visibleIndexes), false), __read(invisibleIndexes));
6490
+ return __spread(visibleIndexes, invisibleIndexes);
6397
6491
  };
6398
6492
 
6399
6493
  __proto.getRenderingElementsByOrder = function (flicking) {
@@ -6516,58 +6610,60 @@ version: 4.4.1
6516
6610
  horizontal = _e === void 0 ? true : _e,
6517
6611
  _f = _b.circular,
6518
6612
  circular = _f === void 0 ? false : _f,
6519
- _g = _b.bound,
6520
- bound = _g === void 0 ? false : _g,
6521
- _h = _b.adaptive,
6522
- adaptive = _h === void 0 ? false : _h,
6523
- _j = _b.panelsPerView,
6524
- panelsPerView = _j === void 0 ? -1 : _j,
6525
- _k = _b.noPanelStyleOverride,
6526
- noPanelStyleOverride = _k === void 0 ? false : _k,
6527
- _l = _b.resizeOnContentsReady,
6528
- resizeOnContentsReady = _l === void 0 ? false : _l,
6529
- _m = _b.needPanelThreshold,
6530
- needPanelThreshold = _m === void 0 ? 0 : _m,
6531
- _o = _b.preventEventsBeforeInit,
6532
- preventEventsBeforeInit = _o === void 0 ? true : _o,
6533
- _p = _b.deceleration,
6534
- deceleration = _p === void 0 ? 0.0075 : _p,
6535
- _q = _b.duration,
6536
- duration = _q === void 0 ? 500 : _q,
6537
- _r = _b.easing,
6538
- easing = _r === void 0 ? function (x) {
6613
+ _g = _b.circularFallback,
6614
+ circularFallback = _g === void 0 ? CIRCULAR_FALLBACK.LINEAR : _g,
6615
+ _h = _b.bound,
6616
+ bound = _h === void 0 ? false : _h,
6617
+ _j = _b.adaptive,
6618
+ adaptive = _j === void 0 ? false : _j,
6619
+ _k = _b.panelsPerView,
6620
+ panelsPerView = _k === void 0 ? -1 : _k,
6621
+ _l = _b.noPanelStyleOverride,
6622
+ noPanelStyleOverride = _l === void 0 ? false : _l,
6623
+ _m = _b.resizeOnContentsReady,
6624
+ resizeOnContentsReady = _m === void 0 ? false : _m,
6625
+ _o = _b.needPanelThreshold,
6626
+ needPanelThreshold = _o === void 0 ? 0 : _o,
6627
+ _p = _b.preventEventsBeforeInit,
6628
+ preventEventsBeforeInit = _p === void 0 ? true : _p,
6629
+ _q = _b.deceleration,
6630
+ deceleration = _q === void 0 ? 0.0075 : _q,
6631
+ _r = _b.duration,
6632
+ duration = _r === void 0 ? 500 : _r,
6633
+ _s = _b.easing,
6634
+ easing = _s === void 0 ? function (x) {
6539
6635
  return 1 - Math.pow(1 - x, 3);
6540
- } : _r,
6541
- _s = _b.inputType,
6542
- inputType = _s === void 0 ? ["mouse", "touch"] : _s,
6543
- _t = _b.moveType,
6544
- moveType = _t === void 0 ? "snap" : _t,
6545
- _u = _b.threshold,
6546
- threshold = _u === void 0 ? 40 : _u,
6547
- _v = _b.interruptable,
6548
- interruptable = _v === void 0 ? true : _v,
6549
- _w = _b.bounce,
6550
- bounce = _w === void 0 ? "20%" : _w,
6551
- _x = _b.iOSEdgeSwipeThreshold,
6552
- iOSEdgeSwipeThreshold = _x === void 0 ? 30 : _x,
6553
- _y = _b.preventClickOnDrag,
6554
- preventClickOnDrag = _y === void 0 ? true : _y,
6555
- _z = _b.disableOnInit,
6556
- disableOnInit = _z === void 0 ? false : _z,
6557
- _0 = _b.renderOnlyVisible,
6558
- renderOnlyVisible = _0 === void 0 ? false : _0,
6559
- _1 = _b.virtual,
6560
- virtual = _1 === void 0 ? null : _1,
6561
- _2 = _b.autoInit,
6562
- autoInit = _2 === void 0 ? true : _2,
6563
- _3 = _b.autoResize,
6564
- autoResize = _3 === void 0 ? true : _3,
6565
- _4 = _b.useResizeObserver,
6566
- useResizeObserver = _4 === void 0 ? true : _4,
6567
- _5 = _b.externalRenderer,
6568
- externalRenderer = _5 === void 0 ? null : _5,
6569
- _6 = _b.renderExternal,
6570
- renderExternal = _6 === void 0 ? null : _6;
6636
+ } : _s,
6637
+ _t = _b.inputType,
6638
+ inputType = _t === void 0 ? ["mouse", "touch"] : _t,
6639
+ _u = _b.moveType,
6640
+ moveType = _u === void 0 ? "snap" : _u,
6641
+ _v = _b.threshold,
6642
+ threshold = _v === void 0 ? 40 : _v,
6643
+ _w = _b.interruptable,
6644
+ interruptable = _w === void 0 ? true : _w,
6645
+ _x = _b.bounce,
6646
+ bounce = _x === void 0 ? "20%" : _x,
6647
+ _y = _b.iOSEdgeSwipeThreshold,
6648
+ iOSEdgeSwipeThreshold = _y === void 0 ? 30 : _y,
6649
+ _z = _b.preventClickOnDrag,
6650
+ preventClickOnDrag = _z === void 0 ? true : _z,
6651
+ _0 = _b.disableOnInit,
6652
+ disableOnInit = _0 === void 0 ? false : _0,
6653
+ _1 = _b.renderOnlyVisible,
6654
+ renderOnlyVisible = _1 === void 0 ? false : _1,
6655
+ _2 = _b.virtual,
6656
+ virtual = _2 === void 0 ? null : _2,
6657
+ _3 = _b.autoInit,
6658
+ autoInit = _3 === void 0 ? true : _3,
6659
+ _4 = _b.autoResize,
6660
+ autoResize = _4 === void 0 ? true : _4,
6661
+ _5 = _b.useResizeObserver,
6662
+ useResizeObserver = _5 === void 0 ? true : _5,
6663
+ _6 = _b.externalRenderer,
6664
+ externalRenderer = _6 === void 0 ? null : _6,
6665
+ _7 = _b.renderExternal,
6666
+ renderExternal = _7 === void 0 ? null : _7;
6571
6667
 
6572
6668
  var _this = _super.call(this) || this; // Internal states
6573
6669
 
@@ -6579,6 +6675,7 @@ version: 4.4.1
6579
6675
  _this._defaultIndex = defaultIndex;
6580
6676
  _this._horizontal = horizontal;
6581
6677
  _this._circular = circular;
6678
+ _this._circularFallback = circularFallback;
6582
6679
  _this._bound = bound;
6583
6680
  _this._adaptive = adaptive;
6584
6681
  _this._panelsPerView = panelsPerView;
@@ -6717,7 +6814,7 @@ version: 4.4.1
6717
6814
  * @readonly
6718
6815
  */
6719
6816
  get: function () {
6720
- return this._camera.controlParams.circular;
6817
+ return this._camera.circularEnabled;
6721
6818
  },
6722
6819
  enumerable: false,
6723
6820
  configurable: true
@@ -6951,6 +7048,24 @@ version: 4.4.1
6951
7048
  enumerable: false,
6952
7049
  configurable: true
6953
7050
  });
7051
+ Object.defineProperty(__proto, "circularFallback", {
7052
+ /**
7053
+ * Set panel control mode for the case when circular cannot be enabled.
7054
+ * "linear" will set the view's range from the top of the first panel to the top of the last panel.
7055
+ * "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.
7056
+ * @ko 순환 모드 사용 불가능시 사용할 패널 조작 범위 설정 방식을 변경합니다.
7057
+ * "linear" 사용시 시점이 첫번째 엘리먼트 위에서부터 마지막 엘리먼트 위까지 움직일 수 있도록 설정합니다.
7058
+ * "bound" 사용시 시점이 첫번째 엘리먼트와 마지막 엘리먼트의 끝과 끝 사이에서 움직일 수 있도록 설정합니다.
7059
+ * @see CIRCULAR_FALLBACK
7060
+ * @type {string}
7061
+ * @default "linear"
7062
+ */
7063
+ get: function () {
7064
+ return this._circularFallback;
7065
+ },
7066
+ enumerable: false,
7067
+ configurable: true
7068
+ });
6954
7069
  Object.defineProperty(__proto, "bound", {
6955
7070
  /**
6956
7071
  * 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
@@ -7911,7 +8026,7 @@ version: 4.4.1
7911
8026
  });
7912
8027
  }
7913
8028
 
7914
- (_a = this._plugins).push.apply(_a, __spreadArray([], __read(plugins)));
8029
+ (_a = this._plugins).push.apply(_a, __spread(plugins));
7915
8030
 
7916
8031
  return this;
7917
8032
  };
@@ -8158,22 +8273,14 @@ version: 4.4.1
8158
8273
  };
8159
8274
 
8160
8275
  __proto._createCamera = function () {
8161
- var cameraOption = {
8162
- align: this._align
8163
- };
8164
-
8165
- if (this._circular) {
8166
- if (this._bound) {
8167
- // eslint-disable-next-line no-console
8168
- console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
8169
- }
8170
-
8171
- return new CircularCamera(cameraOption);
8172
- } else if (this._bound) {
8173
- return new BoundCamera(cameraOption);
8174
- } else {
8175
- return new LinearCamera(cameraOption);
8276
+ if (this._circular && this._bound) {
8277
+ // eslint-disable-next-line no-console
8278
+ console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
8176
8279
  }
8280
+
8281
+ return new Camera$1({
8282
+ align: this._align
8283
+ });
8177
8284
  };
8178
8285
 
8179
8286
  __proto._createRenderer = function () {
@@ -8237,7 +8344,7 @@ version: 4.4.1
8237
8344
  */
8238
8345
 
8239
8346
 
8240
- Flicking.VERSION = "4.4.1";
8347
+ Flicking.VERSION = "4.5.1";
8241
8348
  return Flicking;
8242
8349
  }(Component);
8243
8350
 
@@ -8293,7 +8400,7 @@ version: 4.4.1
8293
8400
  args[_i] = arguments[_i];
8294
8401
  }
8295
8402
 
8296
- return (_a = descriptor.value).call.apply(_a, __spreadArray([this[flickingName]], __read(args)));
8403
+ return (_a = descriptor.value).call.apply(_a, __spread([this[flickingName]], args));
8297
8404
  }
8298
8405
  });
8299
8406
  } else {
@@ -8303,7 +8410,8 @@ version: 4.4.1
8303
8410
  getterDescriptor.get = function () {
8304
8411
  var _a;
8305
8412
 
8306
- return (_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(this[flickingName]);
8413
+ var flicking = this[flickingName];
8414
+ return flicking && ((_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(flicking));
8307
8415
  };
8308
8416
  }
8309
8417
 
@@ -8317,7 +8425,7 @@ version: 4.4.1
8317
8425
  args[_i] = arguments[_i];
8318
8426
  }
8319
8427
 
8320
- return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([this[flickingName]], __read(args)));
8428
+ return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spread([this[flickingName]], args));
8321
8429
  };
8322
8430
  }
8323
8431
 
@@ -8331,6 +8439,8 @@ version: 4.4.1
8331
8439
  var renderer = flicking.renderer;
8332
8440
  var panels = renderer.panels;
8333
8441
 
8442
+ var prevList = __spread(diffResult.prevList);
8443
+
8334
8444
  if (diffResult.removed.length > 0) {
8335
8445
  var endIdx_1 = -1;
8336
8446
  var prevIdx_1 = -1;
@@ -8346,6 +8456,8 @@ version: 4.4.1
8346
8456
  } else {
8347
8457
  prevIdx_1 = removedIdx;
8348
8458
  }
8459
+
8460
+ prevList.splice(removedIdx, 1);
8349
8461
  });
8350
8462
  batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
8351
8463
  }
@@ -8385,13 +8497,14 @@ version: 4.4.1
8385
8497
  if (diffResult.added.length > 0) {
8386
8498
  var startIdx_1 = -1;
8387
8499
  var prevIdx_2 = -1;
8500
+ var addedElements_1 = rendered.slice(prevList.length);
8388
8501
  diffResult.added.forEach(function (addedIdx, idx) {
8389
8502
  if (startIdx_1 < 0) {
8390
8503
  startIdx_1 = idx;
8391
8504
  }
8392
8505
 
8393
8506
  if (prevIdx_2 >= 0 && addedIdx !== prevIdx_2 + 1) {
8394
- batchInsert(renderer, diffResult, rendered, startIdx_1, idx + 1);
8507
+ batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1);
8395
8508
  startIdx_1 = -1;
8396
8509
  prevIdx_2 = -1;
8397
8510
  } else {
@@ -8400,19 +8513,19 @@ version: 4.4.1
8400
8513
  });
8401
8514
 
8402
8515
  if (startIdx_1 >= 0) {
8403
- batchInsert(renderer, diffResult, rendered, startIdx_1);
8516
+ batchInsert(renderer, diffResult, addedElements_1, startIdx_1);
8404
8517
  }
8405
8518
  }
8406
8519
  });
8407
8520
 
8408
- var batchInsert = function (renderer, diffResult, rendered, startIdx, endIdx) {
8409
- renderer.batchInsert.apply(renderer, __spreadArray([], __read(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
8521
+ var batchInsert = function (renderer, diffResult, addedElements, startIdx, endIdx) {
8522
+ renderer.batchInsert.apply(renderer, __spread(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
8410
8523
  return {
8411
8524
  index: index,
8412
- elements: [rendered[elIdx + diffResult.prevList.length]],
8525
+ elements: [addedElements[elIdx]],
8413
8526
  hasDOMInElements: false
8414
8527
  };
8415
- }))));
8528
+ })));
8416
8529
  };
8417
8530
 
8418
8531
  var batchRemove = function (renderer, startIdx, endIdx) {
@@ -8437,16 +8550,16 @@ version: 4.4.1
8437
8550
  map[prev] = current;
8438
8551
  return map;
8439
8552
  }, {});
8440
- return __spreadArray(__spreadArray([], __read(flicking.panels.filter(function (panel) {
8553
+ return __spread(flicking.panels.filter(function (panel) {
8441
8554
  return !removedPanels[panel.index];
8442
8555
  }) // Sort panels by position
8443
8556
  .sort(function (panel1, panel2) {
8444
8557
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8445
8558
  }).map(function (panel) {
8446
8559
  return diffResult.list[maintainedMap[panel.index]];
8447
- })), false), __read(diffResult.added.map(function (idx) {
8560
+ }), diffResult.added.map(function (idx) {
8448
8561
  return diffResult.list[idx];
8449
- })));
8562
+ }));
8450
8563
  });
8451
8564
 
8452
8565
  var getDefaultCameraTransform = (function (align, horizontal, firstPanelSize) {