@egjs/flicking 4.4.2 → 4.6.0

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 (57) hide show
  1. package/TODO.md +3 -0
  2. package/declaration/Flicking.d.ts +15 -2
  3. package/declaration/camera/Camera.d.ts +28 -26
  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/core/AutoResizer.d.ts +3 -0
  13. package/declaration/core/ResizeWatcher.d.ts +33 -0
  14. package/declaration/renderer/Renderer.d.ts +13 -0
  15. package/declaration/type/external.d.ts +1 -3
  16. package/{css → dist/css}/flicking-inline.css +20 -13
  17. package/dist/css/flicking-inline.min.css +1 -0
  18. package/dist/css/flicking.css +44 -0
  19. package/dist/css/flicking.min.css +1 -0
  20. package/dist/flicking.esm.js +1491 -1251
  21. package/dist/flicking.esm.js.map +1 -1
  22. package/dist/flicking.js +1494 -1253
  23. package/dist/flicking.js.map +1 -1
  24. package/dist/flicking.min.js +2 -2
  25. package/dist/flicking.min.js.map +1 -1
  26. package/dist/flicking.pkgd.js +1466 -1225
  27. package/dist/flicking.pkgd.js.map +1 -1
  28. package/dist/flicking.pkgd.min.js +2 -2
  29. package/dist/flicking.pkgd.min.js.map +1 -1
  30. package/package.json +17 -7
  31. package/sass/flicking-inline.sass +30 -0
  32. package/sass/flicking.sass +23 -0
  33. package/src/Flicking.ts +127 -35
  34. package/src/camera/Camera.ts +162 -81
  35. package/src/camera/index.ts +3 -7
  36. package/src/camera/{BoundCamera.ts → mode/BoundCameraMode.ts} +46 -43
  37. package/src/camera/mode/CameraMode.ts +77 -0
  38. package/src/camera/mode/CircularCameraMode.ts +171 -0
  39. package/src/camera/mode/LinearCameraMode.ts +23 -0
  40. package/src/camera/mode/index.ts +14 -0
  41. package/src/cfc/sync.ts +29 -23
  42. package/src/cfc/withFlickingMethods.ts +3 -2
  43. package/src/const/external.ts +12 -0
  44. package/src/control/StrictControl.ts +10 -0
  45. package/src/core/AutoResizer.ts +33 -0
  46. package/src/core/ResizeWatcher.ts +133 -0
  47. package/src/renderer/Renderer.ts +92 -43
  48. package/css/flicking.css +0 -28
  49. package/declaration/camera/BoundCamera.d.ts +0 -9
  50. package/declaration/camera/CircularCamera.d.ts +0 -37
  51. package/declaration/camera/LinearCamera.d.ts +0 -5
  52. package/dist/flicking-inline.css +0 -2
  53. package/dist/flicking-inline.css.map +0 -1
  54. package/dist/flicking.css +0 -2
  55. package/dist/flicking.css.map +0 -1
  56. package/src/camera/CircularCamera.ts +0 -268
  57. 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.2
7
+ version: 4.6.0
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.2
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.2
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.2
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.2
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);
@@ -999,6 +1014,33 @@ version: 4.4.2
999
1014
  var _this = this;
1000
1015
 
1001
1016
  this._onResize = function () {
1017
+ var flicking = _this._flicking;
1018
+ var resizeDebounce = flicking.resizeDebounce;
1019
+ var maxResizeDebounce = flicking.maxResizeDebounce;
1020
+
1021
+ if (resizeDebounce <= 0) {
1022
+ void flicking.resize();
1023
+ } else {
1024
+ if (_this._maxResizeDebounceTimer <= 0) {
1025
+ if (maxResizeDebounce > 0 && maxResizeDebounce >= resizeDebounce) {
1026
+ _this._maxResizeDebounceTimer = window.setTimeout(_this._doScheduledResize, maxResizeDebounce);
1027
+ }
1028
+ }
1029
+
1030
+ if (_this._resizeTimer > 0) {
1031
+ clearTimeout(_this._resizeTimer);
1032
+ _this._resizeTimer = 0;
1033
+ }
1034
+
1035
+ _this._resizeTimer = window.setTimeout(_this._doScheduledResize, resizeDebounce);
1036
+ }
1037
+ };
1038
+
1039
+ this._doScheduledResize = function () {
1040
+ clearTimeout(_this._resizeTimer);
1041
+ clearTimeout(_this._maxResizeDebounceTimer);
1042
+ _this._maxResizeDebounceTimer = -1;
1043
+ _this._resizeTimer = -1;
1002
1044
  void _this._flicking.resize();
1003
1045
  }; // eslint-disable-next-line @typescript-eslint/member-ordering
1004
1046
 
@@ -1018,6 +1060,8 @@ version: 4.4.2
1018
1060
  this._flicking = flicking;
1019
1061
  this._enabled = false;
1020
1062
  this._resizeObserver = null;
1063
+ this._resizeTimer = -1;
1064
+ this._maxResizeDebounceTimer = -1;
1021
1065
  }
1022
1066
 
1023
1067
  var __proto = AutoResizer.prototype;
@@ -3031,9 +3075,8 @@ version: 4.4.2
3031
3075
 
3032
3076
 
3033
3077
  function SnapControl(_a) {
3034
- var _b = _a === void 0 ? {} : _a,
3035
- _c = _b.count,
3036
- count = _c === void 0 ? Infinity : _c;
3078
+ var _b = (_a === void 0 ? {} : _a).count,
3079
+ count = _b === void 0 ? Infinity : _b;
3037
3080
 
3038
3081
  var _this = _super.call(this) || this;
3039
3082
 
@@ -3239,9 +3282,8 @@ version: 4.4.2
3239
3282
 
3240
3283
 
3241
3284
  function FreeControl(_a) {
3242
- var _b = _a === void 0 ? {} : _a,
3243
- _c = _b.stopAtEdge,
3244
- stopAtEdge = _c === void 0 ? true : _c;
3285
+ var _b = (_a === void 0 ? {} : _a).stopAtEdge,
3286
+ stopAtEdge = _b === void 0 ? true : _b;
3245
3287
 
3246
3288
  var _this = _super.call(this) || this;
3247
3289
 
@@ -3375,9 +3417,8 @@ version: 4.4.2
3375
3417
 
3376
3418
 
3377
3419
  function StrictControl(_a) {
3378
- var _b = _a === void 0 ? {} : _a,
3379
- _c = _b.count,
3380
- count = _c === void 0 ? 1 : _c;
3420
+ var _b = (_a === void 0 ? {} : _a).count,
3421
+ count = _b === void 0 ? 1 : _b;
3381
3422
 
3382
3423
  var _this = _super.call(this) || this;
3383
3424
 
@@ -3500,6 +3541,21 @@ version: 4.4.2
3500
3541
  };
3501
3542
  return this;
3502
3543
  };
3544
+
3545
+ __proto.moveToPanel = function (panel, options) {
3546
+ return __awaiter(this, void 0, void 0, function () {
3547
+ var flicking, camera, controller;
3548
+ return __generator(this, function (_a) {
3549
+ flicking = getFlickingAttached(this._flicking);
3550
+ camera = flicking.camera;
3551
+ controller = this._controller;
3552
+ controller.update(camera.controlParams);
3553
+ return [2
3554
+ /*return*/
3555
+ , _super.prototype.moveToPanel.call(this, panel, options)];
3556
+ });
3557
+ });
3558
+ };
3503
3559
  /**
3504
3560
  * Move {@link Camera} to the given position
3505
3561
  * @ko {@link Camera}를 주어진 좌표로 이동합니다
@@ -3630,932 +3686,1012 @@ version: 4.4.2
3630
3686
  };
3631
3687
 
3632
3688
  /**
3633
- * A component that manages actual movement inside the viewport
3634
- * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
3689
+ * A mode of camera
3635
3690
  */
3636
3691
 
3637
- var Camera$1 =
3692
+ var CameraMode =
3638
3693
  /*#__PURE__*/
3639
3694
  function () {
3640
3695
  /** */
3641
- function Camera(_a) {
3642
- var _this = this;
3696
+ function CameraMode(flicking) {
3697
+ this._flicking = flicking;
3698
+ }
3643
3699
 
3644
- var _b = _a === void 0 ? {} : _a,
3645
- _c = _b.align,
3646
- align = _c === void 0 ? ALIGN.CENTER : _c;
3700
+ var __proto = CameraMode.prototype;
3647
3701
 
3648
- this._checkTranslateSupport = function () {
3649
- var e_1, _a;
3702
+ __proto.getAnchors = function () {
3703
+ var panels = this._flicking.renderer.panels;
3704
+ return panels.map(function (panel, index) {
3705
+ return new AnchorPoint({
3706
+ index: index,
3707
+ position: panel.position,
3708
+ panel: panel
3709
+ });
3710
+ });
3711
+ };
3650
3712
 
3651
- var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
3652
- var supportedStyle = document.documentElement.style;
3653
- var transformName = "";
3713
+ __proto.findAnchorIncludePosition = function (position) {
3714
+ var anchors = this._flicking.camera.anchorPoints;
3715
+ var anchorsIncludingPosition = anchors.filter(function (anchor) {
3716
+ return anchor.panel.includePosition(position, true);
3717
+ });
3718
+ return anchorsIncludingPosition.reduce(function (nearest, anchor) {
3719
+ if (!nearest) return anchor;
3720
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3721
+ }, null);
3722
+ };
3654
3723
 
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;
3724
+ __proto.clampToReachablePosition = function (position) {
3725
+ var camera = this._flicking.camera;
3726
+ var range = camera.range;
3727
+ return clamp(position, range.min, range.max);
3728
+ };
3658
3729
 
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
- }
3730
+ __proto.getCircularOffset = function () {
3731
+ return 0;
3732
+ };
3674
3733
 
3675
- if (!transformName) {
3676
- throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
3677
- }
3734
+ __proto.canReach = function (panel) {
3735
+ var camera = this._flicking.camera;
3736
+ var range = camera.range;
3737
+ if (panel.removed) return false;
3738
+ var panelPos = panel.position;
3739
+ return panelPos >= range.min && panelPos <= range.max;
3740
+ };
3678
3741
 
3679
- _this._transform = transformName;
3742
+ __proto.canSee = function (panel) {
3743
+ var camera = this._flicking.camera;
3744
+ var visibleRange = camera.visibleRange; // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
3745
+
3746
+ return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
3747
+ };
3748
+
3749
+ return CameraMode;
3750
+ }();
3751
+
3752
+ var LinearCameraMode =
3753
+ /*#__PURE__*/
3754
+ function (_super) {
3755
+ __extends(LinearCameraMode, _super);
3756
+
3757
+ function LinearCameraMode() {
3758
+ return _super !== null && _super.apply(this, arguments) || this;
3759
+ }
3760
+
3761
+ var __proto = LinearCameraMode.prototype;
3762
+
3763
+ __proto.checkAvailability = function () {
3764
+ // It's always available
3765
+ return true;
3766
+ };
3767
+
3768
+ __proto.getRange = function () {
3769
+ var _a, _b;
3770
+
3771
+ var renderer = this._flicking.renderer;
3772
+ var firstPanel = renderer.getPanel(0);
3773
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3774
+ return {
3775
+ min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
3776
+ max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
3680
3777
  };
3778
+ };
3681
3779
 
3682
- this._flicking = null;
3780
+ return LinearCameraMode;
3781
+ }(CameraMode);
3683
3782
 
3684
- this._resetInternalValues(); // Options
3783
+ /**
3784
+ * A {@link Camera} mode that connects the last panel and the first panel, enabling continuous loop
3785
+ * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera} 모드
3786
+ */
3685
3787
 
3788
+ var CircularCameraMode =
3789
+ /*#__PURE__*/
3790
+ function (_super) {
3791
+ __extends(CircularCameraMode, _super);
3686
3792
 
3687
- this._align = align;
3793
+ function CircularCameraMode() {
3794
+ return _super !== null && _super.apply(this, arguments) || this;
3688
3795
  }
3689
3796
 
3690
- var __proto = Camera.prototype;
3691
- Object.defineProperty(__proto, "element", {
3692
- // Internal states getter
3797
+ var __proto = CircularCameraMode.prototype;
3693
3798
 
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} max 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 () {
3810
- return {
3811
- min: this._position - this._alignPos,
3812
- max: this._position - this._alignPos + this.size
3813
- };
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);
3799
+ __proto.checkAvailability = function () {
3800
+ var flicking = this._flicking;
3801
+ var renderer = flicking.renderer;
3802
+ var panels = renderer.panels;
3888
3803
 
3889
- if (!flicking || !nearestAnchor) {
3890
- return NaN;
3891
- }
3804
+ if (panels.length <= 0) {
3805
+ return false;
3806
+ }
3892
3807
 
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;
3808
+ var firstPanel = panels[0];
3809
+ var lastPanel = panels[panels.length - 1];
3810
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
3811
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
3812
+ var visibleSize = flicking.camera.size;
3813
+ var panelSizeSum = lastPanelNext - firstPanelPrev;
3814
+ var canSetCircularMode = panels.every(function (panel) {
3815
+ return panelSizeSum - panel.size >= visibleSize;
3816
+ });
3817
+ return canSetCircularMode;
3818
+ };
3900
3819
 
3901
- if (position === panelPos) {
3902
- return nearestPanel.index;
3903
- }
3820
+ __proto.getRange = function () {
3821
+ var flicking = this._flicking;
3822
+ var panels = flicking.renderer.panels;
3904
3823
 
3905
- if (position < panelPos) {
3906
- var prevPanel = nearestPanel.prev();
3907
- var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
3824
+ if (panels.length <= 0) {
3825
+ return {
3826
+ min: 0,
3827
+ max: 0
3828
+ };
3829
+ }
3908
3830
 
3909
- if (prevPosition > panelPos) {
3910
- prevPosition -= rangeDiff;
3911
- }
3831
+ var firstPanel = panels[0];
3832
+ var lastPanel = panels[panels.length - 1];
3833
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
3834
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
3835
+ return {
3836
+ min: firstPanelPrev,
3837
+ max: lastPanelNext
3838
+ };
3839
+ };
3912
3840
 
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
3841
+ __proto.getAnchors = function () {
3842
+ var flicking = this._flicking;
3843
+ var panels = flicking.renderer.panels;
3844
+ return panels.map(function (panel, index) {
3845
+ return new AnchorPoint({
3846
+ index: index,
3847
+ position: panel.position,
3848
+ panel: panel
3849
+ });
3850
+ });
3851
+ };
3917
3852
 
3918
- if (nextPosition < panelPos) {
3919
- nextPosition += rangeDiff;
3920
- }
3853
+ __proto.findAnchorIncludePosition = function (position) {
3854
+ var camera = this._flicking.camera;
3855
+ var range = camera.range;
3856
+ var anchors = camera.anchorPoints;
3857
+ var rangeDiff = camera.rangeDiff;
3858
+ var anchorCount = anchors.length;
3859
+ var positionInRange = circulatePosition(position, range.min, range.max);
3921
3860
 
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
3861
+ var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
3930
3862
 
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
- */
3863
+ if (anchorCount > 0 && (position === range.min || position === range.max)) {
3864
+ var possibleAnchors = [anchorInRange, new AnchorPoint({
3865
+ index: 0,
3866
+ position: anchors[0].position + rangeDiff,
3867
+ panel: anchors[0].panel
3868
+ }), new AnchorPoint({
3869
+ index: anchorCount - 1,
3870
+ position: anchors[anchorCount - 1].position - rangeDiff,
3871
+ panel: anchors[anchorCount - 1].panel
3872
+ })].filter(function (anchor) {
3873
+ return !!anchor;
3874
+ });
3875
+ anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
3876
+ if (!nearest) return anchor;
3877
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3878
+ }, null);
3879
+ }
3956
3880
 
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;
3881
+ if (!anchorInRange) return null;
3962
3882
 
3963
- this._checkTranslateSupport();
3883
+ if (position < range.min) {
3884
+ var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
3885
+ return new AnchorPoint({
3886
+ index: anchorInRange.index,
3887
+ position: anchorInRange.position + rangeDiff * loopCount,
3888
+ panel: anchorInRange.panel
3889
+ });
3890
+ } else if (position > range.max) {
3891
+ var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
3892
+ return new AnchorPoint({
3893
+ index: anchorInRange.index,
3894
+ position: anchorInRange.position + rangeDiff * loopCount,
3895
+ panel: anchorInRange.panel
3896
+ });
3897
+ }
3964
3898
 
3965
- return this;
3899
+ return anchorInRange;
3966
3900
  };
3967
- /**
3968
- * Destroy Camera and return to initial state
3969
- * @ko Camera를 초기 상태로 되돌립니다
3970
- * @return {void}
3971
- */
3972
3901
 
3902
+ __proto.getCircularOffset = function () {
3903
+ var flicking = this._flicking;
3904
+ var camera = flicking.camera;
3905
+ if (!camera.circularEnabled) return 0;
3906
+ var toggled = flicking.panels.filter(function (panel) {
3907
+ return panel.toggled;
3908
+ });
3909
+ var toggledPrev = toggled.filter(function (panel) {
3910
+ return panel.toggleDirection === DIRECTION.PREV;
3911
+ });
3912
+ var toggledNext = toggled.filter(function (panel) {
3913
+ return panel.toggleDirection === DIRECTION.NEXT;
3914
+ });
3915
+ return this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
3916
+ };
3973
3917
 
3974
- __proto.destroy = function () {
3975
- this._flicking = null;
3918
+ __proto.clampToReachablePosition = function (position) {
3919
+ // Basically all position is reachable for circular camera
3920
+ return position;
3921
+ };
3976
3922
 
3977
- this._resetInternalValues();
3923
+ __proto.canReach = function (panel) {
3924
+ if (panel.removed) return false; // Always reachable on circular mode
3978
3925
 
3979
- return this;
3926
+ return true;
3980
3927
  };
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
3928
 
3929
+ __proto.canSee = function (panel) {
3930
+ var camera = this._flicking.camera;
3931
+ var range = camera.range;
3932
+ var rangeDiff = camera.rangeDiff;
3933
+ var visibleRange = camera.visibleRange;
3991
3934
 
3992
- __proto.lookAt = function (pos) {
3993
- var prevPos = this._position;
3994
- this._position = pos;
3935
+ var visibleInCurrentRange = _super.prototype.canSee.call(this, panel); // Check looped visible area for circular case
3995
3936
 
3996
- this._refreshVisiblePanels();
3997
3937
 
3998
- this._checkNeedPanel();
3938
+ if (visibleRange.min < range.min) {
3939
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
3940
+ } else if (visibleRange.max > range.max) {
3941
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
3942
+ }
3999
3943
 
4000
- this._checkReachEnd(prevPos, pos);
3944
+ return visibleInCurrentRange;
3945
+ };
4001
3946
 
4002
- this.applyTransform();
3947
+ __proto._calcPanelAreaSum = function (panels) {
3948
+ return panels.reduce(function (sum, panel) {
3949
+ return sum + panel.sizeIncludingMargin;
3950
+ }, 0);
4003
3951
  };
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
- */
4012
3952
 
3953
+ return CircularCameraMode;
3954
+ }(CameraMode);
4013
3955
 
4014
- __proto.getPrevAnchor = function (anchor) {
4015
- return this._anchors[anchor.index - 1] || null;
4016
- };
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
- */
3956
+ var BoundCameraMode =
3957
+ /*#__PURE__*/
3958
+ function (_super) {
3959
+ __extends(BoundCameraMode, _super);
4025
3960
 
3961
+ function BoundCameraMode() {
3962
+ return _super !== null && _super.apply(this, arguments) || this;
3963
+ }
4026
3964
 
4027
- __proto.getNextAnchor = function (anchor) {
4028
- return this._anchors[anchor.index + 1] || null;
3965
+ var __proto = BoundCameraMode.prototype;
3966
+
3967
+ __proto.checkAvailability = function () {
3968
+ var flicking = this._flicking;
3969
+ var renderer = flicking.renderer;
3970
+ var firstPanel = renderer.getPanel(0);
3971
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3972
+
3973
+ if (!firstPanel || !lastPanel) {
3974
+ return false;
3975
+ }
3976
+
3977
+ var viewportSize = flicking.camera.size;
3978
+ var firstPanelPrev = firstPanel.range.min;
3979
+ var lastPanelNext = lastPanel.range.max;
3980
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
3981
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
3982
+ return isBiggerThanViewport;
4029
3983
  };
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
- */
4038
3984
 
3985
+ __proto.getRange = function () {
3986
+ var flicking = this._flicking;
3987
+ var renderer = flicking.renderer;
3988
+ var alignPos = flicking.camera.alignPosition;
3989
+ var firstPanel = renderer.getPanel(0);
3990
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
3991
+
3992
+ if (!firstPanel || !lastPanel) {
3993
+ return {
3994
+ min: 0,
3995
+ max: 0
3996
+ };
3997
+ }
4039
3998
 
4040
- __proto.getProgressInPanel = function (panel) {
4041
- var panelRange = panel.range;
4042
- return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
3999
+ var viewportSize = flicking.camera.size;
4000
+ var firstPanelPrev = firstPanel.range.min;
4001
+ var lastPanelNext = lastPanel.range.max;
4002
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
4003
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
4004
+ var firstPos = firstPanelPrev + alignPos;
4005
+ var lastPos = lastPanelNext - viewportSize + alignPos;
4006
+
4007
+ if (isBiggerThanViewport) {
4008
+ return {
4009
+ min: firstPos,
4010
+ max: lastPos
4011
+ };
4012
+ } else {
4013
+ var align = flicking.camera.align;
4014
+ var alignVal = typeof align === "object" ? align.camera : align;
4015
+ var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
4016
+ return {
4017
+ min: pos,
4018
+ max: pos
4019
+ };
4020
+ }
4043
4021
  };
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
4022
 
4023
+ __proto.getAnchors = function () {
4024
+ var flicking = this._flicking;
4025
+ var camera = flicking.camera;
4026
+ var panels = flicking.renderer.panels;
4053
4027
 
4054
- __proto.findAnchorIncludePosition = function (position) {
4055
- var anchors = this._anchors;
4056
- var anchorsIncludingPosition = anchors.filter(function (anchor) {
4057
- return anchor.panel.includePosition(position, true);
4028
+ if (panels.length <= 0) {
4029
+ return [];
4030
+ }
4031
+
4032
+ var range = flicking.camera.range;
4033
+ var reachablePanels = panels.filter(function (panel) {
4034
+ return camera.canReach(panel);
4058
4035
  });
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
4036
 
4037
+ if (reachablePanels.length > 0) {
4038
+ var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
4039
+ var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
4040
+ var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
4041
+ var newAnchors = reachablePanels.map(function (panel, idx) {
4042
+ return new AnchorPoint({
4043
+ index: idx + indexOffset_1,
4044
+ position: panel.position,
4045
+ panel: panel
4046
+ });
4047
+ });
4073
4048
 
4074
- __proto.findNearestAnchor = function (position) {
4075
- var anchors = this._anchors;
4049
+ if (shouldPrependBoundAnchor) {
4050
+ newAnchors.splice(0, 0, new AnchorPoint({
4051
+ index: 0,
4052
+ position: range.min,
4053
+ panel: panels[reachablePanels[0].index - 1]
4054
+ }));
4055
+ }
4056
+
4057
+ if (shouldAppendBoundAnchor) {
4058
+ newAnchors.push(new AnchorPoint({
4059
+ index: newAnchors.length,
4060
+ position: range.max,
4061
+ panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
4062
+ }));
4063
+ }
4064
+
4065
+ return newAnchors;
4066
+ } else if (range.min !== range.max) {
4067
+ // There're more than 2 panels
4068
+ var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
4069
+
4070
+ var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
4071
+ var panelAtMax = panelAtMin.next();
4072
+ return [new AnchorPoint({
4073
+ index: 0,
4074
+ position: range.min,
4075
+ panel: panelAtMin
4076
+ }), new AnchorPoint({
4077
+ index: 1,
4078
+ position: range.max,
4079
+ panel: panelAtMax
4080
+ })];
4081
+ } else {
4082
+ return [new AnchorPoint({
4083
+ index: 0,
4084
+ position: range.min,
4085
+ panel: this._findNearestPanel(range.min, panels)
4086
+ })];
4087
+ }
4088
+ };
4089
+
4090
+ __proto.findAnchorIncludePosition = function (position) {
4091
+ var camera = this._flicking.camera;
4092
+ var range = camera.range;
4093
+ var anchors = camera.anchorPoints;
4076
4094
  if (anchors.length <= 0) return null;
4095
+
4096
+ if (position <= range.min) {
4097
+ return anchors[0];
4098
+ } else if (position >= range.max) {
4099
+ return anchors[anchors.length - 1];
4100
+ } else {
4101
+ return _super.prototype.findAnchorIncludePosition.call(this, position);
4102
+ }
4103
+ };
4104
+
4105
+ __proto._findNearestPanel = function (pos, panels) {
4077
4106
  var prevDist = Infinity;
4078
4107
 
4079
- for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
4080
- var anchor = anchors[anchorIdx];
4081
- var dist = Math.abs(anchor.position - position);
4108
+ for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
4109
+ var panel = panels[panelIdx];
4110
+ var dist = Math.abs(panel.position - pos);
4082
4111
 
4083
4112
  if (dist > prevDist) {
4084
4113
  // Return previous anchor
4085
- return anchors[anchorIdx - 1];
4114
+ return panels[panelIdx - 1];
4086
4115
  }
4087
4116
 
4088
4117
  prevDist = dist;
4089
4118
  } // Return last anchor
4090
4119
 
4091
4120
 
4092
- return anchors[anchors.length - 1];
4093
- };
4094
- /**
4095
- * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
4096
- * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
4097
- * @return {AnchorPoint | null}
4098
- */
4099
-
4100
-
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
- });
4121
+ return panels[panels.length - 1];
4107
4122
  };
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
- */
4114
4123
 
4124
+ return BoundCameraMode;
4125
+ }(CameraMode);
4115
4126
 
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
- */
4126
-
4127
+ /**
4128
+ * A component that manages actual movement inside the viewport
4129
+ * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
4130
+ */
4127
4131
 
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
- */
4132
+ var Camera$1 =
4133
+ /*#__PURE__*/
4134
+ function () {
4135
+ /** */
4136
+ function Camera(flicking, _a) {
4137
+ var _this = this;
4140
4138
 
4139
+ var _b = (_a === void 0 ? {} : _a).align,
4140
+ align = _b === void 0 ? ALIGN.CENTER : _b;
4141
4141
 
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.
4142
+ this._checkTranslateSupport = function () {
4143
+ var e_1, _a;
4144
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
- */
4145
+ var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
4146
+ var supportedStyle = document.documentElement.style;
4147
+ var transformName = "";
4153
4148
 
4149
+ try {
4150
+ for (var transforms_1 = __values(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
4151
+ var prefixedTransform = transforms_1_1.value;
4154
4152
 
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
- */
4153
+ if (prefixedTransform in supportedStyle) {
4154
+ transformName = prefixedTransform;
4155
+ }
4156
+ }
4157
+ } catch (e_1_1) {
4158
+ e_1 = {
4159
+ error: e_1_1
4160
+ };
4161
+ } finally {
4162
+ try {
4163
+ if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
4164
+ } finally {
4165
+ if (e_1) throw e_1.error;
4166
+ }
4167
+ }
4168
+
4169
+ if (!transformName) {
4170
+ throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
4171
+ }
4172
+
4173
+ _this._transform = transformName;
4174
+ };
4175
+
4176
+ this._flicking = flicking;
4177
+
4178
+ this._resetInternalValues(); // Options
4179
+
4180
+
4181
+ this._align = align;
4182
+ }
4183
+
4184
+ var __proto = Camera.prototype;
4185
+ Object.defineProperty(__proto, "element", {
4186
+ // Internal states getter
4187
+
4188
+ /**
4189
+ * The camera element(`.flicking-camera`)
4190
+ * @ko 카메라 엘리먼트(`.flicking-camera`)
4191
+ * @type {HTMLElement}
4192
+ * @readonly
4193
+ */
4194
+ get: function () {
4195
+ return this._el;
4196
+ },
4197
+ enumerable: false,
4198
+ configurable: true
4199
+ });
4200
+ Object.defineProperty(__proto, "children", {
4201
+ /**
4202
+ * An array of the child elements of the camera element(`.flicking-camera`)
4203
+ * @ko 카메라 엘리먼트(`.flicking-camera`)의 자식 엘리먼트 배열
4204
+ * @type {HTMLElement[]}
4205
+ * @readonly
4206
+ */
4207
+ get: function () {
4208
+ return toArray(this._el.children);
4209
+ },
4210
+ enumerable: false,
4211
+ configurable: true
4212
+ });
4213
+ Object.defineProperty(__proto, "position", {
4214
+ /**
4215
+ * Current position of the camera
4216
+ * @ko Camera의 현재 좌표
4217
+ * @type {number}
4218
+ * @readonly
4219
+ */
4220
+ get: function () {
4221
+ return this._position;
4222
+ },
4223
+ enumerable: false,
4224
+ configurable: true
4225
+ });
4226
+ Object.defineProperty(__proto, "alignPosition", {
4227
+ /**
4228
+ * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
4229
+ * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
4230
+ * @type {number}
4231
+ * @readonly
4232
+ */
4233
+ get: function () {
4234
+ return this._alignPos;
4235
+ },
4236
+ enumerable: false,
4237
+ configurable: true
4238
+ });
4239
+ Object.defineProperty(__proto, "offset", {
4240
+ /**
4241
+ * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
4242
+ * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
4243
+ * @type {number}
4244
+ * @default 0
4245
+ * @readonly
4246
+ */
4247
+ get: function () {
4248
+ return this._offset - this._circularOffset;
4249
+ },
4250
+ enumerable: false,
4251
+ configurable: true
4252
+ });
4253
+ Object.defineProperty(__proto, "circularEnabled", {
4254
+ /**
4255
+ * Whether the `circular` option is enabled.
4256
+ * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
4257
+ * @ko {@link Flicking#circular circular} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
4258
+ * {@link Flicking#circular circular} 옵션은 패널의 크기의 합이 충분하지 않을 경우 비활성화됩니다.
4259
+ * @type {boolean}
4260
+ * @default false
4261
+ * @readonly
4262
+ */
4263
+ get: function () {
4264
+ return this._circularEnabled;
4265
+ },
4266
+ enumerable: false,
4267
+ configurable: true
4268
+ });
4269
+ Object.defineProperty(__proto, "mode", {
4270
+ /**
4271
+ * A current camera mode
4272
+ * @type {CameraMode}
4273
+ * @readonly
4274
+ */
4275
+ get: function () {
4276
+ return this._mode;
4277
+ },
4278
+ enumerable: false,
4279
+ configurable: true
4280
+ });
4281
+ Object.defineProperty(__proto, "range", {
4282
+ /**
4283
+ * A range that Camera's {@link Camera#position position} can reach
4284
+ * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
4285
+ * @type {object}
4286
+ * @property {number} min A minimum position<ko>최소 위치</ko>
4287
+ * @property {number} max A maximum position<ko>최대 위치</ko>
4288
+ * @readonly
4289
+ */
4290
+ get: function () {
4291
+ return this._range;
4292
+ },
4293
+ enumerable: false,
4294
+ configurable: true
4295
+ });
4296
+ Object.defineProperty(__proto, "rangeDiff", {
4297
+ /**
4298
+ * A difference between Camera's minimum and maximum position that can reach
4299
+ * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
4300
+ * @type {number}
4301
+ * @readonly
4302
+ */
4303
+ get: function () {
4304
+ return this._range.max - this._range.min;
4305
+ },
4306
+ enumerable: false,
4307
+ configurable: true
4308
+ });
4309
+ Object.defineProperty(__proto, "visiblePanels", {
4310
+ /**
4311
+ * An array of visible panels from the current position
4312
+ * @ko 현재 보이는 패널들의 배열
4313
+ * @type {Panel[]}
4314
+ * @readonly
4315
+ */
4316
+ get: function () {
4317
+ return this._visiblePanels;
4318
+ },
4319
+ enumerable: false,
4320
+ configurable: true
4321
+ });
4322
+ Object.defineProperty(__proto, "visibleRange", {
4323
+ /**
4324
+ * A range of the visible area from the current position
4325
+ * @ko 현재 위치에서 보이는 범위
4326
+ * @type {object}
4327
+ * @property {number} min A minimum position<ko>최소 위치</ko>
4328
+ * @property {number} min A maximum position<ko>최대 위치</ko>
4329
+ * @readonly
4330
+ */
4331
+ get: function () {
4332
+ return {
4333
+ min: this._position - this._alignPos,
4334
+ max: this._position - this._alignPos + this.size
4335
+ };
4336
+ },
4337
+ enumerable: false,
4338
+ configurable: true
4339
+ });
4340
+ Object.defineProperty(__proto, "anchorPoints", {
4341
+ /**
4342
+ * An array of {@link AnchorPoint}s that Camera can be stopped at
4343
+ * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
4344
+ * @type {AnchorPoint[]}
4345
+ * @readonly
4346
+ */
4347
+ get: function () {
4348
+ return this._anchors;
4349
+ },
4350
+ enumerable: false,
4351
+ configurable: true
4352
+ });
4353
+ Object.defineProperty(__proto, "controlParams", {
4354
+ /**
4355
+ * A current parameters of the Camera for updating {@link AxesController}
4356
+ * @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
4357
+ * @type {ControlParams}
4358
+ * @readonly
4359
+ */
4360
+ get: function () {
4361
+ return {
4362
+ range: this._range,
4363
+ position: this._position,
4364
+ circular: this._circularEnabled
4365
+ };
4366
+ },
4367
+ enumerable: false,
4368
+ configurable: true
4369
+ });
4370
+ Object.defineProperty(__proto, "atEdge", {
4371
+ /**
4372
+ * A Boolean value indicating whether Camera's over the minimum or maximum position reachable
4373
+ * @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
4374
+ * @type {boolean}
4375
+ * @readonly
4376
+ */
4377
+ get: function () {
4378
+ return this._position <= this._range.min || this._position >= this._range.max;
4379
+ },
4380
+ enumerable: false,
4381
+ configurable: true
4382
+ });
4383
+ Object.defineProperty(__proto, "size", {
4384
+ /**
4385
+ * Return the size of the viewport
4386
+ * @ko 뷰포트 크기를 반환합니다
4387
+ * @type {number}
4388
+ * @readonly
4389
+ */
4390
+ get: function () {
4391
+ var flicking = this._flicking;
4392
+ return flicking ? flicking.horizontal ? flicking.viewport.width : flicking.viewport.height : 0;
4393
+ },
4394
+ enumerable: false,
4395
+ configurable: true
4396
+ });
4397
+ Object.defineProperty(__proto, "progress", {
4398
+ /**
4399
+ * Return the camera's position progress from the first panel to last panel
4400
+ * Range is from 0 to last panel's index
4401
+ * @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
4402
+ * 범위는 0부터 마지막 패널의 인덱스까지입니다
4403
+ * @type {number}
4404
+ * @readonly
4405
+ */
4406
+ get: function () {
4407
+ var flicking = this._flicking;
4408
+ var position = this._position + this._offset;
4409
+ var nearestAnchor = this.findNearestAnchor(this._position);
4410
+
4411
+ if (!flicking || !nearestAnchor) {
4412
+ return NaN;
4413
+ }
4414
+
4415
+ var nearestPanel = nearestAnchor.panel;
4416
+ var panelPos = nearestPanel.position + nearestPanel.offset;
4417
+ var bounceSize = flicking.control.controller.bounce;
4418
+ var _a = this.range,
4419
+ prevRange = _a.min,
4420
+ nextRange = _a.max;
4421
+ var rangeDiff = this.rangeDiff;
4422
+
4423
+ if (position === panelPos) {
4424
+ return nearestPanel.index;
4425
+ }
4426
+
4427
+ if (position < panelPos) {
4428
+ var prevPanel = nearestPanel.prev();
4429
+ var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
4430
+
4431
+ if (prevPosition > panelPos) {
4432
+ prevPosition -= rangeDiff;
4433
+ }
4170
4434
 
4435
+ return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
4436
+ } else {
4437
+ var nextPanel = nearestPanel.next();
4438
+ var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1]; // Looped
4171
4439
 
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
- */
4440
+ if (nextPosition < panelPos) {
4441
+ nextPosition += rangeDiff;
4442
+ }
4193
4443
 
4444
+ return nearestPanel.index + getProgress(position, panelPos, nextPosition);
4445
+ }
4446
+ },
4447
+ enumerable: false,
4448
+ configurable: true
4449
+ });
4450
+ Object.defineProperty(__proto, "align", {
4451
+ // Options Getter
4194
4452
 
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
- };
4453
+ /**
4454
+ * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
4455
+ * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
4456
+ * @type {ALIGN | string | number}
4457
+ */
4458
+ get: function () {
4459
+ return this._align;
4460
+ },
4461
+ // Options Setter
4462
+ set: function (val) {
4463
+ this._align = val;
4464
+ },
4465
+ enumerable: false,
4466
+ configurable: true
4467
+ });
4203
4468
  /**
4204
- * Update current offset of the camera
4205
- * @ko 현재 카메라의 오프셋을 업데이트합니다
4206
- * @chainable
4469
+ * Initialize Camera
4470
+ * @ko Camera를 초기화합니다
4471
+ * @throws {FlickingError}
4472
+ * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
4473
+ * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
4207
4474
  * @return {this}
4208
4475
  */
4209
4476
 
4477
+ __proto.init = function () {
4478
+ var viewportEl = this._flicking.viewport.element;
4479
+ checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
4480
+ this._el = viewportEl.firstElementChild;
4210
4481
 
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
- */
4482
+ this._checkTranslateSupport();
4231
4483
 
4484
+ this._updateMode();
4232
4485
 
4233
- __proto.resetNeedPanelHistory = function () {
4234
- this._needPanelTriggered = {
4235
- prev: false,
4236
- next: false
4237
- };
4238
4486
  return this;
4239
4487
  };
4240
4488
  /**
4241
- * Apply "transform" style with the current position to camera element
4242
- * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
4243
- * @chainable
4244
- * @return {this}
4489
+ * Destroy Camera and return to initial state
4490
+ * @ko Camera를 초기 상태로 되돌립니다
4491
+ * @return {void}
4245
4492
  */
4246
4493
 
4247
4494
 
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
- };
4255
-
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
-
4272
- __proto._refreshVisiblePanels = function () {
4273
- var _this = this;
4274
-
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
- });
4288
-
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
- };
4299
-
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;
4305
-
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;
4312
- }
4313
-
4314
- if (!needPanelTriggered.next) {
4315
- flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4316
- direction: DIRECTION.NEXT
4317
- }));
4318
- needPanelTriggered.next = true;
4319
- }
4320
-
4321
- return;
4322
- }
4323
-
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];
4332
-
4333
- if (!needPanelTriggered.prev) {
4334
- var firstPanelPrev = firstPanel.range.min;
4335
-
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;
4341
- }
4342
- }
4343
-
4344
- if (!needPanelTriggered.next) {
4345
- var lastPanelNext = lastPanel.range.max;
4346
-
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
- };
4495
+ __proto.destroy = function () {
4496
+ this._resetInternalValues();
4355
4497
 
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
- }));
4498
+ return this;
4366
4499
  };
4367
-
4368
- return Camera;
4369
- }();
4370
-
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
- */
4375
-
4376
- var LinearCamera =
4377
- /*#__PURE__*/
4378
- function (_super) {
4379
- __extends(LinearCamera, _super);
4380
-
4381
- function LinearCamera() {
4382
- return _super !== null && _super.apply(this, arguments) || this;
4383
- }
4384
4500
  /**
4385
- * Update {@link Camera#range range} of Camera
4386
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4387
- * @chainable
4501
+ * Move to the given position and apply CSS transform
4502
+ * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
4503
+ * @param {number} pos A new position<ko>움직일 위치</ko>
4388
4504
  * @throws {FlickingError}
4389
4505
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4390
4506
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4391
4507
  * @return {this}
4392
- */
4393
-
4394
-
4395
- var __proto = LinearCamera.prototype;
4396
-
4397
- __proto.updateRange = function () {
4398
- var _a, _b;
4399
-
4400
- 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
- };
4508
+ */
4410
4509
 
4411
- return LinearCamera;
4412
- }(Camera$1);
4413
4510
 
4414
- /**
4415
- * A {@link Camera} that connects the last panel and the first panel, enabling continuous loop
4416
- * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera}
4417
- */
4511
+ __proto.lookAt = function (pos) {
4512
+ var _this = this;
4418
4513
 
4419
- var CircularCamera =
4420
- /*#__PURE__*/
4421
- function (_super) {
4422
- __extends(CircularCamera, _super);
4514
+ var flicking = getFlickingAttached(this._flicking);
4515
+ var prevPos = this._position;
4516
+ this._position = pos;
4423
4517
 
4424
- function CircularCamera() {
4425
- var _this = _super !== null && _super.apply(this, arguments) || this;
4518
+ var toggled = this._togglePanels(prevPos, pos);
4426
4519
 
4427
- _this._circularOffset = 0;
4428
- _this._circularEnabled = false;
4429
- return _this;
4430
- }
4520
+ this._refreshVisiblePanels();
4521
+
4522
+ this._checkNeedPanel();
4523
+
4524
+ this._checkReachEnd(prevPos, pos);
4525
+
4526
+ if (toggled) {
4527
+ void flicking.renderer.render().then(function () {
4528
+ _this.updateOffset();
4529
+ });
4530
+ } else {
4531
+ this.applyTransform();
4532
+ }
4533
+ };
4534
+ /**
4535
+ * Return a previous {@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 previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
4541
+ */
4431
4542
 
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
4543
 
4452
4544
  __proto.getPrevAnchor = function (anchor) {
4453
- if (!this._circularEnabled || anchor.index !== 0) return _super.prototype.getPrevAnchor.call(this, anchor);
4454
- 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
- });
4545
+ if (!this._circularEnabled || anchor.index !== 0) {
4546
+ return this._anchors[anchor.index - 1] || null;
4547
+ } else {
4548
+ var anchors = this._anchors;
4549
+ var rangeDiff = this.rangeDiff;
4550
+ var lastAnchor = anchors[anchors.length - 1];
4551
+ return new AnchorPoint({
4552
+ index: lastAnchor.index,
4553
+ position: lastAnchor.position - rangeDiff,
4554
+ panel: lastAnchor.panel
4555
+ });
4556
+ }
4462
4557
  };
4558
+ /**
4559
+ * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
4560
+ * If it does not exist, return `null` instead
4561
+ * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
4562
+ * 존재하지 않을 경우 `null`을 반환합니다
4563
+ * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
4564
+ * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
4565
+ */
4566
+
4463
4567
 
4464
4568
  __proto.getNextAnchor = function (anchor) {
4465
4569
  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
- });
4570
+
4571
+ if (!this._circularEnabled || anchor.index !== anchors.length - 1) {
4572
+ return anchors[anchor.index + 1] || null;
4573
+ } else {
4574
+ var rangeDiff = this.rangeDiff;
4575
+ var firstAnchor = anchors[0];
4576
+ return new AnchorPoint({
4577
+ index: firstAnchor.index,
4578
+ position: firstAnchor.position + rangeDiff,
4579
+ panel: firstAnchor.panel
4580
+ });
4581
+ }
4582
+ };
4583
+ /**
4584
+ * Return the camera's position progress in the panel below
4585
+ * Value is from 0 to 1 when the camera's inside panel
4586
+ * Value can be lower than 0 or bigger than 1 when it's in the margin area
4587
+ * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
4588
+ * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
4589
+ * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
4590
+ */
4591
+
4592
+
4593
+ __proto.getProgressInPanel = function (panel) {
4594
+ var panelRange = panel.range;
4595
+ return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
4474
4596
  };
4597
+ /**
4598
+ * Return {@link AnchorPoint} that includes given position
4599
+ * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
4600
+ * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
4601
+ * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
4602
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
4603
+ * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
4604
+ */
4605
+
4475
4606
 
4476
4607
  __proto.findAnchorIncludePosition = function (position) {
4477
- if (!this._circularEnabled) return _super.prototype.findAnchorIncludePosition.call(this, position);
4478
- var range = this._range;
4608
+ return this._mode.findAnchorIncludePosition(position);
4609
+ };
4610
+ /**
4611
+ * Return {@link AnchorPoint} nearest to given position
4612
+ * If there're no {@link AnchorPoint}s, return `null` instead
4613
+ * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
4614
+ * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
4615
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
4616
+ * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
4617
+ */
4618
+
4619
+
4620
+ __proto.findNearestAnchor = function (position) {
4479
4621
  var anchors = this._anchors;
4480
- var rangeDiff = this.rangeDiff;
4481
- var anchorCount = anchors.length;
4482
- var positionInRange = circulatePosition(position, range.min, range.max);
4622
+ if (anchors.length <= 0) return null;
4623
+ var prevDist = Infinity;
4483
4624
 
4484
- var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
4625
+ for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
4626
+ var anchor = anchors[anchorIdx];
4627
+ var dist = Math.abs(anchor.position - position);
4485
4628
 
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
- }
4629
+ if (dist > prevDist) {
4630
+ // Return previous anchor
4631
+ return anchors[anchorIdx - 1];
4632
+ }
4503
4633
 
4504
- if (!anchorInRange) return null;
4634
+ prevDist = dist;
4635
+ } // Return last anchor
4505
4636
 
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
4637
 
4522
- return anchorInRange;
4638
+ return anchors[anchors.length - 1];
4523
4639
  };
4640
+ /**
4641
+ * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
4642
+ * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
4643
+ * @return {AnchorPoint | null}
4644
+ */
4524
4645
 
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
4646
 
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);
4647
+ __proto.findActiveAnchor = function () {
4648
+ var flicking = getFlickingAttached(this._flicking);
4649
+ var activeIndex = flicking.control.activeIndex;
4650
+ return find(this._anchors, function (anchor) {
4651
+ return anchor.panel.index === activeIndex;
4652
+ });
4534
4653
  };
4654
+ /**
4655
+ * Clamp the given position between camera's range
4656
+ * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
4657
+ * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
4658
+ * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
4659
+ */
4535
4660
 
4536
- __proto.canSee = function (panel) {
4537
- var range = this._range;
4538
- var rangeDiff = this.rangeDiff;
4539
- var visibleRange = this.visibleRange;
4540
4661
 
4541
- var visibleInCurrentRange = _super.prototype.canSee.call(this, panel);
4662
+ __proto.clampToReachablePosition = function (position) {
4663
+ return this._mode.clampToReachablePosition(position);
4664
+ };
4665
+ /**
4666
+ * Check whether the given panel is inside of the Camera's range
4667
+ * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
4668
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4669
+ * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
4670
+ */
4542
4671
 
4543
- if (!this._circularEnabled) {
4544
- return visibleInCurrentRange;
4545
- } // Check looped visible area for circular case
4546
4672
 
4673
+ __proto.canReach = function (panel) {
4674
+ return this._mode.canReach(panel);
4675
+ };
4676
+ /**
4677
+ * Check whether the given panel element is visible at the current position
4678
+ * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
4679
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
4680
+ * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
4681
+ */
4547
4682
 
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
4683
 
4554
- return visibleInCurrentRange;
4684
+ __proto.canSee = function (panel) {
4685
+ return this._mode.canSee(panel);
4555
4686
  };
4556
4687
  /**
4557
4688
  * Update {@link Camera#range range} of Camera
4558
4689
  * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4690
+ * @method
4691
+ * @abstract
4692
+ * @memberof Camera
4693
+ * @instance
4694
+ * @name updateRange
4559
4695
  * @chainable
4560
4696
  * @throws {FlickingError}
4561
4697
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
@@ -4569,287 +4705,269 @@ version: 4.4.2
4569
4705
  var renderer = flicking.renderer;
4570
4706
  var panels = renderer.panels;
4571
4707
 
4572
- if (panels.length <= 0) {
4573
- this._resetInternalValues();
4574
-
4575
- return this;
4576
- }
4708
+ this._updateMode();
4577
4709
 
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;
4710
+ this._range = this._mode.getRange();
4588
4711
 
4589
- if (canSetCircularMode) {
4590
- this._range = {
4591
- min: firstPanelPrev,
4592
- max: lastPanelNext
4593
- };
4712
+ if (this._circularEnabled) {
4594
4713
  panels.forEach(function (panel) {
4595
4714
  return panel.updateCircularToggleDirection();
4596
4715
  });
4597
- } else {
4598
- this._range = {
4599
- min: firstPanel.position,
4600
- max: lastPanel.position
4601
- };
4602
4716
  }
4603
4717
 
4604
- this.updateOffset();
4605
4718
  return this;
4606
4719
  };
4720
+ /**
4721
+ * Update Camera's {@link Camera#alignPosition alignPosition}
4722
+ * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
4723
+ * @chainable
4724
+ * @return {this}
4725
+ */
4726
+
4727
+
4728
+ __proto.updateAlignPos = function () {
4729
+ var align = this._align;
4730
+ var alignVal = typeof align === "object" ? align.camera : align;
4731
+ this._alignPos = parseAlign$1(alignVal, this.size);
4732
+ return this;
4733
+ };
4734
+ /**
4735
+ * Update Camera's {@link Camera#anchorPoints anchorPoints}
4736
+ * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
4737
+ * @throws {FlickingError}
4738
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4739
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4740
+ * @chainable
4741
+ * @return {this}
4742
+ */
4743
+
4744
+
4745
+ __proto.updateAnchors = function () {
4746
+ this._anchors = this._mode.getAnchors();
4747
+ return this;
4748
+ };
4749
+ /**
4750
+ * Update Viewport's height to active panel's height
4751
+ * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
4752
+ * @throws {FlickingError}
4753
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
4754
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
4755
+ * @chainable
4756
+ * @return {this}
4757
+ */
4607
4758
 
4608
- __proto.updateOffset = function () {
4609
- this._updateCircularOffset();
4610
4759
 
4611
- return _super.prototype.updateOffset.call(this);
4760
+ __proto.updateAdaptiveHeight = function () {
4761
+ var flicking = getFlickingAttached(this._flicking);
4762
+ var activePanel = flicking.control.activePanel;
4763
+ if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
4764
+ flicking.viewport.setSize({
4765
+ height: activePanel.height
4766
+ });
4612
4767
  };
4768
+ /**
4769
+ * Update current offset of the camera
4770
+ * @ko 현재 카메라의 오프셋을 업데이트합니다
4771
+ * @chainable
4772
+ * @return {this}
4773
+ */
4613
4774
 
4614
- __proto.lookAt = function (pos) {
4615
- var _this = this;
4616
4775
 
4776
+ __proto.updateOffset = function () {
4617
4777
  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);
4778
+ var position = this._position;
4779
+ var unRenderedPanels = flicking.panels.filter(function (panel) {
4780
+ return !panel.rendered;
4623
4781
  });
4624
- this._position = pos;
4782
+ this._offset = unRenderedPanels.filter(function (panel) {
4783
+ return panel.position + panel.offset < position;
4784
+ }).reduce(function (offset, panel) {
4785
+ return offset + panel.sizeIncludingMargin;
4786
+ }, 0);
4787
+ this._circularOffset = this._mode.getCircularOffset();
4788
+ this.applyTransform();
4789
+ return this;
4790
+ };
4791
+ /**
4792
+ * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
4793
+ * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
4794
+ * @chainable
4795
+ * @return {this}
4796
+ */
4625
4797
 
4626
- _super.prototype.lookAt.call(this, pos);
4627
4798
 
4628
- if (toggled.some(function (isToggled) {
4629
- return isToggled;
4630
- })) {
4631
- void flicking.renderer.render().then(function () {
4632
- _this.updateOffset();
4633
- });
4634
- }
4799
+ __proto.resetNeedPanelHistory = function () {
4800
+ this._needPanelTriggered = {
4801
+ prev: false,
4802
+ next: false
4803
+ };
4804
+ return this;
4635
4805
  };
4806
+ /**
4807
+ * Apply "transform" style with the current position to camera element
4808
+ * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
4809
+ * @return {this}
4810
+ */
4811
+
4636
4812
 
4637
4813
  __proto.applyTransform = function () {
4638
4814
  var el = this._el;
4639
4815
  var flicking = getFlickingAttached(this._flicking);
4816
+ var renderer = flicking.renderer;
4817
+ if (renderer.rendering) return this;
4640
4818
  var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
4641
4819
  el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
4642
4820
  return this;
4643
4821
  };
4644
4822
 
4645
4823
  __proto._resetInternalValues = function () {
4646
- _super.prototype._resetInternalValues.call(this);
4647
-
4824
+ this._position = 0;
4825
+ this._alignPos = 0;
4826
+ this._offset = 0;
4648
4827
  this._circularOffset = 0;
4649
4828
  this._circularEnabled = false;
4829
+ this._range = {
4830
+ min: 0,
4831
+ max: 0
4832
+ };
4833
+ this._visiblePanels = [];
4834
+ this._anchors = [];
4835
+ this._needPanelTriggered = {
4836
+ prev: false,
4837
+ next: false
4838
+ };
4650
4839
  };
4651
4840
 
4652
- __proto._calcPanelAreaSum = function (panels) {
4653
- return panels.reduce(function (sum, panel) {
4654
- return sum + panel.sizeIncludingMargin;
4655
- }, 0);
4656
- };
4657
-
4658
- __proto._updateCircularOffset = function () {
4659
- if (!this._circularEnabled) {
4660
- this._circularOffset = 0;
4661
- return;
4662
- }
4841
+ __proto._refreshVisiblePanels = function () {
4842
+ var _this = this;
4663
4843
 
4664
4844
  var flicking = getFlickingAttached(this._flicking);
4665
- var toggled = flicking.panels.filter(function (panel) {
4666
- return panel.toggled;
4845
+ var panels = flicking.renderer.panels;
4846
+ var newVisiblePanels = panels.filter(function (panel) {
4847
+ return _this.canSee(panel);
4667
4848
  });
4668
- var toggledPrev = toggled.filter(function (panel) {
4669
- return panel.toggleDirection === DIRECTION.PREV;
4849
+ var prevVisiblePanels = this._visiblePanels;
4850
+ this._visiblePanels = newVisiblePanels;
4851
+ var added = newVisiblePanels.filter(function (panel) {
4852
+ return !includes(prevVisiblePanels, panel);
4670
4853
  });
4671
- var toggledNext = toggled.filter(function (panel) {
4672
- return panel.toggleDirection === DIRECTION.NEXT;
4854
+ var removed = prevVisiblePanels.filter(function (panel) {
4855
+ return !includes(newVisiblePanels, panel);
4673
4856
  });
4674
- this._circularOffset = this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
4675
- };
4676
-
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
-
4690
- function BoundCamera() {
4691
- return _super !== null && _super.apply(this, arguments) || this;
4692
- }
4693
- /**
4694
- * Update {@link Camera#range range} of Camera
4695
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
4696
- * @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
- * @return {this}
4701
- */
4702
-
4703
-
4704
- var __proto = BoundCamera.prototype;
4705
-
4706
- __proto.updateRange = function () {
4707
- 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
4857
 
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
- };
4858
+ if (added.length > 0 || removed.length > 0) {
4859
+ void flicking.renderer.render().then(function () {
4860
+ flicking.trigger(new Component.ComponentEvent(EVENTS.VISIBLE_CHANGE, {
4861
+ added: added,
4862
+ removed: removed,
4863
+ visiblePanels: newVisiblePanels
4864
+ }));
4865
+ });
4742
4866
  }
4743
-
4744
- return this;
4745
4867
  };
4746
4868
 
4747
- __proto.updateAnchors = function () {
4748
- var _this = this;
4749
-
4869
+ __proto._checkNeedPanel = function () {
4870
+ var needPanelTriggered = this._needPanelTriggered;
4871
+ if (needPanelTriggered.prev && needPanelTriggered.next) return;
4750
4872
  var flicking = getFlickingAttached(this._flicking);
4751
4873
  var panels = flicking.renderer.panels;
4752
4874
 
4753
4875
  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);
4761
- });
4762
-
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
- });
4773
- });
4774
-
4775
- if (shouldPrependBoundAnchor) {
4776
- newAnchors.splice(0, 0, new AnchorPoint({
4777
- index: 0,
4778
- position: range.min,
4779
- panel: panels[reachablePanels[0].index - 1]
4876
+ if (!needPanelTriggered.prev) {
4877
+ flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4878
+ direction: DIRECTION.PREV
4780
4879
  }));
4880
+ needPanelTriggered.prev = true;
4781
4881
  }
4782
4882
 
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]
4883
+ if (!needPanelTriggered.next) {
4884
+ flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4885
+ direction: DIRECTION.NEXT
4788
4886
  }));
4887
+ needPanelTriggered.next = true;
4789
4888
  }
4790
4889
 
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);
4795
-
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
- })];
4890
+ return;
4813
4891
  }
4814
4892
 
4815
- return this;
4816
- };
4893
+ var cameraPosition = this._position;
4894
+ var cameraSize = this.size;
4895
+ var cameraRange = this._range;
4896
+ var needPanelThreshold = flicking.needPanelThreshold;
4897
+ var cameraPrev = cameraPosition - this._alignPos;
4898
+ var cameraNext = cameraPrev + cameraSize;
4899
+ var firstPanel = panels[0];
4900
+ var lastPanel = panels[panels.length - 1];
4817
4901
 
4818
- __proto.findAnchorIncludePosition = function (position) {
4819
- var range = this._range;
4820
- var anchors = this._anchors;
4821
- if (anchors.length <= 0) return null;
4902
+ if (!needPanelTriggered.prev) {
4903
+ var firstPanelPrev = firstPanel.range.min;
4822
4904
 
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);
4905
+ if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
4906
+ flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4907
+ direction: DIRECTION.PREV
4908
+ }));
4909
+ needPanelTriggered.prev = true;
4910
+ }
4911
+ }
4912
+
4913
+ if (!needPanelTriggered.next) {
4914
+ var lastPanelNext = lastPanel.range.max;
4915
+
4916
+ if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
4917
+ flicking.trigger(new Component.ComponentEvent(EVENTS.NEED_PANEL, {
4918
+ direction: DIRECTION.NEXT
4919
+ }));
4920
+ needPanelTriggered.next = true;
4921
+ }
4829
4922
  }
4830
4923
  };
4831
4924
 
4832
- __proto._findNearestPanel = function (pos, panels) {
4833
- var prevDist = Infinity;
4925
+ __proto._checkReachEnd = function (prevPos, newPos) {
4926
+ var flicking = getFlickingAttached(this._flicking);
4927
+ var range = this._range;
4928
+ var wasBetweenRange = prevPos > range.min && prevPos < range.max;
4929
+ var isBetweenRange = newPos > range.min && newPos < range.max;
4930
+ if (!wasBetweenRange || isBetweenRange) return;
4931
+ var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
4932
+ flicking.trigger(new Component.ComponentEvent(EVENTS.REACH_EDGE, {
4933
+ direction: direction
4934
+ }));
4935
+ };
4834
4936
 
4835
- for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
4836
- var panel = panels[panelIdx];
4837
- var dist = Math.abs(panel.position - pos);
4937
+ __proto._updateMode = function () {
4938
+ var flicking = getFlickingAttached(this._flicking);
4838
4939
 
4839
- if (dist > prevDist) {
4840
- // Return previous anchor
4841
- return panels[panelIdx - 1];
4842
- }
4940
+ if (flicking.circular) {
4941
+ var circularMode = new CircularCameraMode(flicking);
4942
+ var canSetCircularMode = circularMode.checkAvailability();
4843
4943
 
4844
- prevDist = dist;
4845
- } // Return last anchor
4944
+ if (canSetCircularMode) {
4945
+ this._mode = circularMode;
4946
+ } else {
4947
+ var fallbackMode = flicking.circularFallback;
4948
+ this._mode = fallbackMode === CIRCULAR_FALLBACK.BOUND ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
4949
+ }
4846
4950
 
4951
+ this._circularEnabled = canSetCircularMode;
4952
+ } else {
4953
+ this._mode = flicking.bound ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
4954
+ }
4955
+ };
4847
4956
 
4848
- return panels[panels.length - 1];
4957
+ __proto._togglePanels = function (prevPos, pos) {
4958
+ if (pos === prevPos) return false;
4959
+ var flicking = getFlickingAttached(this._flicking);
4960
+ var panels = flicking.renderer.panels;
4961
+ var toggled = panels.map(function (panel) {
4962
+ return panel.toggle(prevPos, pos);
4963
+ });
4964
+ return toggled.some(function (isToggled) {
4965
+ return isToggled;
4966
+ });
4849
4967
  };
4850
4968
 
4851
- return BoundCamera;
4852
- }(Camera$1);
4969
+ return Camera;
4970
+ }();
4853
4971
 
4854
4972
  /*
4855
4973
  * Copyright (c) 2015 NAVER Corp.
@@ -4859,9 +4977,9 @@ version: 4.4.2
4859
4977
  var Camera = {
4860
4978
  __proto__: null,
4861
4979
  Camera: Camera$1,
4862
- LinearCamera: LinearCamera,
4863
- CircularCamera: CircularCamera,
4864
- BoundCamera: BoundCamera
4980
+ LinearCameraMode: LinearCameraMode,
4981
+ CircularCameraMode: CircularCameraMode,
4982
+ BoundCameraMode: BoundCameraMode
4865
4983
  };
4866
4984
 
4867
4985
  /**
@@ -4882,7 +5000,8 @@ version: 4.4.2
4882
5000
  align = _b === void 0 ? ALIGN.CENTER : _b,
4883
5001
  strategy = _a.strategy;
4884
5002
  this._flicking = null;
4885
- this._panels = []; // Bind options
5003
+ this._panels = [];
5004
+ this._rendering = false; // Bind options
4886
5005
 
4887
5006
  this._align = align;
4888
5007
  this._strategy = strategy;
@@ -4905,6 +5024,20 @@ version: 4.4.2
4905
5024
  enumerable: false,
4906
5025
  configurable: true
4907
5026
  });
5027
+ Object.defineProperty(__proto, "rendering", {
5028
+ /**
5029
+ * A boolean value indicating whether rendering is in progress
5030
+ * @ko 현재 렌더링이 시작되어 끝나기 전까지의 상태인지의 여부
5031
+ * @type {boolean}
5032
+ * @readonly
5033
+ * @internal
5034
+ */
5035
+ get: function () {
5036
+ return this._rendering;
5037
+ },
5038
+ enumerable: false,
5039
+ configurable: true
5040
+ });
4908
5041
  Object.defineProperty(__proto, "panelCount", {
4909
5042
  /**
4910
5043
  * Count of panels
@@ -5036,6 +5169,25 @@ version: 4.4.2
5036
5169
 
5037
5170
 
5038
5171
  __proto.batchInsert = function () {
5172
+ var items = [];
5173
+
5174
+ for (var _i = 0; _i < arguments.length; _i++) {
5175
+ items[_i] = arguments[_i];
5176
+ }
5177
+
5178
+ var allPanelsInserted = this.batchInsertDefer.apply(this, __spread(items));
5179
+ if (allPanelsInserted.length <= 0) return [];
5180
+ this.updateAfterPanelChange(allPanelsInserted, []);
5181
+ return allPanelsInserted;
5182
+ };
5183
+ /**
5184
+ * Defers update
5185
+ * camera position & others will be updated after calling updateAfterPanelChange
5186
+ * @internal
5187
+ */
5188
+
5189
+
5190
+ __proto.batchInsertDefer = function () {
5039
5191
  var _this = this;
5040
5192
 
5041
5193
  var items = [];
@@ -5046,7 +5198,6 @@ version: 4.4.2
5046
5198
 
5047
5199
  var panels = this._panels;
5048
5200
  var flicking = getFlickingAttached(this._flicking);
5049
- var control = flicking.control;
5050
5201
  var prevFirstPanel = panels[0];
5051
5202
  var align = parsePanelAlign(this._align);
5052
5203
  var allPanelsInserted = items.reduce(function (addedPanels, item) {
@@ -5061,7 +5212,7 @@ version: 4.4.2
5061
5212
  flicking: flicking
5062
5213
  });
5063
5214
  });
5064
- panels.splice.apply(panels, __spreadArray([insertingIdx, 0], __read(panelsInserted)));
5215
+ panels.splice.apply(panels, __spread([insertingIdx, 0], panelsInserted));
5065
5216
 
5066
5217
  if (item.hasDOMInElements) {
5067
5218
  // Insert the actual elements as camera element's children
@@ -5084,29 +5235,8 @@ version: 4.4.2
5084
5235
  panel.increaseIndex(panelsInserted.length);
5085
5236
  panel.updatePosition();
5086
5237
  });
5087
- return __spreadArray(__spreadArray([], __read(addedPanels), false), __read(panelsInserted));
5238
+ return __spread(addedPanels, panelsInserted);
5088
5239
  }, []);
5089
- if (allPanelsInserted.length <= 0) return []; // Update camera & control
5090
-
5091
- this._updateCameraAndControl();
5092
-
5093
- void this.render(); // Move to the first panel added if no panels existed
5094
- // FIXME: fix for animating case
5095
-
5096
- if (allPanelsInserted.length > 0 && !control.animating) {
5097
- void control.moveToPanel(control.activePanel || allPanelsInserted[0], {
5098
- duration: 0
5099
- }).catch(function () {
5100
- return void 0;
5101
- });
5102
- }
5103
-
5104
- flicking.camera.updateOffset();
5105
- flicking.trigger(new Component.ComponentEvent(EVENTS.PANEL_CHANGE, {
5106
- added: allPanelsInserted,
5107
- removed: []
5108
- }));
5109
- this.checkPanelContentsReady(allPanelsInserted);
5110
5240
  return allPanelsInserted;
5111
5241
  };
5112
5242
  /**
@@ -5123,6 +5253,25 @@ version: 4.4.2
5123
5253
 
5124
5254
 
5125
5255
  __proto.batchRemove = function () {
5256
+ var items = [];
5257
+
5258
+ for (var _i = 0; _i < arguments.length; _i++) {
5259
+ items[_i] = arguments[_i];
5260
+ }
5261
+
5262
+ var allPanelsRemoved = this.batchRemoveDefer.apply(this, __spread(items));
5263
+ if (allPanelsRemoved.length <= 0) return [];
5264
+ this.updateAfterPanelChange([], allPanelsRemoved);
5265
+ return allPanelsRemoved;
5266
+ };
5267
+ /**
5268
+ * Defers update
5269
+ * camera position & others will be updated after calling updateAfterPanelChange
5270
+ * @internal
5271
+ */
5272
+
5273
+
5274
+ __proto.batchRemoveDefer = function () {
5126
5275
  var _this = this;
5127
5276
 
5128
5277
  var items = [];
@@ -5133,10 +5282,8 @@ version: 4.4.2
5133
5282
 
5134
5283
  var panels = this._panels;
5135
5284
  var flicking = getFlickingAttached(this._flicking);
5136
- var camera = flicking.camera,
5137
- control = flicking.control;
5285
+ var control = flicking.control;
5138
5286
  var activePanel = control.activePanel;
5139
- var activeIndex = control.activeIndex;
5140
5287
  var allPanelsRemoved = items.reduce(function (removed, item) {
5141
5288
  var index = item.index,
5142
5289
  deleteCount = item.deleteCount;
@@ -5163,34 +5310,62 @@ version: 4.4.2
5163
5310
  control.resetActive();
5164
5311
  }
5165
5312
 
5166
- return __spreadArray(__spreadArray([], __read(removed), false), __read(panelsRemoved));
5167
- }, []); // Update camera & control
5313
+ return __spread(removed, panelsRemoved);
5314
+ }, []);
5315
+ return allPanelsRemoved;
5316
+ };
5317
+ /**
5318
+ * @internal
5319
+ */
5320
+
5321
+
5322
+ __proto.updateAfterPanelChange = function (panelsAdded, panelsRemoved) {
5323
+ var _a;
5324
+
5325
+ var flicking = getFlickingAttached(this._flicking);
5326
+ var camera = flicking.camera,
5327
+ control = flicking.control;
5328
+ var panels = this._panels;
5329
+ var activePanel = control.activePanel; // Update camera & control
5168
5330
 
5169
5331
  this._updateCameraAndControl();
5170
5332
 
5171
- void this.render(); // FIXME: fix for animating case
5333
+ void this.render();
5172
5334
 
5173
- if (allPanelsRemoved.length > 0 && !control.animating) {
5174
- var targetPanel = includes(allPanelsRemoved, activePanel) ? panels[activeIndex] || panels[panels.length - 1] : activePanel;
5335
+ if (!activePanel || activePanel.removed) {
5336
+ if (panels.length <= 0) {
5337
+ // All panels removed
5338
+ camera.lookAt(0);
5339
+ } else {
5340
+ var targetIndex = (_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.index) !== null && _a !== void 0 ? _a : 0;
5341
+
5342
+ if (targetIndex > panels.length - 1) {
5343
+ targetIndex = panels.length - 1;
5344
+ }
5175
5345
 
5176
- if (targetPanel) {
5177
- void control.moveToPanel(targetPanel, {
5346
+ void control.moveToPanel(panels[targetIndex], {
5178
5347
  duration: 0
5179
5348
  }).catch(function () {
5180
5349
  return void 0;
5181
5350
  });
5182
- } else {
5183
- // All panels removed
5184
- camera.lookAt(0);
5185
5351
  }
5352
+ } else {
5353
+ void control.moveToPanel(control.activePanel, {
5354
+ duration: 0
5355
+ }).catch(function () {
5356
+ return void 0;
5357
+ });
5186
5358
  }
5187
5359
 
5188
5360
  flicking.camera.updateOffset();
5189
- flicking.trigger(new Component.ComponentEvent(EVENTS.PANEL_CHANGE, {
5190
- added: [],
5191
- removed: allPanelsRemoved
5192
- }));
5193
- return allPanelsRemoved;
5361
+
5362
+ if (panelsAdded.length > 0 || panelsRemoved.length > 0) {
5363
+ flicking.trigger(new Component.ComponentEvent(EVENTS.PANEL_CHANGE, {
5364
+ added: panelsAdded,
5365
+ removed: panelsRemoved
5366
+ }));
5367
+ this.checkPanelContentsReady(__spread(panelsAdded, panelsRemoved));
5368
+ }
5194
5369
  };
5195
5370
  /**
5196
5371
  * @internal
@@ -5235,6 +5410,7 @@ version: 4.4.2
5235
5410
  });
5236
5411
  if (!flicking.initialized) return;
5237
5412
  camera.updateRange();
5413
+ camera.updateOffset();
5238
5414
  camera.updateAnchors();
5239
5415
 
5240
5416
  if (control.animating) ; else {
@@ -5268,6 +5444,7 @@ version: 4.4.2
5268
5444
  var camera = flicking.camera,
5269
5445
  control = flicking.control;
5270
5446
  camera.updateRange();
5447
+ camera.updateOffset();
5271
5448
  camera.updateAnchors();
5272
5449
  camera.resetNeedPanelHistory();
5273
5450
  control.updateInput();
@@ -6162,7 +6339,7 @@ version: 4.4.2
6162
6339
  var notToggled = renderedPanels.filter(function (panel) {
6163
6340
  return !panel.toggled;
6164
6341
  });
6165
- return __spreadArray(__spreadArray(__spreadArray([], __read(toggledPrev), false), __read(notToggled), false), __read(toggledNext)).map(function (panel) {
6342
+ return __spread(toggledPrev, notToggled, toggledNext).map(function (panel) {
6166
6343
  return panel.index;
6167
6344
  });
6168
6345
  };
@@ -6372,7 +6549,7 @@ version: 4.4.2
6372
6549
  __proto.getRenderingIndexesByOrder = function (flicking) {
6373
6550
  var virtualManager = flicking.virtual;
6374
6551
 
6375
- var visiblePanels = __spreadArray([], __read(flicking.visiblePanels)).filter(function (panel) {
6552
+ var visiblePanels = __spread(flicking.visiblePanels).filter(function (panel) {
6376
6553
  return panel.rendered;
6377
6554
  }).sort(function (panel1, panel2) {
6378
6555
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
@@ -6393,7 +6570,7 @@ version: 4.4.2
6393
6570
  }).map(function (el) {
6394
6571
  return el.idx;
6395
6572
  });
6396
- return __spreadArray(__spreadArray([], __read(visibleIndexes), false), __read(invisibleIndexes));
6573
+ return __spread(visibleIndexes, invisibleIndexes);
6397
6574
  };
6398
6575
 
6399
6576
  __proto.getRenderingElementsByOrder = function (flicking) {
@@ -6516,58 +6693,64 @@ version: 4.4.2
6516
6693
  horizontal = _e === void 0 ? true : _e,
6517
6694
  _f = _b.circular,
6518
6695
  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) {
6696
+ _g = _b.circularFallback,
6697
+ circularFallback = _g === void 0 ? CIRCULAR_FALLBACK.LINEAR : _g,
6698
+ _h = _b.bound,
6699
+ bound = _h === void 0 ? false : _h,
6700
+ _j = _b.adaptive,
6701
+ adaptive = _j === void 0 ? false : _j,
6702
+ _k = _b.panelsPerView,
6703
+ panelsPerView = _k === void 0 ? -1 : _k,
6704
+ _l = _b.noPanelStyleOverride,
6705
+ noPanelStyleOverride = _l === void 0 ? false : _l,
6706
+ _m = _b.resizeOnContentsReady,
6707
+ resizeOnContentsReady = _m === void 0 ? false : _m,
6708
+ _o = _b.needPanelThreshold,
6709
+ needPanelThreshold = _o === void 0 ? 0 : _o,
6710
+ _p = _b.preventEventsBeforeInit,
6711
+ preventEventsBeforeInit = _p === void 0 ? true : _p,
6712
+ _q = _b.deceleration,
6713
+ deceleration = _q === void 0 ? 0.0075 : _q,
6714
+ _r = _b.duration,
6715
+ duration = _r === void 0 ? 500 : _r,
6716
+ _s = _b.easing,
6717
+ easing = _s === void 0 ? function (x) {
6539
6718
  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;
6719
+ } : _s,
6720
+ _t = _b.inputType,
6721
+ inputType = _t === void 0 ? ["mouse", "touch"] : _t,
6722
+ _u = _b.moveType,
6723
+ moveType = _u === void 0 ? "snap" : _u,
6724
+ _v = _b.threshold,
6725
+ threshold = _v === void 0 ? 40 : _v,
6726
+ _w = _b.interruptable,
6727
+ interruptable = _w === void 0 ? true : _w,
6728
+ _x = _b.bounce,
6729
+ bounce = _x === void 0 ? "20%" : _x,
6730
+ _y = _b.iOSEdgeSwipeThreshold,
6731
+ iOSEdgeSwipeThreshold = _y === void 0 ? 30 : _y,
6732
+ _z = _b.preventClickOnDrag,
6733
+ preventClickOnDrag = _z === void 0 ? true : _z,
6734
+ _0 = _b.disableOnInit,
6735
+ disableOnInit = _0 === void 0 ? false : _0,
6736
+ _1 = _b.renderOnlyVisible,
6737
+ renderOnlyVisible = _1 === void 0 ? false : _1,
6738
+ _2 = _b.virtual,
6739
+ virtual = _2 === void 0 ? null : _2,
6740
+ _3 = _b.autoInit,
6741
+ autoInit = _3 === void 0 ? true : _3,
6742
+ _4 = _b.autoResize,
6743
+ autoResize = _4 === void 0 ? true : _4,
6744
+ _5 = _b.useResizeObserver,
6745
+ useResizeObserver = _5 === void 0 ? true : _5,
6746
+ _6 = _b.resizeDebounce,
6747
+ resizeDebounce = _6 === void 0 ? 0 : _6,
6748
+ _7 = _b.maxResizeDebounce,
6749
+ maxResizeDebounce = _7 === void 0 ? 100 : _7,
6750
+ _8 = _b.externalRenderer,
6751
+ externalRenderer = _8 === void 0 ? null : _8,
6752
+ _9 = _b.renderExternal,
6753
+ renderExternal = _9 === void 0 ? null : _9;
6571
6754
 
6572
6755
  var _this = _super.call(this) || this; // Internal states
6573
6756
 
@@ -6579,6 +6762,7 @@ version: 4.4.2
6579
6762
  _this._defaultIndex = defaultIndex;
6580
6763
  _this._horizontal = horizontal;
6581
6764
  _this._circular = circular;
6765
+ _this._circularFallback = circularFallback;
6582
6766
  _this._bound = bound;
6583
6767
  _this._adaptive = adaptive;
6584
6768
  _this._panelsPerView = panelsPerView;
@@ -6602,6 +6786,8 @@ version: 4.4.2
6602
6786
  _this._autoInit = autoInit;
6603
6787
  _this._autoResize = autoResize;
6604
6788
  _this._useResizeObserver = useResizeObserver;
6789
+ _this._resizeDebounce = resizeDebounce;
6790
+ _this._maxResizeDebounce = maxResizeDebounce;
6605
6791
  _this._externalRenderer = externalRenderer;
6606
6792
  _this._renderExternal = renderExternal; // Create core components
6607
6793
 
@@ -6717,7 +6903,7 @@ version: 4.4.2
6717
6903
  * @readonly
6718
6904
  */
6719
6905
  get: function () {
6720
- return this._camera.controlParams.circular;
6906
+ return this._camera.circularEnabled;
6721
6907
  },
6722
6908
  enumerable: false,
6723
6909
  configurable: true
@@ -6951,6 +7137,24 @@ version: 4.4.2
6951
7137
  enumerable: false,
6952
7138
  configurable: true
6953
7139
  });
7140
+ Object.defineProperty(__proto, "circularFallback", {
7141
+ /**
7142
+ * Set panel control mode for the case when circular cannot be enabled.
7143
+ * "linear" will set the view's range from the top of the first panel to the top of the last panel.
7144
+ * "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.
7145
+ * @ko 순환 모드 사용 불가능시 사용할 패널 조작 범위 설정 방식을 변경합니다.
7146
+ * "linear" 사용시 시점이 첫번째 엘리먼트 위에서부터 마지막 엘리먼트 위까지 움직일 수 있도록 설정합니다.
7147
+ * "bound" 사용시 시점이 첫번째 엘리먼트와 마지막 엘리먼트의 끝과 끝 사이에서 움직일 수 있도록 설정합니다.
7148
+ * @see CIRCULAR_FALLBACK
7149
+ * @type {string}
7150
+ * @default "linear"
7151
+ */
7152
+ get: function () {
7153
+ return this._circularFallback;
7154
+ },
7155
+ enumerable: false,
7156
+ configurable: true
7157
+ });
6954
7158
  Object.defineProperty(__proto, "bound", {
6955
7159
  /**
6956
7160
  * 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
@@ -7432,6 +7636,38 @@ version: 4.4.2
7432
7636
  enumerable: false,
7433
7637
  configurable: true
7434
7638
  });
7639
+ Object.defineProperty(__proto, "resizeDebounce", {
7640
+ /**
7641
+ * Delays size recalculation from `autoResize` by the given time in milisecond.
7642
+ * If the size is changed again while being delayed, it cancels the previous one and delays from the beginning again.
7643
+ * This can increase performance by preventing `resize` being called too often.
7644
+ * @ko `autoResize` 설정시에 호출되는 크기 재계산을 주어진 시간(단위: ms)만큼 지연시킵니다.
7645
+ * 지연시키는 도중 크기가 다시 변경되었을 경우, 이전 것을 취소하고 주어진 시간만큼 다시 지연시킵니다.
7646
+ * 이를 통해 `resize`가 너무 많이 호출되는 것을 방지하여 성능을 향상시킬 수 있습니다.
7647
+ * @type {number}
7648
+ * @default 0
7649
+ */
7650
+ get: function () {
7651
+ return this._resizeDebounce;
7652
+ },
7653
+ enumerable: false,
7654
+ configurable: true
7655
+ });
7656
+ Object.defineProperty(__proto, "maxResizeDebounce", {
7657
+ /**
7658
+ * The maximum time for size recalculation delay when using `resizeDebounce`, in milisecond.
7659
+ * This guarantees that size recalculation is performed at least once every (n)ms.
7660
+ * @ko `resizeDebounce` 사용시에 크기 재계산이 지연되는 최대 시간을 지정합니다. (단위: ms)
7661
+ * 이를 통해, 적어도 (n)ms에 한번은 크기 재계산을 수행하는 것을 보장할 수 있습니다.
7662
+ * @type {number}
7663
+ * @default 100
7664
+ */
7665
+ get: function () {
7666
+ return this._maxResizeDebounce;
7667
+ },
7668
+ enumerable: false,
7669
+ configurable: true
7670
+ });
7435
7671
  Object.defineProperty(__proto, "externalRenderer", {
7436
7672
  /**
7437
7673
  * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
@@ -7467,85 +7703,61 @@ version: 4.4.2
7467
7703
  * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
7468
7704
  * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
7469
7705
  * @fires Flicking#ready
7470
- * @return {this}
7706
+ * @return {Promise<void>}
7471
7707
  */
7472
7708
 
7473
7709
  __proto.init = function () {
7474
- return __awaiter(this, void 0, void 0, function () {
7475
- var camera, renderer, control, virtualManager, originalTrigger, preventEventsBeforeInit;
7476
-
7477
- var _this = this;
7478
-
7479
- return __generator(this, function (_a) {
7480
- switch (_a.label) {
7481
- case 0:
7482
- if (this._initialized) return [2
7483
- /*return*/
7484
- ];
7485
- camera = this._camera;
7486
- renderer = this._renderer;
7487
- control = this._control;
7488
- virtualManager = this._virtualManager;
7489
- originalTrigger = this.trigger;
7490
- preventEventsBeforeInit = this._preventEventsBeforeInit;
7491
- camera.init(this);
7492
- virtualManager.init();
7493
- renderer.init(this);
7494
- control.init(this);
7495
-
7496
- if (preventEventsBeforeInit) {
7497
- this.trigger = function () {
7498
- return _this;
7499
- };
7500
- }
7501
-
7502
- return [4
7503
- /*yield*/
7504
- , this.resize()];
7505
-
7506
- case 1:
7507
- _a.sent(); // Look at initial panel
7508
-
7710
+ var _this = this;
7509
7711
 
7510
- return [4
7511
- /*yield*/
7512
- , this._moveToInitialPanel()];
7712
+ if (this._initialized) return Promise.resolve();
7713
+ var camera = this._camera;
7714
+ var renderer = this._renderer;
7715
+ var control = this._control;
7716
+ var virtualManager = this._virtualManager;
7717
+ var originalTrigger = this.trigger;
7718
+ var preventEventsBeforeInit = this._preventEventsBeforeInit;
7719
+ camera.init();
7720
+ virtualManager.init();
7721
+ renderer.init(this);
7722
+ control.init(this);
7723
+
7724
+ if (preventEventsBeforeInit) {
7725
+ this.trigger = function () {
7726
+ return _this;
7727
+ };
7728
+ }
7513
7729
 
7514
- case 2:
7515
- // Look at initial panel
7516
- _a.sent();
7730
+ this._initialResize(); // Look at initial panel
7517
7731
 
7518
- if (this._autoResize) {
7519
- this._autoResizer.enable();
7520
- }
7521
7732
 
7522
- if (this._preventClickOnDrag) {
7523
- control.controller.addPreventClickHandler();
7524
- }
7733
+ this._moveToInitialPanel();
7525
7734
 
7526
- if (this._disableOnInit) {
7527
- this.disableInput();
7528
- }
7735
+ if (this._autoResize) {
7736
+ this._autoResizer.enable();
7737
+ }
7529
7738
 
7530
- renderer.checkPanelContentsReady(renderer.panels);
7739
+ if (this._preventClickOnDrag) {
7740
+ control.controller.addPreventClickHandler();
7741
+ }
7531
7742
 
7532
- this._plugins.forEach(function (plugin) {
7533
- return plugin.init(_this);
7534
- }); // Done initializing & emit ready event
7743
+ if (this._disableOnInit) {
7744
+ this.disableInput();
7745
+ }
7535
7746
 
7747
+ renderer.checkPanelContentsReady(renderer.panels);
7748
+ return renderer.render().then(function () {
7749
+ // Done initializing & emit ready event
7750
+ _this._plugins.forEach(function (plugin) {
7751
+ return plugin.init(_this);
7752
+ });
7536
7753
 
7537
- this._initialized = true;
7754
+ _this._initialized = true;
7538
7755
 
7539
- if (preventEventsBeforeInit) {
7540
- this.trigger = originalTrigger;
7541
- }
7756
+ if (preventEventsBeforeInit) {
7757
+ _this.trigger = originalTrigger;
7758
+ }
7542
7759
 
7543
- this.trigger(new Component.ComponentEvent(EVENTS.READY));
7544
- return [2
7545
- /*return*/
7546
- ];
7547
- }
7548
- });
7760
+ _this.trigger(new Component.ComponentEvent(EVENTS.READY));
7549
7761
  });
7550
7762
  };
7551
7763
  /**
@@ -7911,7 +8123,7 @@ version: 4.4.2
7911
8123
  });
7912
8124
  }
7913
8125
 
7914
- (_a = this._plugins).push.apply(_a, __spreadArray([], __read(plugins)));
8126
+ (_a = this._plugins).push.apply(_a, __spread(plugins));
7915
8127
 
7916
8128
  return this;
7917
8129
  };
@@ -8158,22 +8370,14 @@ version: 4.4.2
8158
8370
  };
8159
8371
 
8160
8372
  __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);
8373
+ if (this._circular && this._bound) {
8374
+ // eslint-disable-next-line no-console
8375
+ console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
8176
8376
  }
8377
+
8378
+ return new Camera$1(this, {
8379
+ align: this._align
8380
+ });
8177
8381
  };
8178
8382
 
8179
8383
  __proto._createRenderer = function () {
@@ -8207,23 +8411,59 @@ version: 4.4.2
8207
8411
  };
8208
8412
 
8209
8413
  __proto._moveToInitialPanel = function () {
8210
- return __awaiter(this, void 0, void 0, function () {
8211
- var renderer, control, initialPanel;
8212
- return __generator(this, function (_a) {
8213
- renderer = this._renderer;
8214
- control = this._control;
8215
- initialPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
8216
- if (!initialPanel) return [2
8217
- /*return*/
8218
- ];
8219
- control.setActive(initialPanel, null, false);
8220
- return [2
8221
- /*return*/
8222
- , control.moveToPanel(initialPanel, {
8223
- duration: 0
8224
- })];
8225
- });
8226
- });
8414
+ var renderer = this._renderer;
8415
+ var control = this._control;
8416
+ var camera = this._camera;
8417
+ var initialPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
8418
+ if (!initialPanel) return;
8419
+ var nearestAnchor = camera.findNearestAnchor(initialPanel.position);
8420
+ control.setActive(initialPanel, null, false);
8421
+
8422
+ if (!nearestAnchor) {
8423
+ throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(initialPanel.position), CODE.POSITION_NOT_REACHABLE);
8424
+ }
8425
+
8426
+ var position = initialPanel.position;
8427
+
8428
+ if (!camera.canReach(initialPanel)) {
8429
+ position = nearestAnchor.position;
8430
+ }
8431
+
8432
+ camera.lookAt(position);
8433
+ control.updateInput();
8434
+ camera.updateOffset();
8435
+ };
8436
+
8437
+ __proto._initialResize = function () {
8438
+ var viewport = this._viewport;
8439
+ var renderer = this._renderer;
8440
+ var camera = this._camera;
8441
+ var control = this._control;
8442
+ this.trigger(new Component.ComponentEvent(EVENTS.BEFORE_RESIZE, {
8443
+ width: 0,
8444
+ height: 0,
8445
+ element: viewport.element
8446
+ }));
8447
+ viewport.resize();
8448
+ renderer.updatePanelSize();
8449
+ camera.updateAlignPos();
8450
+ camera.updateRange();
8451
+ camera.updateAnchors();
8452
+ camera.updateOffset();
8453
+ control.updateInput();
8454
+ var newWidth = viewport.width;
8455
+ var newHeight = viewport.height;
8456
+ var sizeChanged = newWidth !== 0 || newHeight !== 0;
8457
+ this.trigger(new Component.ComponentEvent(EVENTS.AFTER_RESIZE, {
8458
+ width: viewport.width,
8459
+ height: viewport.height,
8460
+ prev: {
8461
+ width: 0,
8462
+ height: 0
8463
+ },
8464
+ sizeChanged: sizeChanged,
8465
+ element: viewport.element
8466
+ }));
8227
8467
  };
8228
8468
  /**
8229
8469
  * Version info string
@@ -8237,7 +8477,7 @@ version: 4.4.2
8237
8477
  */
8238
8478
 
8239
8479
 
8240
- Flicking.VERSION = "4.4.2";
8480
+ Flicking.VERSION = "4.6.0";
8241
8481
  return Flicking;
8242
8482
  }(Component);
8243
8483
 
@@ -8277,7 +8517,7 @@ version: 4.4.2
8277
8517
  var withFlickingMethods = function (prototype, flickingName) {
8278
8518
  [Component.prototype, Flicking.prototype].forEach(function (proto) {
8279
8519
  Object.getOwnPropertyNames(proto).filter(function (name) {
8280
- return !prototype[name] && !name.startsWith("_") && name !== "constructor";
8520
+ return !prototype[name] && name.indexOf("_") !== 0 && name !== "constructor";
8281
8521
  }).forEach(function (name) {
8282
8522
  var descriptor = Object.getOwnPropertyDescriptor(proto, name);
8283
8523
 
@@ -8293,7 +8533,7 @@ version: 4.4.2
8293
8533
  args[_i] = arguments[_i];
8294
8534
  }
8295
8535
 
8296
- return (_a = descriptor.value).call.apply(_a, __spreadArray([this[flickingName]], __read(args)));
8536
+ return (_a = descriptor.value).call.apply(_a, __spread([this[flickingName]], args));
8297
8537
  }
8298
8538
  });
8299
8539
  } else {
@@ -8303,7 +8543,8 @@ version: 4.4.2
8303
8543
  getterDescriptor.get = function () {
8304
8544
  var _a;
8305
8545
 
8306
- return (_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(this[flickingName]);
8546
+ var flicking = this[flickingName];
8547
+ return flicking && ((_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(flicking));
8307
8548
  };
8308
8549
  }
8309
8550
 
@@ -8317,7 +8558,7 @@ version: 4.4.2
8317
8558
  args[_i] = arguments[_i];
8318
8559
  }
8319
8560
 
8320
- return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([this[flickingName]], __read(args)));
8561
+ return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spread([this[flickingName]], args));
8321
8562
  };
8322
8563
  }
8323
8564
 
@@ -8331,7 +8572,10 @@ version: 4.4.2
8331
8572
  var renderer = flicking.renderer;
8332
8573
  var panels = renderer.panels;
8333
8574
 
8334
- var prevList = __spreadArray([], __read(diffResult.prevList));
8575
+ var prevList = __spread(diffResult.prevList);
8576
+
8577
+ var added = [];
8578
+ var removed = [];
8335
8579
 
8336
8580
  if (diffResult.removed.length > 0) {
8337
8581
  var endIdx_1 = -1;
@@ -8342,7 +8586,7 @@ version: 4.4.2
8342
8586
  }
8343
8587
 
8344
8588
  if (prevIdx_1 >= 0 && removedIdx !== prevIdx_1 - 1) {
8345
- batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
8589
+ removed.push.apply(removed, __spread(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
8346
8590
  endIdx_1 = removedIdx;
8347
8591
  prevIdx_1 = removedIdx;
8348
8592
  } else {
@@ -8351,39 +8595,34 @@ version: 4.4.2
8351
8595
 
8352
8596
  prevList.splice(removedIdx, 1);
8353
8597
  });
8354
- batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
8598
+ removed.push.apply(removed, __spread(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
8355
8599
  }
8356
8600
 
8357
8601
  diffResult.ordered.forEach(function (_a) {
8358
8602
  var _b = __read(_a, 2),
8359
- prevIdx = _b[0],
8360
- newIdx = _b[1];
8361
-
8362
- var prevPanel = panels[prevIdx];
8363
- var indexDiff = newIdx - prevIdx;
8364
-
8365
- if (indexDiff > 0) {
8366
- var middlePanels = panels.slice(prevIdx + 1, newIdx + 1);
8367
- prevPanel.increaseIndex(indexDiff);
8368
- middlePanels.forEach(function (panel) {
8369
- return panel.decreaseIndex(1);
8370
- });
8371
- } else {
8372
- var middlePanels = panels.slice(newIdx, prevIdx);
8373
- prevPanel.decreaseIndex(-indexDiff);
8374
- middlePanels.forEach(function (panel) {
8375
- return panel.increaseIndex(1);
8376
- });
8377
- } // Update position
8603
+ from = _b[0],
8604
+ to = _b[1];
8378
8605
 
8379
-
8380
- prevPanel.resize();
8606
+ var prevPanel = panels.splice(from, 1)[0];
8607
+ panels.splice(to, 0, prevPanel);
8381
8608
  });
8382
8609
 
8383
8610
  if (diffResult.ordered.length > 0) {
8611
+ panels.forEach(function (panel, idx) {
8612
+ var indexDiff = idx - panel.index;
8613
+
8614
+ if (indexDiff > 0) {
8615
+ panel.increaseIndex(indexDiff);
8616
+ } else {
8617
+ panel.decreaseIndex(-indexDiff);
8618
+ }
8619
+ });
8384
8620
  panels.sort(function (panel1, panel2) {
8385
8621
  return panel1.index - panel2.index;
8386
8622
  });
8623
+ panels.forEach(function (panel) {
8624
+ panel.updatePosition();
8625
+ });
8387
8626
  }
8388
8627
 
8389
8628
  if (diffResult.added.length > 0) {
@@ -8396,7 +8635,7 @@ version: 4.4.2
8396
8635
  }
8397
8636
 
8398
8637
  if (prevIdx_2 >= 0 && addedIdx !== prevIdx_2 + 1) {
8399
- batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1);
8638
+ added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1)));
8400
8639
  startIdx_1 = -1;
8401
8640
  prevIdx_2 = -1;
8402
8641
  } else {
@@ -8405,24 +8644,26 @@ version: 4.4.2
8405
8644
  });
8406
8645
 
8407
8646
  if (startIdx_1 >= 0) {
8408
- batchInsert(renderer, diffResult, addedElements_1, startIdx_1);
8647
+ added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1, startIdx_1)));
8409
8648
  }
8410
8649
  }
8650
+
8651
+ renderer.updateAfterPanelChange(added, removed);
8411
8652
  });
8412
8653
 
8413
8654
  var batchInsert = function (renderer, diffResult, addedElements, startIdx, endIdx) {
8414
- renderer.batchInsert.apply(renderer, __spreadArray([], __read(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
8655
+ return renderer.batchInsertDefer.apply(renderer, __spread(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
8415
8656
  return {
8416
8657
  index: index,
8417
8658
  elements: [addedElements[elIdx]],
8418
8659
  hasDOMInElements: false
8419
8660
  };
8420
- }))));
8661
+ })));
8421
8662
  };
8422
8663
 
8423
8664
  var batchRemove = function (renderer, startIdx, endIdx) {
8424
8665
  var removed = renderer.panels.slice(startIdx, endIdx);
8425
- renderer.batchRemove({
8666
+ return renderer.batchRemoveDefer({
8426
8667
  index: startIdx,
8427
8668
  deleteCount: removed.length,
8428
8669
  hasDOMInElements: false
@@ -8442,16 +8683,16 @@ version: 4.4.2
8442
8683
  map[prev] = current;
8443
8684
  return map;
8444
8685
  }, {});
8445
- return __spreadArray(__spreadArray([], __read(flicking.panels.filter(function (panel) {
8686
+ return __spread(flicking.panels.filter(function (panel) {
8446
8687
  return !removedPanels[panel.index];
8447
8688
  }) // Sort panels by position
8448
8689
  .sort(function (panel1, panel2) {
8449
8690
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
8450
8691
  }).map(function (panel) {
8451
8692
  return diffResult.list[maintainedMap[panel.index]];
8452
- })), false), __read(diffResult.added.map(function (idx) {
8693
+ }), diffResult.added.map(function (idx) {
8453
8694
  return diffResult.list[idx];
8454
- })));
8695
+ }));
8455
8696
  });
8456
8697
 
8457
8698
  var getDefaultCameraTransform = (function (align, horizontal, firstPanelSize) {