@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
@@ -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() :
@@ -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$1() {
248
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read$1(arguments[i]));
249
+
250
+ return ar;
249
251
  }
250
252
 
251
253
  /*
@@ -893,6 +895,18 @@ version: 4.4.2
893
895
  HIDDEN: "flicking-hidden",
894
896
  DEFAULT_VIRTUAL: "flicking-panel"
895
897
  };
898
+ /**
899
+ * An object with all possible {@link Flicking#circularFallback circularFallback}s
900
+ * @ko Flicking의 {@link Flicking#circularFallback circularFallback}에 설정 가능한 값들을 담고 있는 객체
901
+ * @type {object}
902
+ * @property {string} LINEAR "linear"
903
+ * @property {string} BOUND "bound"
904
+ */
905
+
906
+ var CIRCULAR_FALLBACK = {
907
+ LINEAR: "linear",
908
+ BOUND: "bound"
909
+ };
896
910
 
897
911
  var Constants = {
898
912
  __proto__: null,
@@ -901,6 +915,7 @@ version: 4.4.2
901
915
  DIRECTION: DIRECTION,
902
916
  MOVE_TYPE: MOVE_TYPE,
903
917
  CLASS: CLASS,
918
+ CIRCULAR_FALLBACK: CIRCULAR_FALLBACK,
904
919
  ERROR_CODE: CODE
905
920
  };
906
921
 
@@ -1086,7 +1101,7 @@ version: 4.4.2
1086
1101
  if (isString(el)) {
1087
1102
  var tempDiv = document.createElement("div");
1088
1103
  tempDiv.innerHTML = el;
1089
- elements.push.apply(elements, __spreadArray([], __read$1(toArray$3(tempDiv.children))));
1104
+ elements.push.apply(elements, __spread$1(toArray$3(tempDiv.children)));
1090
1105
 
1091
1106
  while (tempDiv.firstChild) {
1092
1107
  tempDiv.removeChild(tempDiv.firstChild);
@@ -1467,6 +1482,33 @@ version: 4.4.2
1467
1482
  var _this = this;
1468
1483
 
1469
1484
  this._onResize = function () {
1485
+ var flicking = _this._flicking;
1486
+ var resizeDebounce = flicking.resizeDebounce;
1487
+ var maxResizeDebounce = flicking.maxResizeDebounce;
1488
+
1489
+ if (resizeDebounce <= 0) {
1490
+ void flicking.resize();
1491
+ } else {
1492
+ if (_this._maxResizeDebounceTimer <= 0) {
1493
+ if (maxResizeDebounce > 0 && maxResizeDebounce >= resizeDebounce) {
1494
+ _this._maxResizeDebounceTimer = window.setTimeout(_this._doScheduledResize, maxResizeDebounce);
1495
+ }
1496
+ }
1497
+
1498
+ if (_this._resizeTimer > 0) {
1499
+ clearTimeout(_this._resizeTimer);
1500
+ _this._resizeTimer = 0;
1501
+ }
1502
+
1503
+ _this._resizeTimer = window.setTimeout(_this._doScheduledResize, resizeDebounce);
1504
+ }
1505
+ };
1506
+
1507
+ this._doScheduledResize = function () {
1508
+ clearTimeout(_this._resizeTimer);
1509
+ clearTimeout(_this._maxResizeDebounceTimer);
1510
+ _this._maxResizeDebounceTimer = -1;
1511
+ _this._resizeTimer = -1;
1470
1512
  void _this._flicking.resize();
1471
1513
  }; // eslint-disable-next-line @typescript-eslint/member-ordering
1472
1514
 
@@ -1486,6 +1528,8 @@ version: 4.4.2
1486
1528
  this._flicking = flicking;
1487
1529
  this._enabled = false;
1488
1530
  this._resizeObserver = null;
1531
+ this._resizeTimer = -1;
1532
+ this._maxResizeDebounceTimer = -1;
1489
1533
  }
1490
1534
 
1491
1535
  var __proto = AutoResizer.prototype;
@@ -9443,9 +9487,8 @@ version: 4.4.2
9443
9487
 
9444
9488
 
9445
9489
  function SnapControl(_a) {
9446
- var _b = _a === void 0 ? {} : _a,
9447
- _c = _b.count,
9448
- count = _c === void 0 ? Infinity : _c;
9490
+ var _b = (_a === void 0 ? {} : _a).count,
9491
+ count = _b === void 0 ? Infinity : _b;
9449
9492
 
9450
9493
  var _this = _super.call(this) || this;
9451
9494
 
@@ -9651,9 +9694,8 @@ version: 4.4.2
9651
9694
 
9652
9695
 
9653
9696
  function FreeControl(_a) {
9654
- var _b = _a === void 0 ? {} : _a,
9655
- _c = _b.stopAtEdge,
9656
- stopAtEdge = _c === void 0 ? true : _c;
9697
+ var _b = (_a === void 0 ? {} : _a).stopAtEdge,
9698
+ stopAtEdge = _b === void 0 ? true : _b;
9657
9699
 
9658
9700
  var _this = _super.call(this) || this;
9659
9701
 
@@ -9787,9 +9829,8 @@ version: 4.4.2
9787
9829
 
9788
9830
 
9789
9831
  function StrictControl(_a) {
9790
- var _b = _a === void 0 ? {} : _a,
9791
- _c = _b.count,
9792
- count = _c === void 0 ? 1 : _c;
9832
+ var _b = (_a === void 0 ? {} : _a).count,
9833
+ count = _b === void 0 ? 1 : _b;
9793
9834
 
9794
9835
  var _this = _super.call(this) || this;
9795
9836
 
@@ -9912,6 +9953,21 @@ version: 4.4.2
9912
9953
  };
9913
9954
  return this;
9914
9955
  };
9956
+
9957
+ __proto.moveToPanel = function (panel, options) {
9958
+ return __awaiter(this, void 0, void 0, function () {
9959
+ var flicking, camera, controller;
9960
+ return __generator(this, function (_a) {
9961
+ flicking = getFlickingAttached(this._flicking);
9962
+ camera = flicking.camera;
9963
+ controller = this._controller;
9964
+ controller.update(camera.controlParams);
9965
+ return [2
9966
+ /*return*/
9967
+ , _super.prototype.moveToPanel.call(this, panel, options)];
9968
+ });
9969
+ });
9970
+ };
9915
9971
  /**
9916
9972
  * Move {@link Camera} to the given position
9917
9973
  * @ko {@link Camera}를 주어진 좌표로 이동합니다
@@ -10042,197 +10098,663 @@ version: 4.4.2
10042
10098
  };
10043
10099
 
10044
10100
  /**
10045
- * A component that manages actual movement inside the viewport
10046
- * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
10101
+ * A mode of camera
10047
10102
  */
10048
10103
 
10049
- var Camera$1 =
10104
+ var CameraMode =
10050
10105
  /*#__PURE__*/
10051
10106
  function () {
10052
10107
  /** */
10053
- function Camera(_a) {
10054
- var _this = this;
10108
+ function CameraMode(flicking) {
10109
+ this._flicking = flicking;
10110
+ }
10055
10111
 
10056
- var _b = _a === void 0 ? {} : _a,
10057
- _c = _b.align,
10058
- align = _c === void 0 ? ALIGN.CENTER : _c;
10112
+ var __proto = CameraMode.prototype;
10059
10113
 
10060
- this._checkTranslateSupport = function () {
10061
- var e_1, _a;
10114
+ __proto.getAnchors = function () {
10115
+ var panels = this._flicking.renderer.panels;
10116
+ return panels.map(function (panel, index) {
10117
+ return new AnchorPoint({
10118
+ index: index,
10119
+ position: panel.position,
10120
+ panel: panel
10121
+ });
10122
+ });
10123
+ };
10062
10124
 
10063
- var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
10064
- var supportedStyle = document.documentElement.style;
10065
- var transformName = "";
10125
+ __proto.findAnchorIncludePosition = function (position) {
10126
+ var anchors = this._flicking.camera.anchorPoints;
10127
+ var anchorsIncludingPosition = anchors.filter(function (anchor) {
10128
+ return anchor.panel.includePosition(position, true);
10129
+ });
10130
+ return anchorsIncludingPosition.reduce(function (nearest, anchor) {
10131
+ if (!nearest) return anchor;
10132
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
10133
+ }, null);
10134
+ };
10066
10135
 
10067
- try {
10068
- for (var transforms_1 = __values$2(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
10069
- var prefixedTransform = transforms_1_1.value;
10136
+ __proto.clampToReachablePosition = function (position) {
10137
+ var camera = this._flicking.camera;
10138
+ var range = camera.range;
10139
+ return clamp(position, range.min, range.max);
10140
+ };
10070
10141
 
10071
- if (prefixedTransform in supportedStyle) {
10072
- transformName = prefixedTransform;
10073
- }
10074
- }
10075
- } catch (e_1_1) {
10076
- e_1 = {
10077
- error: e_1_1
10078
- };
10079
- } finally {
10080
- try {
10081
- if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
10082
- } finally {
10083
- if (e_1) throw e_1.error;
10084
- }
10085
- }
10142
+ __proto.getCircularOffset = function () {
10143
+ return 0;
10144
+ };
10086
10145
 
10087
- if (!transformName) {
10088
- throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
10089
- }
10146
+ __proto.canReach = function (panel) {
10147
+ var camera = this._flicking.camera;
10148
+ var range = camera.range;
10149
+ if (panel.removed) return false;
10150
+ var panelPos = panel.position;
10151
+ return panelPos >= range.min && panelPos <= range.max;
10152
+ };
10090
10153
 
10091
- _this._transform = transformName;
10154
+ __proto.canSee = function (panel) {
10155
+ var camera = this._flicking.camera;
10156
+ var visibleRange = camera.visibleRange; // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
10157
+
10158
+ return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
10159
+ };
10160
+
10161
+ return CameraMode;
10162
+ }();
10163
+
10164
+ var LinearCameraMode =
10165
+ /*#__PURE__*/
10166
+ function (_super) {
10167
+ __extends$2(LinearCameraMode, _super);
10168
+
10169
+ function LinearCameraMode() {
10170
+ return _super !== null && _super.apply(this, arguments) || this;
10171
+ }
10172
+
10173
+ var __proto = LinearCameraMode.prototype;
10174
+
10175
+ __proto.checkAvailability = function () {
10176
+ // It's always available
10177
+ return true;
10178
+ };
10179
+
10180
+ __proto.getRange = function () {
10181
+ var _a, _b;
10182
+
10183
+ var renderer = this._flicking.renderer;
10184
+ var firstPanel = renderer.getPanel(0);
10185
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
10186
+ return {
10187
+ min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
10188
+ max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
10092
10189
  };
10190
+ };
10093
10191
 
10094
- this._flicking = null;
10192
+ return LinearCameraMode;
10193
+ }(CameraMode);
10095
10194
 
10096
- this._resetInternalValues(); // Options
10195
+ /**
10196
+ * A {@link Camera} mode that connects the last panel and the first panel, enabling continuous loop
10197
+ * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera} 모드
10198
+ */
10097
10199
 
10200
+ var CircularCameraMode =
10201
+ /*#__PURE__*/
10202
+ function (_super) {
10203
+ __extends$2(CircularCameraMode, _super);
10098
10204
 
10099
- this._align = align;
10205
+ function CircularCameraMode() {
10206
+ return _super !== null && _super.apply(this, arguments) || this;
10100
10207
  }
10101
10208
 
10102
- var __proto = Camera.prototype;
10103
- Object.defineProperty(__proto, "element", {
10104
- // Internal states getter
10209
+ var __proto = CircularCameraMode.prototype;
10105
10210
 
10106
- /**
10107
- * The camera element(`.flicking-camera`)
10108
- * @ko 카메라 엘리먼트(`.flicking-camera`)
10109
- * @type {HTMLElement}
10110
- * @readonly
10111
- */
10112
- get: function () {
10113
- return this._el;
10114
- },
10115
- enumerable: false,
10116
- configurable: true
10117
- });
10118
- Object.defineProperty(__proto, "children", {
10119
- /**
10120
- * An array of the child elements of the camera element(`.flicking-camera`)
10121
- * @ko 카메라 엘리먼트(`.flicking-camera`) 자식 엘리먼트 배열
10122
- * @type {HTMLElement[]}
10123
- * @readonly
10124
- */
10125
- get: function () {
10126
- return toArray$3(this._el.children);
10127
- },
10128
- enumerable: false,
10129
- configurable: true
10130
- });
10131
- Object.defineProperty(__proto, "position", {
10132
- /**
10133
- * Current position of the camera
10134
- * @ko Camera의 현재 좌표
10135
- * @type {number}
10136
- * @readonly
10137
- */
10138
- get: function () {
10139
- return this._position;
10140
- },
10141
- enumerable: false,
10142
- configurable: true
10143
- });
10144
- Object.defineProperty(__proto, "alignPosition", {
10145
- /**
10146
- * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
10147
- * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
10148
- * @type {number}
10149
- * @readonly
10150
- */
10151
- get: function () {
10152
- return this._alignPos;
10153
- },
10154
- enumerable: false,
10155
- configurable: true
10156
- });
10157
- Object.defineProperty(__proto, "offset", {
10158
- /**
10159
- * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
10160
- * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
10161
- * @type {number}
10162
- * @default 0
10163
- * @readonly
10164
- */
10165
- get: function () {
10166
- return this._offset;
10167
- },
10168
- enumerable: false,
10169
- configurable: true
10170
- });
10171
- Object.defineProperty(__proto, "range", {
10172
- /**
10173
- * A range that Camera's {@link Camera#position position} can reach
10174
- * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
10175
- * @type {object}
10176
- * @property {number} min A minimum position<ko>최소 위치</ko>
10177
- * @property {number} max A maximum position<ko>최대 위치</ko>
10178
- * @readonly
10179
- */
10180
- get: function () {
10181
- return this._range;
10182
- },
10183
- enumerable: false,
10184
- configurable: true
10185
- });
10186
- Object.defineProperty(__proto, "rangeDiff", {
10187
- /**
10188
- * A difference between Camera's minimum and maximum position that can reach
10189
- * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
10190
- * @type {number}
10191
- * @readonly
10192
- */
10193
- get: function () {
10194
- return this._range.max - this._range.min;
10195
- },
10196
- enumerable: false,
10197
- configurable: true
10198
- });
10199
- Object.defineProperty(__proto, "visiblePanels", {
10200
- /**
10201
- * An array of visible panels from the current position
10202
- * @ko 현재 보이는 패널들의 배열
10203
- * @type {Panel[]}
10204
- * @readonly
10205
- */
10206
- get: function () {
10207
- return this._visiblePanels;
10208
- },
10209
- enumerable: false,
10210
- configurable: true
10211
- });
10212
- Object.defineProperty(__proto, "visibleRange", {
10213
- /**
10214
- * A range of the visible area from the current position
10215
- * @ko 현재 위치에서 보이는 범위
10216
- * @type {object}
10217
- * @property {number} min A minimum position<ko>최소 위치</ko>
10218
- * @property {number} min A maximum position<ko>최대 위치</ko>
10219
- * @readonly
10220
- */
10221
- get: function () {
10222
- return {
10223
- min: this._position - this._alignPos,
10224
- max: this._position - this._alignPos + this.size
10225
- };
10226
- },
10227
- enumerable: false,
10228
- configurable: true
10229
- });
10230
- Object.defineProperty(__proto, "anchorPoints", {
10231
- /**
10232
- * An array of {@link AnchorPoint}s that Camera can be stopped at
10233
- * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
10234
- * @type {AnchorPoint[]}
10235
- * @readonly
10211
+ __proto.checkAvailability = function () {
10212
+ var flicking = this._flicking;
10213
+ var renderer = flicking.renderer;
10214
+ var panels = renderer.panels;
10215
+
10216
+ if (panels.length <= 0) {
10217
+ return false;
10218
+ }
10219
+
10220
+ var firstPanel = panels[0];
10221
+ var lastPanel = panels[panels.length - 1];
10222
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
10223
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
10224
+ var visibleSize = flicking.camera.size;
10225
+ var panelSizeSum = lastPanelNext - firstPanelPrev;
10226
+ var canSetCircularMode = panels.every(function (panel) {
10227
+ return panelSizeSum - panel.size >= visibleSize;
10228
+ });
10229
+ return canSetCircularMode;
10230
+ };
10231
+
10232
+ __proto.getRange = function () {
10233
+ var flicking = this._flicking;
10234
+ var panels = flicking.renderer.panels;
10235
+
10236
+ if (panels.length <= 0) {
10237
+ return {
10238
+ min: 0,
10239
+ max: 0
10240
+ };
10241
+ }
10242
+
10243
+ var firstPanel = panels[0];
10244
+ var lastPanel = panels[panels.length - 1];
10245
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
10246
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
10247
+ return {
10248
+ min: firstPanelPrev,
10249
+ max: lastPanelNext
10250
+ };
10251
+ };
10252
+
10253
+ __proto.getAnchors = function () {
10254
+ var flicking = this._flicking;
10255
+ var panels = flicking.renderer.panels;
10256
+ return panels.map(function (panel, index) {
10257
+ return new AnchorPoint({
10258
+ index: index,
10259
+ position: panel.position,
10260
+ panel: panel
10261
+ });
10262
+ });
10263
+ };
10264
+
10265
+ __proto.findAnchorIncludePosition = function (position) {
10266
+ var camera = this._flicking.camera;
10267
+ var range = camera.range;
10268
+ var anchors = camera.anchorPoints;
10269
+ var rangeDiff = camera.rangeDiff;
10270
+ var anchorCount = anchors.length;
10271
+ var positionInRange = circulatePosition(position, range.min, range.max);
10272
+
10273
+ var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
10274
+
10275
+ if (anchorCount > 0 && (position === range.min || position === range.max)) {
10276
+ var possibleAnchors = [anchorInRange, new AnchorPoint({
10277
+ index: 0,
10278
+ position: anchors[0].position + rangeDiff,
10279
+ panel: anchors[0].panel
10280
+ }), new AnchorPoint({
10281
+ index: anchorCount - 1,
10282
+ position: anchors[anchorCount - 1].position - rangeDiff,
10283
+ panel: anchors[anchorCount - 1].panel
10284
+ })].filter(function (anchor) {
10285
+ return !!anchor;
10286
+ });
10287
+ anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
10288
+ if (!nearest) return anchor;
10289
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
10290
+ }, null);
10291
+ }
10292
+
10293
+ if (!anchorInRange) return null;
10294
+
10295
+ if (position < range.min) {
10296
+ var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
10297
+ return new AnchorPoint({
10298
+ index: anchorInRange.index,
10299
+ position: anchorInRange.position + rangeDiff * loopCount,
10300
+ panel: anchorInRange.panel
10301
+ });
10302
+ } else if (position > range.max) {
10303
+ var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
10304
+ return new AnchorPoint({
10305
+ index: anchorInRange.index,
10306
+ position: anchorInRange.position + rangeDiff * loopCount,
10307
+ panel: anchorInRange.panel
10308
+ });
10309
+ }
10310
+
10311
+ return anchorInRange;
10312
+ };
10313
+
10314
+ __proto.getCircularOffset = function () {
10315
+ var flicking = this._flicking;
10316
+ var camera = flicking.camera;
10317
+ if (!camera.circularEnabled) return 0;
10318
+ var toggled = flicking.panels.filter(function (panel) {
10319
+ return panel.toggled;
10320
+ });
10321
+ var toggledPrev = toggled.filter(function (panel) {
10322
+ return panel.toggleDirection === DIRECTION.PREV;
10323
+ });
10324
+ var toggledNext = toggled.filter(function (panel) {
10325
+ return panel.toggleDirection === DIRECTION.NEXT;
10326
+ });
10327
+ return this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
10328
+ };
10329
+
10330
+ __proto.clampToReachablePosition = function (position) {
10331
+ // Basically all position is reachable for circular camera
10332
+ return position;
10333
+ };
10334
+
10335
+ __proto.canReach = function (panel) {
10336
+ if (panel.removed) return false; // Always reachable on circular mode
10337
+
10338
+ return true;
10339
+ };
10340
+
10341
+ __proto.canSee = function (panel) {
10342
+ var camera = this._flicking.camera;
10343
+ var range = camera.range;
10344
+ var rangeDiff = camera.rangeDiff;
10345
+ var visibleRange = camera.visibleRange;
10346
+
10347
+ var visibleInCurrentRange = _super.prototype.canSee.call(this, panel); // Check looped visible area for circular case
10348
+
10349
+
10350
+ if (visibleRange.min < range.min) {
10351
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
10352
+ } else if (visibleRange.max > range.max) {
10353
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
10354
+ }
10355
+
10356
+ return visibleInCurrentRange;
10357
+ };
10358
+
10359
+ __proto._calcPanelAreaSum = function (panels) {
10360
+ return panels.reduce(function (sum, panel) {
10361
+ return sum + panel.sizeIncludingMargin;
10362
+ }, 0);
10363
+ };
10364
+
10365
+ return CircularCameraMode;
10366
+ }(CameraMode);
10367
+
10368
+ var BoundCameraMode =
10369
+ /*#__PURE__*/
10370
+ function (_super) {
10371
+ __extends$2(BoundCameraMode, _super);
10372
+
10373
+ function BoundCameraMode() {
10374
+ return _super !== null && _super.apply(this, arguments) || this;
10375
+ }
10376
+
10377
+ var __proto = BoundCameraMode.prototype;
10378
+
10379
+ __proto.checkAvailability = function () {
10380
+ var flicking = this._flicking;
10381
+ var renderer = flicking.renderer;
10382
+ var firstPanel = renderer.getPanel(0);
10383
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
10384
+
10385
+ if (!firstPanel || !lastPanel) {
10386
+ return false;
10387
+ }
10388
+
10389
+ var viewportSize = flicking.camera.size;
10390
+ var firstPanelPrev = firstPanel.range.min;
10391
+ var lastPanelNext = lastPanel.range.max;
10392
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
10393
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
10394
+ return isBiggerThanViewport;
10395
+ };
10396
+
10397
+ __proto.getRange = function () {
10398
+ var flicking = this._flicking;
10399
+ var renderer = flicking.renderer;
10400
+ var alignPos = flicking.camera.alignPosition;
10401
+ var firstPanel = renderer.getPanel(0);
10402
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
10403
+
10404
+ if (!firstPanel || !lastPanel) {
10405
+ return {
10406
+ min: 0,
10407
+ max: 0
10408
+ };
10409
+ }
10410
+
10411
+ var viewportSize = flicking.camera.size;
10412
+ var firstPanelPrev = firstPanel.range.min;
10413
+ var lastPanelNext = lastPanel.range.max;
10414
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
10415
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
10416
+ var firstPos = firstPanelPrev + alignPos;
10417
+ var lastPos = lastPanelNext - viewportSize + alignPos;
10418
+
10419
+ if (isBiggerThanViewport) {
10420
+ return {
10421
+ min: firstPos,
10422
+ max: lastPos
10423
+ };
10424
+ } else {
10425
+ var align = flicking.camera.align;
10426
+ var alignVal = typeof align === "object" ? align.camera : align;
10427
+ var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
10428
+ return {
10429
+ min: pos,
10430
+ max: pos
10431
+ };
10432
+ }
10433
+ };
10434
+
10435
+ __proto.getAnchors = function () {
10436
+ var flicking = this._flicking;
10437
+ var camera = flicking.camera;
10438
+ var panels = flicking.renderer.panels;
10439
+
10440
+ if (panels.length <= 0) {
10441
+ return [];
10442
+ }
10443
+
10444
+ var range = flicking.camera.range;
10445
+ var reachablePanels = panels.filter(function (panel) {
10446
+ return camera.canReach(panel);
10447
+ });
10448
+
10449
+ if (reachablePanels.length > 0) {
10450
+ var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
10451
+ var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
10452
+ var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
10453
+ var newAnchors = reachablePanels.map(function (panel, idx) {
10454
+ return new AnchorPoint({
10455
+ index: idx + indexOffset_1,
10456
+ position: panel.position,
10457
+ panel: panel
10458
+ });
10459
+ });
10460
+
10461
+ if (shouldPrependBoundAnchor) {
10462
+ newAnchors.splice(0, 0, new AnchorPoint({
10463
+ index: 0,
10464
+ position: range.min,
10465
+ panel: panels[reachablePanels[0].index - 1]
10466
+ }));
10467
+ }
10468
+
10469
+ if (shouldAppendBoundAnchor) {
10470
+ newAnchors.push(new AnchorPoint({
10471
+ index: newAnchors.length,
10472
+ position: range.max,
10473
+ panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
10474
+ }));
10475
+ }
10476
+
10477
+ return newAnchors;
10478
+ } else if (range.min !== range.max) {
10479
+ // There're more than 2 panels
10480
+ var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
10481
+
10482
+ var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
10483
+ var panelAtMax = panelAtMin.next();
10484
+ return [new AnchorPoint({
10485
+ index: 0,
10486
+ position: range.min,
10487
+ panel: panelAtMin
10488
+ }), new AnchorPoint({
10489
+ index: 1,
10490
+ position: range.max,
10491
+ panel: panelAtMax
10492
+ })];
10493
+ } else {
10494
+ return [new AnchorPoint({
10495
+ index: 0,
10496
+ position: range.min,
10497
+ panel: this._findNearestPanel(range.min, panels)
10498
+ })];
10499
+ }
10500
+ };
10501
+
10502
+ __proto.findAnchorIncludePosition = function (position) {
10503
+ var camera = this._flicking.camera;
10504
+ var range = camera.range;
10505
+ var anchors = camera.anchorPoints;
10506
+ if (anchors.length <= 0) return null;
10507
+
10508
+ if (position <= range.min) {
10509
+ return anchors[0];
10510
+ } else if (position >= range.max) {
10511
+ return anchors[anchors.length - 1];
10512
+ } else {
10513
+ return _super.prototype.findAnchorIncludePosition.call(this, position);
10514
+ }
10515
+ };
10516
+
10517
+ __proto._findNearestPanel = function (pos, panels) {
10518
+ var prevDist = Infinity;
10519
+
10520
+ for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
10521
+ var panel = panels[panelIdx];
10522
+ var dist = Math.abs(panel.position - pos);
10523
+
10524
+ if (dist > prevDist) {
10525
+ // Return previous anchor
10526
+ return panels[panelIdx - 1];
10527
+ }
10528
+
10529
+ prevDist = dist;
10530
+ } // Return last anchor
10531
+
10532
+
10533
+ return panels[panels.length - 1];
10534
+ };
10535
+
10536
+ return BoundCameraMode;
10537
+ }(CameraMode);
10538
+
10539
+ /**
10540
+ * A component that manages actual movement inside the viewport
10541
+ * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
10542
+ */
10543
+
10544
+ var Camera$1 =
10545
+ /*#__PURE__*/
10546
+ function () {
10547
+ /** */
10548
+ function Camera(flicking, _a) {
10549
+ var _this = this;
10550
+
10551
+ var _b = (_a === void 0 ? {} : _a).align,
10552
+ align = _b === void 0 ? ALIGN.CENTER : _b;
10553
+
10554
+ this._checkTranslateSupport = function () {
10555
+ var e_1, _a;
10556
+
10557
+ var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
10558
+ var supportedStyle = document.documentElement.style;
10559
+ var transformName = "";
10560
+
10561
+ try {
10562
+ for (var transforms_1 = __values$2(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
10563
+ var prefixedTransform = transforms_1_1.value;
10564
+
10565
+ if (prefixedTransform in supportedStyle) {
10566
+ transformName = prefixedTransform;
10567
+ }
10568
+ }
10569
+ } catch (e_1_1) {
10570
+ e_1 = {
10571
+ error: e_1_1
10572
+ };
10573
+ } finally {
10574
+ try {
10575
+ if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
10576
+ } finally {
10577
+ if (e_1) throw e_1.error;
10578
+ }
10579
+ }
10580
+
10581
+ if (!transformName) {
10582
+ throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
10583
+ }
10584
+
10585
+ _this._transform = transformName;
10586
+ };
10587
+
10588
+ this._flicking = flicking;
10589
+
10590
+ this._resetInternalValues(); // Options
10591
+
10592
+
10593
+ this._align = align;
10594
+ }
10595
+
10596
+ var __proto = Camera.prototype;
10597
+ Object.defineProperty(__proto, "element", {
10598
+ // Internal states getter
10599
+
10600
+ /**
10601
+ * The camera element(`.flicking-camera`)
10602
+ * @ko 카메라 엘리먼트(`.flicking-camera`)
10603
+ * @type {HTMLElement}
10604
+ * @readonly
10605
+ */
10606
+ get: function () {
10607
+ return this._el;
10608
+ },
10609
+ enumerable: false,
10610
+ configurable: true
10611
+ });
10612
+ Object.defineProperty(__proto, "children", {
10613
+ /**
10614
+ * An array of the child elements of the camera element(`.flicking-camera`)
10615
+ * @ko 카메라 엘리먼트(`.flicking-camera`)의 자식 엘리먼트 배열
10616
+ * @type {HTMLElement[]}
10617
+ * @readonly
10618
+ */
10619
+ get: function () {
10620
+ return toArray$3(this._el.children);
10621
+ },
10622
+ enumerable: false,
10623
+ configurable: true
10624
+ });
10625
+ Object.defineProperty(__proto, "position", {
10626
+ /**
10627
+ * Current position of the camera
10628
+ * @ko Camera의 현재 좌표
10629
+ * @type {number}
10630
+ * @readonly
10631
+ */
10632
+ get: function () {
10633
+ return this._position;
10634
+ },
10635
+ enumerable: false,
10636
+ configurable: true
10637
+ });
10638
+ Object.defineProperty(__proto, "alignPosition", {
10639
+ /**
10640
+ * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
10641
+ * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
10642
+ * @type {number}
10643
+ * @readonly
10644
+ */
10645
+ get: function () {
10646
+ return this._alignPos;
10647
+ },
10648
+ enumerable: false,
10649
+ configurable: true
10650
+ });
10651
+ Object.defineProperty(__proto, "offset", {
10652
+ /**
10653
+ * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
10654
+ * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
10655
+ * @type {number}
10656
+ * @default 0
10657
+ * @readonly
10658
+ */
10659
+ get: function () {
10660
+ return this._offset - this._circularOffset;
10661
+ },
10662
+ enumerable: false,
10663
+ configurable: true
10664
+ });
10665
+ Object.defineProperty(__proto, "circularEnabled", {
10666
+ /**
10667
+ * Whether the `circular` option is enabled.
10668
+ * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
10669
+ * @ko {@link Flicking#circular circular} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
10670
+ * {@link Flicking#circular circular} 옵션은 패널의 크기의 합이 충분하지 않을 경우 비활성화됩니다.
10671
+ * @type {boolean}
10672
+ * @default false
10673
+ * @readonly
10674
+ */
10675
+ get: function () {
10676
+ return this._circularEnabled;
10677
+ },
10678
+ enumerable: false,
10679
+ configurable: true
10680
+ });
10681
+ Object.defineProperty(__proto, "mode", {
10682
+ /**
10683
+ * A current camera mode
10684
+ * @type {CameraMode}
10685
+ * @readonly
10686
+ */
10687
+ get: function () {
10688
+ return this._mode;
10689
+ },
10690
+ enumerable: false,
10691
+ configurable: true
10692
+ });
10693
+ Object.defineProperty(__proto, "range", {
10694
+ /**
10695
+ * A range that Camera's {@link Camera#position position} can reach
10696
+ * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
10697
+ * @type {object}
10698
+ * @property {number} min A minimum position<ko>최소 위치</ko>
10699
+ * @property {number} max A maximum position<ko>최대 위치</ko>
10700
+ * @readonly
10701
+ */
10702
+ get: function () {
10703
+ return this._range;
10704
+ },
10705
+ enumerable: false,
10706
+ configurable: true
10707
+ });
10708
+ Object.defineProperty(__proto, "rangeDiff", {
10709
+ /**
10710
+ * A difference between Camera's minimum and maximum position that can reach
10711
+ * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
10712
+ * @type {number}
10713
+ * @readonly
10714
+ */
10715
+ get: function () {
10716
+ return this._range.max - this._range.min;
10717
+ },
10718
+ enumerable: false,
10719
+ configurable: true
10720
+ });
10721
+ Object.defineProperty(__proto, "visiblePanels", {
10722
+ /**
10723
+ * An array of visible panels from the current position
10724
+ * @ko 현재 보이는 패널들의 배열
10725
+ * @type {Panel[]}
10726
+ * @readonly
10727
+ */
10728
+ get: function () {
10729
+ return this._visiblePanels;
10730
+ },
10731
+ enumerable: false,
10732
+ configurable: true
10733
+ });
10734
+ Object.defineProperty(__proto, "visibleRange", {
10735
+ /**
10736
+ * A range of the visible area from the current position
10737
+ * @ko 현재 위치에서 보이는 범위
10738
+ * @type {object}
10739
+ * @property {number} min A minimum position<ko>최소 위치</ko>
10740
+ * @property {number} min A maximum position<ko>최대 위치</ko>
10741
+ * @readonly
10742
+ */
10743
+ get: function () {
10744
+ return {
10745
+ min: this._position - this._alignPos,
10746
+ max: this._position - this._alignPos + this.size
10747
+ };
10748
+ },
10749
+ enumerable: false,
10750
+ configurable: true
10751
+ });
10752
+ Object.defineProperty(__proto, "anchorPoints", {
10753
+ /**
10754
+ * An array of {@link AnchorPoint}s that Camera can be stopped at
10755
+ * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
10756
+ * @type {AnchorPoint[]}
10757
+ * @readonly
10236
10758
  */
10237
10759
  get: function () {
10238
10760
  return this._anchors;
@@ -10251,7 +10773,7 @@ version: 4.4.2
10251
10773
  return {
10252
10774
  range: this._range,
10253
10775
  position: this._position,
10254
- circular: false
10776
+ circular: this._circularEnabled
10255
10777
  };
10256
10778
  },
10257
10779
  enumerable: false,
@@ -10319,484 +10841,78 @@ version: 4.4.2
10319
10841
  var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
10320
10842
 
10321
10843
  if (prevPosition > panelPos) {
10322
- prevPosition -= rangeDiff;
10323
- }
10324
-
10325
- return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
10326
- } else {
10327
- var nextPanel = nearestPanel.next();
10328
- var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1]; // Looped
10329
-
10330
- if (nextPosition < panelPos) {
10331
- nextPosition += rangeDiff;
10332
- }
10333
-
10334
- return nearestPanel.index + getProgress(position, panelPos, nextPosition);
10335
- }
10336
- },
10337
- enumerable: false,
10338
- configurable: true
10339
- });
10340
- Object.defineProperty(__proto, "align", {
10341
- // Options Getter
10342
-
10343
- /**
10344
- * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
10345
- * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
10346
- * @type {ALIGN | string | number}
10347
- */
10348
- get: function () {
10349
- return this._align;
10350
- },
10351
- // Options Setter
10352
- set: function (val) {
10353
- this._align = val;
10354
- },
10355
- enumerable: false,
10356
- configurable: true
10357
- });
10358
- /**
10359
- * Initialize Camera
10360
- * @ko Camera를 초기화합니다
10361
- * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
10362
- * @chainable
10363
- * @throws {FlickingError}
10364
- * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
10365
- * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
10366
- * @return {this}
10367
- */
10368
-
10369
- __proto.init = function (flicking) {
10370
- this._flicking = flicking;
10371
- var viewportEl = flicking.viewport.element;
10372
- checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
10373
- this._el = viewportEl.firstElementChild;
10374
-
10375
- this._checkTranslateSupport();
10376
-
10377
- return this;
10378
- };
10379
- /**
10380
- * Destroy Camera and return to initial state
10381
- * @ko Camera를 초기 상태로 되돌립니다
10382
- * @return {void}
10383
- */
10384
-
10385
-
10386
- __proto.destroy = function () {
10387
- this._flicking = null;
10388
-
10389
- this._resetInternalValues();
10390
-
10391
- return this;
10392
- };
10393
- /**
10394
- * Move to the given position and apply CSS transform
10395
- * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
10396
- * @param {number} pos A new position<ko>움직일 위치</ko>
10397
- * @throws {FlickingError}
10398
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
10399
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
10400
- * @return {this}
10401
- */
10402
-
10403
-
10404
- __proto.lookAt = function (pos) {
10405
- var prevPos = this._position;
10406
- this._position = pos;
10407
-
10408
- this._refreshVisiblePanels();
10409
-
10410
- this._checkNeedPanel();
10411
-
10412
- this._checkReachEnd(prevPos, pos);
10413
-
10414
- this.applyTransform();
10415
- };
10416
- /**
10417
- * Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
10418
- * If it does not exist, return `null` instead
10419
- * @ko 주어진 {@link AnchorPoint}의 이전 {@link AnchorPoint}를 반환합니다
10420
- * 존재하지 않을 경우 `null`을 반환합니다
10421
- * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
10422
- * @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
10423
- */
10424
-
10425
-
10426
- __proto.getPrevAnchor = function (anchor) {
10427
- return this._anchors[anchor.index - 1] || null;
10428
- };
10429
- /**
10430
- * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
10431
- * If it does not exist, return `null` instead
10432
- * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
10433
- * 존재하지 않을 경우 `null`을 반환합니다
10434
- * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
10435
- * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
10436
- */
10437
-
10438
-
10439
- __proto.getNextAnchor = function (anchor) {
10440
- return this._anchors[anchor.index + 1] || null;
10441
- };
10442
- /**
10443
- * Return the camera's position progress in the panel below
10444
- * Value is from 0 to 1 when the camera's inside panel
10445
- * Value can be lower than 0 or bigger than 1 when it's in the margin area
10446
- * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
10447
- * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
10448
- * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
10449
- */
10450
-
10451
-
10452
- __proto.getProgressInPanel = function (panel) {
10453
- var panelRange = panel.range;
10454
- return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
10455
- };
10456
- /**
10457
- * Return {@link AnchorPoint} that includes given position
10458
- * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
10459
- * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
10460
- * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
10461
- * @param {number} position A position to check<ko>확인할 좌표</ko>
10462
- * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
10463
- */
10464
-
10465
-
10466
- __proto.findAnchorIncludePosition = function (position) {
10467
- var anchors = this._anchors;
10468
- var anchorsIncludingPosition = anchors.filter(function (anchor) {
10469
- return anchor.panel.includePosition(position, true);
10470
- });
10471
- return anchorsIncludingPosition.reduce(function (nearest, anchor) {
10472
- if (!nearest) return anchor;
10473
- return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
10474
- }, null);
10475
- };
10476
- /**
10477
- * Return {@link AnchorPoint} nearest to given position
10478
- * If there're no {@link AnchorPoint}s, return `null` instead
10479
- * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
10480
- * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
10481
- * @param {number} position A position to check<ko>확인할 좌표</ko>
10482
- * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
10483
- */
10484
-
10485
-
10486
- __proto.findNearestAnchor = function (position) {
10487
- var anchors = this._anchors;
10488
- if (anchors.length <= 0) return null;
10489
- var prevDist = Infinity;
10490
-
10491
- for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
10492
- var anchor = anchors[anchorIdx];
10493
- var dist = Math.abs(anchor.position - position);
10494
-
10495
- if (dist > prevDist) {
10496
- // Return previous anchor
10497
- return anchors[anchorIdx - 1];
10498
- }
10499
-
10500
- prevDist = dist;
10501
- } // Return last anchor
10502
-
10503
-
10504
- return anchors[anchors.length - 1];
10505
- };
10506
- /**
10507
- * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
10508
- * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
10509
- * @return {AnchorPoint | null}
10510
- */
10511
-
10512
-
10513
- __proto.findActiveAnchor = function () {
10514
- var flicking = getFlickingAttached(this._flicking);
10515
- var activeIndex = flicking.control.activeIndex;
10516
- return find$1(this._anchors, function (anchor) {
10517
- return anchor.panel.index === activeIndex;
10518
- });
10519
- };
10520
- /**
10521
- * Clamp the given position between camera's range
10522
- * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
10523
- * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
10524
- * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
10525
- */
10526
-
10527
-
10528
- __proto.clampToReachablePosition = function (position) {
10529
- var range = this._range;
10530
- return clamp(position, range.min, range.max);
10531
- };
10532
- /**
10533
- * Check whether the given panel is inside of the Camera's range
10534
- * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
10535
- * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
10536
- * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
10537
- */
10538
-
10539
-
10540
- __proto.canReach = function (panel) {
10541
- var range = this._range;
10542
- if (panel.removed) return false;
10543
- var panelPos = panel.position;
10544
- return panelPos >= range.min && panelPos <= range.max;
10545
- };
10546
- /**
10547
- * Check whether the given panel element is visible at the current position
10548
- * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
10549
- * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
10550
- * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
10551
- */
10552
-
10553
-
10554
- __proto.canSee = function (panel) {
10555
- var visibleRange = this.visibleRange; // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
10556
-
10557
- return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
10558
- };
10559
- /**
10560
- * Update Camera's {@link Camera#alignPosition alignPosition}
10561
- * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
10562
- * @chainable
10563
- * @return {this}
10564
- */
10565
-
10566
-
10567
- __proto.updateAlignPos = function () {
10568
- var align = this._align;
10569
- var alignVal = typeof align === "object" ? align.camera : align;
10570
- this._alignPos = parseAlign$1(alignVal, this.size);
10571
- return this;
10572
- };
10573
- /**
10574
- * Update Camera's {@link Camera#anchorPoints anchorPoints}
10575
- * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
10576
- * @throws {FlickingError}
10577
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
10578
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
10579
- * @chainable
10580
- * @return {this}
10581
- */
10844
+ prevPosition -= rangeDiff;
10845
+ }
10582
10846
 
10847
+ return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
10848
+ } else {
10849
+ var nextPanel = nearestPanel.next();
10850
+ var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1]; // Looped
10583
10851
 
10584
- __proto.updateAnchors = function () {
10585
- var flicking = getFlickingAttached(this._flicking);
10586
- var panels = flicking.renderer.panels;
10587
- this._anchors = panels.map(function (panel, index) {
10588
- return new AnchorPoint({
10589
- index: index,
10590
- position: panel.position,
10591
- panel: panel
10592
- });
10593
- });
10594
- return this;
10595
- };
10596
- /**
10597
- * Update Viewport's height to active panel's height
10598
- * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
10599
- * @throws {FlickingError}
10600
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
10601
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
10602
- * @chainable
10603
- * @return {this}
10604
- */
10852
+ if (nextPosition < panelPos) {
10853
+ nextPosition += rangeDiff;
10854
+ }
10605
10855
 
10856
+ return nearestPanel.index + getProgress(position, panelPos, nextPosition);
10857
+ }
10858
+ },
10859
+ enumerable: false,
10860
+ configurable: true
10861
+ });
10862
+ Object.defineProperty(__proto, "align", {
10863
+ // Options Getter
10606
10864
 
10607
- __proto.updateAdaptiveHeight = function () {
10608
- var flicking = getFlickingAttached(this._flicking);
10609
- var activePanel = flicking.control.activePanel;
10610
- if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
10611
- flicking.viewport.setSize({
10612
- height: activePanel.height
10613
- });
10614
- };
10865
+ /**
10866
+ * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
10867
+ * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
10868
+ * @type {ALIGN | string | number}
10869
+ */
10870
+ get: function () {
10871
+ return this._align;
10872
+ },
10873
+ // Options Setter
10874
+ set: function (val) {
10875
+ this._align = val;
10876
+ },
10877
+ enumerable: false,
10878
+ configurable: true
10879
+ });
10615
10880
  /**
10616
- * Update current offset of the camera
10617
- * @ko 현재 카메라의 오프셋을 업데이트합니다
10618
- * @chainable
10881
+ * Initialize Camera
10882
+ * @ko Camera를 초기화합니다
10883
+ * @throws {FlickingError}
10884
+ * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
10885
+ * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
10619
10886
  * @return {this}
10620
10887
  */
10621
10888
 
10889
+ __proto.init = function () {
10890
+ var viewportEl = this._flicking.viewport.element;
10891
+ checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
10892
+ this._el = viewportEl.firstElementChild;
10622
10893
 
10623
- __proto.updateOffset = function () {
10624
- var flicking = getFlickingAttached(this._flicking);
10625
- var position = this._position;
10626
- var unRenderedPanels = flicking.panels.filter(function (panel) {
10627
- return !panel.rendered;
10628
- });
10629
- this._offset = unRenderedPanels.filter(function (panel) {
10630
- return panel.position + panel.offset < position;
10631
- }).reduce(function (offset, panel) {
10632
- return offset + panel.sizeIncludingMargin;
10633
- }, 0);
10634
- this.applyTransform();
10635
- return this;
10636
- };
10637
- /**
10638
- * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
10639
- * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
10640
- * @chainable
10641
- * @return {this}
10642
- */
10894
+ this._checkTranslateSupport();
10643
10895
 
10896
+ this._updateMode();
10644
10897
 
10645
- __proto.resetNeedPanelHistory = function () {
10646
- this._needPanelTriggered = {
10647
- prev: false,
10648
- next: false
10649
- };
10650
10898
  return this;
10651
10899
  };
10652
10900
  /**
10653
- * Apply "transform" style with the current position to camera element
10654
- * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
10655
- * @chainable
10656
- * @return {this}
10901
+ * Destroy Camera and return to initial state
10902
+ * @ko Camera를 초기 상태로 되돌립니다
10903
+ * @return {void}
10657
10904
  */
10658
10905
 
10659
10906
 
10660
- __proto.applyTransform = function () {
10661
- var el = this._el;
10662
- var flicking = getFlickingAttached(this._flicking);
10663
- var actualPosition = this._position - this._alignPos - this._offset;
10664
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
10665
- return this;
10666
- };
10667
-
10668
- __proto._resetInternalValues = function () {
10669
- this._position = 0;
10670
- this._alignPos = 0;
10671
- this._offset = 0;
10672
- this._range = {
10673
- min: 0,
10674
- max: 0
10675
- };
10676
- this._visiblePanels = [];
10677
- this._anchors = [];
10678
- this._needPanelTriggered = {
10679
- prev: false,
10680
- next: false
10681
- };
10682
- };
10683
-
10684
- __proto._refreshVisiblePanels = function () {
10685
- var _this = this;
10686
-
10687
- var flicking = getFlickingAttached(this._flicking);
10688
- var panels = flicking.renderer.panels;
10689
- var newVisiblePanels = panels.filter(function (panel) {
10690
- return _this.canSee(panel);
10691
- });
10692
- var prevVisiblePanels = this._visiblePanels;
10693
- this._visiblePanels = newVisiblePanels;
10694
- var added = newVisiblePanels.filter(function (panel) {
10695
- return !includes(prevVisiblePanels, panel);
10696
- });
10697
- var removed = prevVisiblePanels.filter(function (panel) {
10698
- return !includes(newVisiblePanels, panel);
10699
- });
10700
-
10701
- if (added.length > 0 || removed.length > 0) {
10702
- void flicking.renderer.render().then(function () {
10703
- flicking.trigger(new ComponentEvent$1(EVENTS.VISIBLE_CHANGE, {
10704
- added: added,
10705
- removed: removed,
10706
- visiblePanels: newVisiblePanels
10707
- }));
10708
- });
10709
- }
10710
- };
10711
-
10712
- __proto._checkNeedPanel = function () {
10713
- var needPanelTriggered = this._needPanelTriggered;
10714
- if (needPanelTriggered.prev && needPanelTriggered.next) return;
10715
- var flicking = getFlickingAttached(this._flicking);
10716
- var panels = flicking.renderer.panels;
10717
-
10718
- if (panels.length <= 0) {
10719
- if (!needPanelTriggered.prev) {
10720
- flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
10721
- direction: DIRECTION.PREV
10722
- }));
10723
- needPanelTriggered.prev = true;
10724
- }
10725
-
10726
- if (!needPanelTriggered.next) {
10727
- flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
10728
- direction: DIRECTION.NEXT
10729
- }));
10730
- needPanelTriggered.next = true;
10731
- }
10732
-
10733
- return;
10734
- }
10735
-
10736
- var cameraPosition = this._position;
10737
- var cameraSize = this.size;
10738
- var cameraRange = this._range;
10739
- var needPanelThreshold = flicking.needPanelThreshold;
10740
- var cameraPrev = cameraPosition - this._alignPos;
10741
- var cameraNext = cameraPrev + cameraSize;
10742
- var firstPanel = panels[0];
10743
- var lastPanel = panels[panels.length - 1];
10744
-
10745
- if (!needPanelTriggered.prev) {
10746
- var firstPanelPrev = firstPanel.range.min;
10747
-
10748
- if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
10749
- flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
10750
- direction: DIRECTION.PREV
10751
- }));
10752
- needPanelTriggered.prev = true;
10753
- }
10754
- }
10755
-
10756
- if (!needPanelTriggered.next) {
10757
- var lastPanelNext = lastPanel.range.max;
10758
-
10759
- if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
10760
- flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
10761
- direction: DIRECTION.NEXT
10762
- }));
10763
- needPanelTriggered.next = true;
10764
- }
10765
- }
10766
- };
10907
+ __proto.destroy = function () {
10908
+ this._resetInternalValues();
10767
10909
 
10768
- __proto._checkReachEnd = function (prevPos, newPos) {
10769
- var flicking = getFlickingAttached(this._flicking);
10770
- var range = this._range;
10771
- var wasBetweenRange = prevPos > range.min && prevPos < range.max;
10772
- var isBetweenRange = newPos > range.min && newPos < range.max;
10773
- if (!wasBetweenRange || isBetweenRange) return;
10774
- var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
10775
- flicking.trigger(new ComponentEvent$1(EVENTS.REACH_EDGE, {
10776
- direction: direction
10777
- }));
10910
+ return this;
10778
10911
  };
10779
-
10780
- return Camera;
10781
- }();
10782
-
10783
- /**
10784
- * A {@link Camera} that can move from the position of the first panel to the position of the last panel
10785
- * @ko 첫번째 패널의 좌표로부터 마지막 패널의 좌표로까지 이동할 수 있는 종류의 {@link Camera}
10786
- */
10787
-
10788
- var LinearCamera =
10789
- /*#__PURE__*/
10790
- function (_super) {
10791
- __extends$2(LinearCamera, _super);
10792
-
10793
- function LinearCamera() {
10794
- return _super !== null && _super.apply(this, arguments) || this;
10795
- }
10796
10912
  /**
10797
- * Update {@link Camera#range range} of Camera
10798
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
10799
- * @chainable
10913
+ * Move to the given position and apply CSS transform
10914
+ * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
10915
+ * @param {number} pos A new position<ko>움직일 위치</ko>
10800
10916
  * @throws {FlickingError}
10801
10917
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
10802
10918
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -10804,170 +10920,190 @@ version: 4.4.2
10804
10920
  */
10805
10921
 
10806
10922
 
10807
- var __proto = LinearCamera.prototype;
10808
-
10809
- __proto.updateRange = function () {
10810
- var _a, _b;
10811
-
10812
- var flicking = getFlickingAttached(this._flicking);
10813
- var renderer = flicking.renderer;
10814
- var firstPanel = renderer.getPanel(0);
10815
- var lastPanel = renderer.getPanel(renderer.panelCount - 1);
10816
- this._range = {
10817
- min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
10818
- max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
10819
- };
10820
- return this;
10821
- };
10822
-
10823
- return LinearCamera;
10824
- }(Camera$1);
10923
+ __proto.lookAt = function (pos) {
10924
+ var _this = this;
10825
10925
 
10826
- /**
10827
- * A {@link Camera} that connects the last panel and the first panel, enabling continuous loop
10828
- * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera}
10829
- */
10926
+ var flicking = getFlickingAttached(this._flicking);
10927
+ var prevPos = this._position;
10928
+ this._position = pos;
10830
10929
 
10831
- var CircularCamera =
10832
- /*#__PURE__*/
10833
- function (_super) {
10834
- __extends$2(CircularCamera, _super);
10930
+ var toggled = this._togglePanels(prevPos, pos);
10835
10931
 
10836
- function CircularCamera() {
10837
- var _this = _super !== null && _super.apply(this, arguments) || this;
10932
+ this._refreshVisiblePanels();
10838
10933
 
10839
- _this._circularOffset = 0;
10840
- _this._circularEnabled = false;
10841
- return _this;
10842
- }
10934
+ this._checkNeedPanel();
10935
+
10936
+ this._checkReachEnd(prevPos, pos);
10937
+
10938
+ if (toggled) {
10939
+ void flicking.renderer.render().then(function () {
10940
+ _this.updateOffset();
10941
+ });
10942
+ } else {
10943
+ this.applyTransform();
10944
+ }
10945
+ };
10946
+ /**
10947
+ * Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
10948
+ * If it does not exist, return `null` instead
10949
+ * @ko 주어진 {@link AnchorPoint}의 이전 {@link AnchorPoint}를 반환합니다
10950
+ * 존재하지 않을 경우 `null`을 반환합니다
10951
+ * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
10952
+ * @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
10953
+ */
10843
10954
 
10844
- var __proto = CircularCamera.prototype;
10845
- Object.defineProperty(__proto, "offset", {
10846
- get: function () {
10847
- return this._offset - this._circularOffset;
10848
- },
10849
- enumerable: false,
10850
- configurable: true
10851
- });
10852
- Object.defineProperty(__proto, "controlParams", {
10853
- get: function () {
10854
- return {
10855
- range: this._range,
10856
- position: this._position,
10857
- circular: this._circularEnabled
10858
- };
10859
- },
10860
- enumerable: false,
10861
- configurable: true
10862
- });
10863
10955
 
10864
10956
  __proto.getPrevAnchor = function (anchor) {
10865
- if (!this._circularEnabled || anchor.index !== 0) return _super.prototype.getPrevAnchor.call(this, anchor);
10866
- var anchors = this._anchors;
10867
- var rangeDiff = this.rangeDiff;
10868
- var lastAnchor = anchors[anchors.length - 1];
10869
- return new AnchorPoint({
10870
- index: lastAnchor.index,
10871
- position: lastAnchor.position - rangeDiff,
10872
- panel: lastAnchor.panel
10873
- });
10957
+ if (!this._circularEnabled || anchor.index !== 0) {
10958
+ return this._anchors[anchor.index - 1] || null;
10959
+ } else {
10960
+ var anchors = this._anchors;
10961
+ var rangeDiff = this.rangeDiff;
10962
+ var lastAnchor = anchors[anchors.length - 1];
10963
+ return new AnchorPoint({
10964
+ index: lastAnchor.index,
10965
+ position: lastAnchor.position - rangeDiff,
10966
+ panel: lastAnchor.panel
10967
+ });
10968
+ }
10874
10969
  };
10970
+ /**
10971
+ * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
10972
+ * If it does not exist, return `null` instead
10973
+ * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
10974
+ * 존재하지 않을 경우 `null`을 반환합니다
10975
+ * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
10976
+ * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
10977
+ */
10978
+
10875
10979
 
10876
10980
  __proto.getNextAnchor = function (anchor) {
10877
10981
  var anchors = this._anchors;
10878
- if (!this._circularEnabled || anchor.index !== anchors.length - 1) return _super.prototype.getNextAnchor.call(this, anchor);
10879
- var rangeDiff = this.rangeDiff;
10880
- var firstAnchor = anchors[0];
10881
- return new AnchorPoint({
10882
- index: firstAnchor.index,
10883
- position: firstAnchor.position + rangeDiff,
10884
- panel: firstAnchor.panel
10885
- });
10982
+
10983
+ if (!this._circularEnabled || anchor.index !== anchors.length - 1) {
10984
+ return anchors[anchor.index + 1] || null;
10985
+ } else {
10986
+ var rangeDiff = this.rangeDiff;
10987
+ var firstAnchor = anchors[0];
10988
+ return new AnchorPoint({
10989
+ index: firstAnchor.index,
10990
+ position: firstAnchor.position + rangeDiff,
10991
+ panel: firstAnchor.panel
10992
+ });
10993
+ }
10994
+ };
10995
+ /**
10996
+ * Return the camera's position progress in the panel below
10997
+ * Value is from 0 to 1 when the camera's inside panel
10998
+ * Value can be lower than 0 or bigger than 1 when it's in the margin area
10999
+ * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
11000
+ * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
11001
+ * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
11002
+ */
11003
+
11004
+
11005
+ __proto.getProgressInPanel = function (panel) {
11006
+ var panelRange = panel.range;
11007
+ return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
10886
11008
  };
11009
+ /**
11010
+ * Return {@link AnchorPoint} that includes given position
11011
+ * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
11012
+ * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
11013
+ * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
11014
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
11015
+ * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
11016
+ */
11017
+
10887
11018
 
10888
11019
  __proto.findAnchorIncludePosition = function (position) {
10889
- if (!this._circularEnabled) return _super.prototype.findAnchorIncludePosition.call(this, position);
10890
- var range = this._range;
11020
+ return this._mode.findAnchorIncludePosition(position);
11021
+ };
11022
+ /**
11023
+ * Return {@link AnchorPoint} nearest to given position
11024
+ * If there're no {@link AnchorPoint}s, return `null` instead
11025
+ * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
11026
+ * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
11027
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
11028
+ * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
11029
+ */
11030
+
11031
+
11032
+ __proto.findNearestAnchor = function (position) {
10891
11033
  var anchors = this._anchors;
10892
- var rangeDiff = this.rangeDiff;
10893
- var anchorCount = anchors.length;
10894
- var positionInRange = circulatePosition(position, range.min, range.max);
11034
+ if (anchors.length <= 0) return null;
11035
+ var prevDist = Infinity;
10895
11036
 
10896
- var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
11037
+ for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
11038
+ var anchor = anchors[anchorIdx];
11039
+ var dist = Math.abs(anchor.position - position);
10897
11040
 
10898
- if (anchorCount > 0 && (position === range.min || position === range.max)) {
10899
- var possibleAnchors = [anchorInRange, new AnchorPoint({
10900
- index: 0,
10901
- position: anchors[0].position + rangeDiff,
10902
- panel: anchors[0].panel
10903
- }), new AnchorPoint({
10904
- index: anchorCount - 1,
10905
- position: anchors[anchorCount - 1].position - rangeDiff,
10906
- panel: anchors[anchorCount - 1].panel
10907
- })].filter(function (anchor) {
10908
- return !!anchor;
10909
- });
10910
- anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
10911
- if (!nearest) return anchor;
10912
- return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
10913
- }, null);
10914
- }
11041
+ if (dist > prevDist) {
11042
+ // Return previous anchor
11043
+ return anchors[anchorIdx - 1];
11044
+ }
10915
11045
 
10916
- if (!anchorInRange) return null;
11046
+ prevDist = dist;
11047
+ } // Return last anchor
10917
11048
 
10918
- if (position < range.min) {
10919
- var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
10920
- return new AnchorPoint({
10921
- index: anchorInRange.index,
10922
- position: anchorInRange.position + rangeDiff * loopCount,
10923
- panel: anchorInRange.panel
10924
- });
10925
- } else if (position > range.max) {
10926
- var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
10927
- return new AnchorPoint({
10928
- index: anchorInRange.index,
10929
- position: anchorInRange.position + rangeDiff * loopCount,
10930
- panel: anchorInRange.panel
10931
- });
10932
- }
10933
11049
 
10934
- return anchorInRange;
11050
+ return anchors[anchors.length - 1];
10935
11051
  };
11052
+ /**
11053
+ * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
11054
+ * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
11055
+ * @return {AnchorPoint | null}
11056
+ */
10936
11057
 
10937
- __proto.clampToReachablePosition = function (position) {
10938
- // Basically all position is reachable for circular camera
10939
- return this._circularEnabled ? position : _super.prototype.clampToReachablePosition.call(this, position);
10940
- };
10941
11058
 
10942
- __proto.canReach = function (panel) {
10943
- if (panel.removed) return false;
10944
- return this._circularEnabled // Always reachable on circular mode
10945
- ? true : _super.prototype.canReach.call(this, panel);
11059
+ __proto.findActiveAnchor = function () {
11060
+ var flicking = getFlickingAttached(this._flicking);
11061
+ var activeIndex = flicking.control.activeIndex;
11062
+ return find$1(this._anchors, function (anchor) {
11063
+ return anchor.panel.index === activeIndex;
11064
+ });
10946
11065
  };
11066
+ /**
11067
+ * Clamp the given position between camera's range
11068
+ * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
11069
+ * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
11070
+ * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
11071
+ */
10947
11072
 
10948
- __proto.canSee = function (panel) {
10949
- var range = this._range;
10950
- var rangeDiff = this.rangeDiff;
10951
- var visibleRange = this.visibleRange;
10952
11073
 
10953
- var visibleInCurrentRange = _super.prototype.canSee.call(this, panel);
11074
+ __proto.clampToReachablePosition = function (position) {
11075
+ return this._mode.clampToReachablePosition(position);
11076
+ };
11077
+ /**
11078
+ * Check whether the given panel is inside of the Camera's range
11079
+ * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
11080
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
11081
+ * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
11082
+ */
10954
11083
 
10955
- if (!this._circularEnabled) {
10956
- return visibleInCurrentRange;
10957
- } // Check looped visible area for circular case
10958
11084
 
11085
+ __proto.canReach = function (panel) {
11086
+ return this._mode.canReach(panel);
11087
+ };
11088
+ /**
11089
+ * Check whether the given panel element is visible at the current position
11090
+ * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
11091
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
11092
+ * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
11093
+ */
10959
11094
 
10960
- if (visibleRange.min < range.min) {
10961
- return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
10962
- } else if (visibleRange.max > range.max) {
10963
- return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
10964
- }
10965
11095
 
10966
- return visibleInCurrentRange;
11096
+ __proto.canSee = function (panel) {
11097
+ return this._mode.canSee(panel);
10967
11098
  };
10968
11099
  /**
10969
11100
  * Update {@link Camera#range range} of Camera
10970
11101
  * @ko Camera의 {@link Camera#range range}를 업데이트합니다
11102
+ * @method
11103
+ * @abstract
11104
+ * @memberof Camera
11105
+ * @instance
11106
+ * @name updateRange
10971
11107
  * @chainable
10972
11108
  * @throws {FlickingError}
10973
11109
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
@@ -10981,287 +11117,269 @@ version: 4.4.2
10981
11117
  var renderer = flicking.renderer;
10982
11118
  var panels = renderer.panels;
10983
11119
 
10984
- if (panels.length <= 0) {
10985
- this._resetInternalValues();
10986
-
10987
- return this;
10988
- }
11120
+ this._updateMode();
10989
11121
 
10990
- var firstPanel = panels[0];
10991
- var lastPanel = panels[panels.length - 1];
10992
- var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
10993
- var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
10994
- var visibleSize = this.size;
10995
- var panelSizeSum = lastPanelNext - firstPanelPrev;
10996
- var canSetCircularMode = panels.every(function (panel) {
10997
- return panelSizeSum - panel.size >= visibleSize;
10998
- });
10999
- this._circularEnabled = canSetCircularMode;
11122
+ this._range = this._mode.getRange();
11000
11123
 
11001
- if (canSetCircularMode) {
11002
- this._range = {
11003
- min: firstPanelPrev,
11004
- max: lastPanelNext
11005
- };
11124
+ if (this._circularEnabled) {
11006
11125
  panels.forEach(function (panel) {
11007
11126
  return panel.updateCircularToggleDirection();
11008
11127
  });
11009
- } else {
11010
- this._range = {
11011
- min: firstPanel.position,
11012
- max: lastPanel.position
11013
- };
11014
11128
  }
11015
11129
 
11016
- this.updateOffset();
11017
11130
  return this;
11018
11131
  };
11132
+ /**
11133
+ * Update Camera's {@link Camera#alignPosition alignPosition}
11134
+ * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
11135
+ * @chainable
11136
+ * @return {this}
11137
+ */
11138
+
11139
+
11140
+ __proto.updateAlignPos = function () {
11141
+ var align = this._align;
11142
+ var alignVal = typeof align === "object" ? align.camera : align;
11143
+ this._alignPos = parseAlign$1(alignVal, this.size);
11144
+ return this;
11145
+ };
11146
+ /**
11147
+ * Update Camera's {@link Camera#anchorPoints anchorPoints}
11148
+ * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
11149
+ * @throws {FlickingError}
11150
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
11151
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
11152
+ * @chainable
11153
+ * @return {this}
11154
+ */
11155
+
11156
+
11157
+ __proto.updateAnchors = function () {
11158
+ this._anchors = this._mode.getAnchors();
11159
+ return this;
11160
+ };
11161
+ /**
11162
+ * Update Viewport's height to active panel's height
11163
+ * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
11164
+ * @throws {FlickingError}
11165
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
11166
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
11167
+ * @chainable
11168
+ * @return {this}
11169
+ */
11019
11170
 
11020
- __proto.updateOffset = function () {
11021
- this._updateCircularOffset();
11022
11171
 
11023
- return _super.prototype.updateOffset.call(this);
11172
+ __proto.updateAdaptiveHeight = function () {
11173
+ var flicking = getFlickingAttached(this._flicking);
11174
+ var activePanel = flicking.control.activePanel;
11175
+ if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
11176
+ flicking.viewport.setSize({
11177
+ height: activePanel.height
11178
+ });
11024
11179
  };
11180
+ /**
11181
+ * Update current offset of the camera
11182
+ * @ko 현재 카메라의 오프셋을 업데이트합니다
11183
+ * @chainable
11184
+ * @return {this}
11185
+ */
11025
11186
 
11026
- __proto.lookAt = function (pos) {
11027
- var _this = this;
11028
11187
 
11188
+ __proto.updateOffset = function () {
11029
11189
  var flicking = getFlickingAttached(this._flicking);
11030
- var prevPos = this._position;
11031
- if (pos === prevPos) return _super.prototype.lookAt.call(this, pos);
11032
- var panels = flicking.renderer.panels;
11033
- var toggled = panels.map(function (panel) {
11034
- return panel.toggle(prevPos, pos);
11190
+ var position = this._position;
11191
+ var unRenderedPanels = flicking.panels.filter(function (panel) {
11192
+ return !panel.rendered;
11035
11193
  });
11036
- this._position = pos;
11194
+ this._offset = unRenderedPanels.filter(function (panel) {
11195
+ return panel.position + panel.offset < position;
11196
+ }).reduce(function (offset, panel) {
11197
+ return offset + panel.sizeIncludingMargin;
11198
+ }, 0);
11199
+ this._circularOffset = this._mode.getCircularOffset();
11200
+ this.applyTransform();
11201
+ return this;
11202
+ };
11203
+ /**
11204
+ * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
11205
+ * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
11206
+ * @chainable
11207
+ * @return {this}
11208
+ */
11037
11209
 
11038
- _super.prototype.lookAt.call(this, pos);
11039
11210
 
11040
- if (toggled.some(function (isToggled) {
11041
- return isToggled;
11042
- })) {
11043
- void flicking.renderer.render().then(function () {
11044
- _this.updateOffset();
11045
- });
11046
- }
11211
+ __proto.resetNeedPanelHistory = function () {
11212
+ this._needPanelTriggered = {
11213
+ prev: false,
11214
+ next: false
11215
+ };
11216
+ return this;
11047
11217
  };
11218
+ /**
11219
+ * Apply "transform" style with the current position to camera element
11220
+ * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
11221
+ * @return {this}
11222
+ */
11223
+
11048
11224
 
11049
11225
  __proto.applyTransform = function () {
11050
11226
  var el = this._el;
11051
11227
  var flicking = getFlickingAttached(this._flicking);
11228
+ var renderer = flicking.renderer;
11229
+ if (renderer.rendering) return this;
11052
11230
  var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
11053
11231
  el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
11054
11232
  return this;
11055
11233
  };
11056
11234
 
11057
11235
  __proto._resetInternalValues = function () {
11058
- _super.prototype._resetInternalValues.call(this);
11059
-
11236
+ this._position = 0;
11237
+ this._alignPos = 0;
11238
+ this._offset = 0;
11060
11239
  this._circularOffset = 0;
11061
11240
  this._circularEnabled = false;
11241
+ this._range = {
11242
+ min: 0,
11243
+ max: 0
11244
+ };
11245
+ this._visiblePanels = [];
11246
+ this._anchors = [];
11247
+ this._needPanelTriggered = {
11248
+ prev: false,
11249
+ next: false
11250
+ };
11062
11251
  };
11063
11252
 
11064
- __proto._calcPanelAreaSum = function (panels) {
11065
- return panels.reduce(function (sum, panel) {
11066
- return sum + panel.sizeIncludingMargin;
11067
- }, 0);
11068
- };
11069
-
11070
- __proto._updateCircularOffset = function () {
11071
- if (!this._circularEnabled) {
11072
- this._circularOffset = 0;
11073
- return;
11074
- }
11253
+ __proto._refreshVisiblePanels = function () {
11254
+ var _this = this;
11075
11255
 
11076
11256
  var flicking = getFlickingAttached(this._flicking);
11077
- var toggled = flicking.panels.filter(function (panel) {
11078
- return panel.toggled;
11257
+ var panels = flicking.renderer.panels;
11258
+ var newVisiblePanels = panels.filter(function (panel) {
11259
+ return _this.canSee(panel);
11079
11260
  });
11080
- var toggledPrev = toggled.filter(function (panel) {
11081
- return panel.toggleDirection === DIRECTION.PREV;
11261
+ var prevVisiblePanels = this._visiblePanels;
11262
+ this._visiblePanels = newVisiblePanels;
11263
+ var added = newVisiblePanels.filter(function (panel) {
11264
+ return !includes(prevVisiblePanels, panel);
11082
11265
  });
11083
- var toggledNext = toggled.filter(function (panel) {
11084
- return panel.toggleDirection === DIRECTION.NEXT;
11266
+ var removed = prevVisiblePanels.filter(function (panel) {
11267
+ return !includes(newVisiblePanels, panel);
11085
11268
  });
11086
- this._circularOffset = this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
11087
- };
11088
-
11089
- return CircularCamera;
11090
- }(Camera$1);
11091
-
11092
- /**
11093
- * 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
11094
- * @ko 첫번째와 마지막 패널 밖으로 넘어가지 못하도록 범위를 설정하여, 첫번째/마지막 패널 전/후의 빈 공간을 보이지 않도록 하는 종류의 {@link Camera}
11095
- */
11096
-
11097
- var BoundCamera =
11098
- /*#__PURE__*/
11099
- function (_super) {
11100
- __extends$2(BoundCamera, _super);
11101
-
11102
- function BoundCamera() {
11103
- return _super !== null && _super.apply(this, arguments) || this;
11104
- }
11105
- /**
11106
- * Update {@link Camera#range range} of Camera
11107
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
11108
- * @chainable
11109
- * @throws {FlickingError}
11110
- * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
11111
- * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
11112
- * @return {this}
11113
- */
11114
-
11115
-
11116
- var __proto = BoundCamera.prototype;
11117
-
11118
- __proto.updateRange = function () {
11119
- var flicking = getFlickingAttached(this._flicking);
11120
- var renderer = flicking.renderer;
11121
- var alignPos = this._alignPos;
11122
- var firstPanel = renderer.getPanel(0);
11123
- var lastPanel = renderer.getPanel(renderer.panelCount - 1);
11124
-
11125
- if (!firstPanel || !lastPanel) {
11126
- this._range = {
11127
- min: 0,
11128
- max: 0
11129
- };
11130
- return this;
11131
- }
11132
-
11133
- var viewportSize = this.size;
11134
- var firstPanelPrev = firstPanel.range.min;
11135
- var lastPanelNext = lastPanel.range.max;
11136
- var panelAreaSize = lastPanelNext - firstPanelPrev;
11137
- var isBiggerThanViewport = viewportSize < panelAreaSize;
11138
- var firstPos = firstPanelPrev + alignPos;
11139
- var lastPos = lastPanelNext - viewportSize + alignPos;
11140
11269
 
11141
- if (isBiggerThanViewport) {
11142
- this._range = {
11143
- min: firstPos,
11144
- max: lastPos
11145
- };
11146
- } else {
11147
- var align = this._align;
11148
- var alignVal = typeof align === "object" ? align.camera : align;
11149
- var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
11150
- this._range = {
11151
- min: pos,
11152
- max: pos
11153
- };
11270
+ if (added.length > 0 || removed.length > 0) {
11271
+ void flicking.renderer.render().then(function () {
11272
+ flicking.trigger(new ComponentEvent$1(EVENTS.VISIBLE_CHANGE, {
11273
+ added: added,
11274
+ removed: removed,
11275
+ visiblePanels: newVisiblePanels
11276
+ }));
11277
+ });
11154
11278
  }
11155
-
11156
- return this;
11157
11279
  };
11158
11280
 
11159
- __proto.updateAnchors = function () {
11160
- var _this = this;
11161
-
11281
+ __proto._checkNeedPanel = function () {
11282
+ var needPanelTriggered = this._needPanelTriggered;
11283
+ if (needPanelTriggered.prev && needPanelTriggered.next) return;
11162
11284
  var flicking = getFlickingAttached(this._flicking);
11163
11285
  var panels = flicking.renderer.panels;
11164
11286
 
11165
11287
  if (panels.length <= 0) {
11166
- this._anchors = [];
11167
- return this;
11168
- }
11169
-
11170
- var range = this._range;
11171
- var reachablePanels = panels.filter(function (panel) {
11172
- return _this.canReach(panel);
11173
- });
11174
-
11175
- if (reachablePanels.length > 0) {
11176
- var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
11177
- var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
11178
- var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
11179
- var newAnchors = reachablePanels.map(function (panel, idx) {
11180
- return new AnchorPoint({
11181
- index: idx + indexOffset_1,
11182
- position: panel.position,
11183
- panel: panel
11184
- });
11185
- });
11186
-
11187
- if (shouldPrependBoundAnchor) {
11188
- newAnchors.splice(0, 0, new AnchorPoint({
11189
- index: 0,
11190
- position: range.min,
11191
- panel: panels[reachablePanels[0].index - 1]
11288
+ if (!needPanelTriggered.prev) {
11289
+ flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
11290
+ direction: DIRECTION.PREV
11192
11291
  }));
11292
+ needPanelTriggered.prev = true;
11193
11293
  }
11194
11294
 
11195
- if (shouldAppendBoundAnchor) {
11196
- newAnchors.push(new AnchorPoint({
11197
- index: newAnchors.length,
11198
- position: range.max,
11199
- panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
11295
+ if (!needPanelTriggered.next) {
11296
+ flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
11297
+ direction: DIRECTION.NEXT
11200
11298
  }));
11299
+ needPanelTriggered.next = true;
11201
11300
  }
11202
11301
 
11203
- this._anchors = newAnchors;
11204
- } else if (range.min !== range.max) {
11205
- // There're more than 2 panels
11206
- var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
11207
-
11208
- var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
11209
- var panelAtMax = panelAtMin.next();
11210
- this._anchors = [new AnchorPoint({
11211
- index: 0,
11212
- position: range.min,
11213
- panel: panelAtMin
11214
- }), new AnchorPoint({
11215
- index: 1,
11216
- position: range.max,
11217
- panel: panelAtMax
11218
- })];
11219
- } else {
11220
- this._anchors = [new AnchorPoint({
11221
- index: 0,
11222
- position: range.min,
11223
- panel: this._findNearestPanel(range.min, panels)
11224
- })];
11302
+ return;
11225
11303
  }
11226
11304
 
11227
- return this;
11228
- };
11305
+ var cameraPosition = this._position;
11306
+ var cameraSize = this.size;
11307
+ var cameraRange = this._range;
11308
+ var needPanelThreshold = flicking.needPanelThreshold;
11309
+ var cameraPrev = cameraPosition - this._alignPos;
11310
+ var cameraNext = cameraPrev + cameraSize;
11311
+ var firstPanel = panels[0];
11312
+ var lastPanel = panels[panels.length - 1];
11229
11313
 
11230
- __proto.findAnchorIncludePosition = function (position) {
11231
- var range = this._range;
11232
- var anchors = this._anchors;
11233
- if (anchors.length <= 0) return null;
11314
+ if (!needPanelTriggered.prev) {
11315
+ var firstPanelPrev = firstPanel.range.min;
11234
11316
 
11235
- if (position <= range.min) {
11236
- return anchors[0];
11237
- } else if (position >= range.max) {
11238
- return anchors[anchors.length - 1];
11239
- } else {
11240
- return _super.prototype.findAnchorIncludePosition.call(this, position);
11317
+ if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
11318
+ flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
11319
+ direction: DIRECTION.PREV
11320
+ }));
11321
+ needPanelTriggered.prev = true;
11322
+ }
11323
+ }
11324
+
11325
+ if (!needPanelTriggered.next) {
11326
+ var lastPanelNext = lastPanel.range.max;
11327
+
11328
+ if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
11329
+ flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
11330
+ direction: DIRECTION.NEXT
11331
+ }));
11332
+ needPanelTriggered.next = true;
11333
+ }
11241
11334
  }
11242
11335
  };
11243
11336
 
11244
- __proto._findNearestPanel = function (pos, panels) {
11245
- var prevDist = Infinity;
11337
+ __proto._checkReachEnd = function (prevPos, newPos) {
11338
+ var flicking = getFlickingAttached(this._flicking);
11339
+ var range = this._range;
11340
+ var wasBetweenRange = prevPos > range.min && prevPos < range.max;
11341
+ var isBetweenRange = newPos > range.min && newPos < range.max;
11342
+ if (!wasBetweenRange || isBetweenRange) return;
11343
+ var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
11344
+ flicking.trigger(new ComponentEvent$1(EVENTS.REACH_EDGE, {
11345
+ direction: direction
11346
+ }));
11347
+ };
11246
11348
 
11247
- for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
11248
- var panel = panels[panelIdx];
11249
- var dist = Math.abs(panel.position - pos);
11349
+ __proto._updateMode = function () {
11350
+ var flicking = getFlickingAttached(this._flicking);
11250
11351
 
11251
- if (dist > prevDist) {
11252
- // Return previous anchor
11253
- return panels[panelIdx - 1];
11254
- }
11352
+ if (flicking.circular) {
11353
+ var circularMode = new CircularCameraMode(flicking);
11354
+ var canSetCircularMode = circularMode.checkAvailability();
11255
11355
 
11256
- prevDist = dist;
11257
- } // Return last anchor
11356
+ if (canSetCircularMode) {
11357
+ this._mode = circularMode;
11358
+ } else {
11359
+ var fallbackMode = flicking.circularFallback;
11360
+ this._mode = fallbackMode === CIRCULAR_FALLBACK.BOUND ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
11361
+ }
11258
11362
 
11363
+ this._circularEnabled = canSetCircularMode;
11364
+ } else {
11365
+ this._mode = flicking.bound ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
11366
+ }
11367
+ };
11259
11368
 
11260
- return panels[panels.length - 1];
11369
+ __proto._togglePanels = function (prevPos, pos) {
11370
+ if (pos === prevPos) return false;
11371
+ var flicking = getFlickingAttached(this._flicking);
11372
+ var panels = flicking.renderer.panels;
11373
+ var toggled = panels.map(function (panel) {
11374
+ return panel.toggle(prevPos, pos);
11375
+ });
11376
+ return toggled.some(function (isToggled) {
11377
+ return isToggled;
11378
+ });
11261
11379
  };
11262
11380
 
11263
- return BoundCamera;
11264
- }(Camera$1);
11381
+ return Camera;
11382
+ }();
11265
11383
 
11266
11384
  /*
11267
11385
  * Copyright (c) 2015 NAVER Corp.
@@ -11271,9 +11389,9 @@ version: 4.4.2
11271
11389
  var Camera = {
11272
11390
  __proto__: null,
11273
11391
  Camera: Camera$1,
11274
- LinearCamera: LinearCamera,
11275
- CircularCamera: CircularCamera,
11276
- BoundCamera: BoundCamera
11392
+ LinearCameraMode: LinearCameraMode,
11393
+ CircularCameraMode: CircularCameraMode,
11394
+ BoundCameraMode: BoundCameraMode
11277
11395
  };
11278
11396
 
11279
11397
  /*
@@ -12301,7 +12419,8 @@ version: 4.4.2
12301
12419
  align = _b === void 0 ? ALIGN.CENTER : _b,
12302
12420
  strategy = _a.strategy;
12303
12421
  this._flicking = null;
12304
- this._panels = []; // Bind options
12422
+ this._panels = [];
12423
+ this._rendering = false; // Bind options
12305
12424
 
12306
12425
  this._align = align;
12307
12426
  this._strategy = strategy;
@@ -12324,6 +12443,20 @@ version: 4.4.2
12324
12443
  enumerable: false,
12325
12444
  configurable: true
12326
12445
  });
12446
+ Object.defineProperty(__proto, "rendering", {
12447
+ /**
12448
+ * A boolean value indicating whether rendering is in progress
12449
+ * @ko 현재 렌더링이 시작되어 끝나기 전까지의 상태인지의 여부
12450
+ * @type {boolean}
12451
+ * @readonly
12452
+ * @internal
12453
+ */
12454
+ get: function () {
12455
+ return this._rendering;
12456
+ },
12457
+ enumerable: false,
12458
+ configurable: true
12459
+ });
12327
12460
  Object.defineProperty(__proto, "panelCount", {
12328
12461
  /**
12329
12462
  * Count of panels
@@ -12455,6 +12588,25 @@ version: 4.4.2
12455
12588
 
12456
12589
 
12457
12590
  __proto.batchInsert = function () {
12591
+ var items = [];
12592
+
12593
+ for (var _i = 0; _i < arguments.length; _i++) {
12594
+ items[_i] = arguments[_i];
12595
+ }
12596
+
12597
+ var allPanelsInserted = this.batchInsertDefer.apply(this, __spread$1(items));
12598
+ if (allPanelsInserted.length <= 0) return [];
12599
+ this.updateAfterPanelChange(allPanelsInserted, []);
12600
+ return allPanelsInserted;
12601
+ };
12602
+ /**
12603
+ * Defers update
12604
+ * camera position & others will be updated after calling updateAfterPanelChange
12605
+ * @internal
12606
+ */
12607
+
12608
+
12609
+ __proto.batchInsertDefer = function () {
12458
12610
  var _this = this;
12459
12611
 
12460
12612
  var items = [];
@@ -12465,7 +12617,6 @@ version: 4.4.2
12465
12617
 
12466
12618
  var panels = this._panels;
12467
12619
  var flicking = getFlickingAttached(this._flicking);
12468
- var control = flicking.control;
12469
12620
  var prevFirstPanel = panels[0];
12470
12621
  var align = parsePanelAlign(this._align);
12471
12622
  var allPanelsInserted = items.reduce(function (addedPanels, item) {
@@ -12480,7 +12631,7 @@ version: 4.4.2
12480
12631
  flicking: flicking
12481
12632
  });
12482
12633
  });
12483
- panels.splice.apply(panels, __spreadArray([insertingIdx, 0], __read$1(panelsInserted)));
12634
+ panels.splice.apply(panels, __spread$1([insertingIdx, 0], panelsInserted));
12484
12635
 
12485
12636
  if (item.hasDOMInElements) {
12486
12637
  // Insert the actual elements as camera element's children
@@ -12503,29 +12654,8 @@ version: 4.4.2
12503
12654
  panel.increaseIndex(panelsInserted.length);
12504
12655
  panel.updatePosition();
12505
12656
  });
12506
- return __spreadArray(__spreadArray([], __read$1(addedPanels), false), __read$1(panelsInserted));
12657
+ return __spread$1(addedPanels, panelsInserted);
12507
12658
  }, []);
12508
- if (allPanelsInserted.length <= 0) return []; // Update camera & control
12509
-
12510
- this._updateCameraAndControl();
12511
-
12512
- void this.render(); // Move to the first panel added if no panels existed
12513
- // FIXME: fix for animating case
12514
-
12515
- if (allPanelsInserted.length > 0 && !control.animating) {
12516
- void control.moveToPanel(control.activePanel || allPanelsInserted[0], {
12517
- duration: 0
12518
- }).catch(function () {
12519
- return void 0;
12520
- });
12521
- }
12522
-
12523
- flicking.camera.updateOffset();
12524
- flicking.trigger(new ComponentEvent$1(EVENTS.PANEL_CHANGE, {
12525
- added: allPanelsInserted,
12526
- removed: []
12527
- }));
12528
- this.checkPanelContentsReady(allPanelsInserted);
12529
12659
  return allPanelsInserted;
12530
12660
  };
12531
12661
  /**
@@ -12542,6 +12672,25 @@ version: 4.4.2
12542
12672
 
12543
12673
 
12544
12674
  __proto.batchRemove = function () {
12675
+ var items = [];
12676
+
12677
+ for (var _i = 0; _i < arguments.length; _i++) {
12678
+ items[_i] = arguments[_i];
12679
+ }
12680
+
12681
+ var allPanelsRemoved = this.batchRemoveDefer.apply(this, __spread$1(items));
12682
+ if (allPanelsRemoved.length <= 0) return [];
12683
+ this.updateAfterPanelChange([], allPanelsRemoved);
12684
+ return allPanelsRemoved;
12685
+ };
12686
+ /**
12687
+ * Defers update
12688
+ * camera position & others will be updated after calling updateAfterPanelChange
12689
+ * @internal
12690
+ */
12691
+
12692
+
12693
+ __proto.batchRemoveDefer = function () {
12545
12694
  var _this = this;
12546
12695
 
12547
12696
  var items = [];
@@ -12552,10 +12701,8 @@ version: 4.4.2
12552
12701
 
12553
12702
  var panels = this._panels;
12554
12703
  var flicking = getFlickingAttached(this._flicking);
12555
- var camera = flicking.camera,
12556
- control = flicking.control;
12704
+ var control = flicking.control;
12557
12705
  var activePanel = control.activePanel;
12558
- var activeIndex = control.activeIndex;
12559
12706
  var allPanelsRemoved = items.reduce(function (removed, item) {
12560
12707
  var index = item.index,
12561
12708
  deleteCount = item.deleteCount;
@@ -12582,34 +12729,62 @@ version: 4.4.2
12582
12729
  control.resetActive();
12583
12730
  }
12584
12731
 
12585
- return __spreadArray(__spreadArray([], __read$1(removed), false), __read$1(panelsRemoved));
12586
- }, []); // Update camera & control
12732
+ return __spread$1(removed, panelsRemoved);
12733
+ }, []);
12734
+ return allPanelsRemoved;
12735
+ };
12736
+ /**
12737
+ * @internal
12738
+ */
12739
+
12740
+
12741
+ __proto.updateAfterPanelChange = function (panelsAdded, panelsRemoved) {
12742
+ var _a;
12743
+
12744
+ var flicking = getFlickingAttached(this._flicking);
12745
+ var camera = flicking.camera,
12746
+ control = flicking.control;
12747
+ var panels = this._panels;
12748
+ var activePanel = control.activePanel; // Update camera & control
12587
12749
 
12588
12750
  this._updateCameraAndControl();
12589
12751
 
12590
- void this.render(); // FIXME: fix for animating case
12752
+ void this.render();
12753
+
12754
+ if (!activePanel || activePanel.removed) {
12755
+ if (panels.length <= 0) {
12756
+ // All panels removed
12757
+ camera.lookAt(0);
12758
+ } else {
12759
+ var targetIndex = (_a = activePanel === null || activePanel === void 0 ? void 0 : activePanel.index) !== null && _a !== void 0 ? _a : 0;
12591
12760
 
12592
- if (allPanelsRemoved.length > 0 && !control.animating) {
12593
- var targetPanel = includes(allPanelsRemoved, activePanel) ? panels[activeIndex] || panels[panels.length - 1] : activePanel;
12761
+ if (targetIndex > panels.length - 1) {
12762
+ targetIndex = panels.length - 1;
12763
+ }
12594
12764
 
12595
- if (targetPanel) {
12596
- void control.moveToPanel(targetPanel, {
12765
+ void control.moveToPanel(panels[targetIndex], {
12597
12766
  duration: 0
12598
12767
  }).catch(function () {
12599
12768
  return void 0;
12600
12769
  });
12601
- } else {
12602
- // All panels removed
12603
- camera.lookAt(0);
12604
12770
  }
12771
+ } else {
12772
+ void control.moveToPanel(control.activePanel, {
12773
+ duration: 0
12774
+ }).catch(function () {
12775
+ return void 0;
12776
+ });
12605
12777
  }
12606
12778
 
12607
12779
  flicking.camera.updateOffset();
12608
- flicking.trigger(new ComponentEvent$1(EVENTS.PANEL_CHANGE, {
12609
- added: [],
12610
- removed: allPanelsRemoved
12611
- }));
12612
- return allPanelsRemoved;
12780
+
12781
+ if (panelsAdded.length > 0 || panelsRemoved.length > 0) {
12782
+ flicking.trigger(new ComponentEvent$1(EVENTS.PANEL_CHANGE, {
12783
+ added: panelsAdded,
12784
+ removed: panelsRemoved
12785
+ }));
12786
+ this.checkPanelContentsReady(__spread$1(panelsAdded, panelsRemoved));
12787
+ }
12613
12788
  };
12614
12789
  /**
12615
12790
  * @internal
@@ -12654,6 +12829,7 @@ version: 4.4.2
12654
12829
  });
12655
12830
  if (!flicking.initialized) return;
12656
12831
  camera.updateRange();
12832
+ camera.updateOffset();
12657
12833
  camera.updateAnchors();
12658
12834
 
12659
12835
  if (control.animating) ; else {
@@ -12687,6 +12863,7 @@ version: 4.4.2
12687
12863
  var camera = flicking.camera,
12688
12864
  control = flicking.control;
12689
12865
  camera.updateRange();
12866
+ camera.updateOffset();
12690
12867
  camera.updateAnchors();
12691
12868
  camera.resetNeedPanelHistory();
12692
12869
  control.updateInput();
@@ -13581,7 +13758,7 @@ version: 4.4.2
13581
13758
  var notToggled = renderedPanels.filter(function (panel) {
13582
13759
  return !panel.toggled;
13583
13760
  });
13584
- return __spreadArray(__spreadArray(__spreadArray([], __read$1(toggledPrev), false), __read$1(notToggled), false), __read$1(toggledNext)).map(function (panel) {
13761
+ return __spread$1(toggledPrev, notToggled, toggledNext).map(function (panel) {
13585
13762
  return panel.index;
13586
13763
  });
13587
13764
  };
@@ -13791,7 +13968,7 @@ version: 4.4.2
13791
13968
  __proto.getRenderingIndexesByOrder = function (flicking) {
13792
13969
  var virtualManager = flicking.virtual;
13793
13970
 
13794
- var visiblePanels = __spreadArray([], __read$1(flicking.visiblePanels)).filter(function (panel) {
13971
+ var visiblePanels = __spread$1(flicking.visiblePanels).filter(function (panel) {
13795
13972
  return panel.rendered;
13796
13973
  }).sort(function (panel1, panel2) {
13797
13974
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
@@ -13812,7 +13989,7 @@ version: 4.4.2
13812
13989
  }).map(function (el) {
13813
13990
  return el.idx;
13814
13991
  });
13815
- return __spreadArray(__spreadArray([], __read$1(visibleIndexes), false), __read$1(invisibleIndexes));
13992
+ return __spread$1(visibleIndexes, invisibleIndexes);
13816
13993
  };
13817
13994
 
13818
13995
  __proto.getRenderingElementsByOrder = function (flicking) {
@@ -13935,58 +14112,64 @@ version: 4.4.2
13935
14112
  horizontal = _e === void 0 ? true : _e,
13936
14113
  _f = _b.circular,
13937
14114
  circular = _f === void 0 ? false : _f,
13938
- _g = _b.bound,
13939
- bound = _g === void 0 ? false : _g,
13940
- _h = _b.adaptive,
13941
- adaptive = _h === void 0 ? false : _h,
13942
- _j = _b.panelsPerView,
13943
- panelsPerView = _j === void 0 ? -1 : _j,
13944
- _k = _b.noPanelStyleOverride,
13945
- noPanelStyleOverride = _k === void 0 ? false : _k,
13946
- _l = _b.resizeOnContentsReady,
13947
- resizeOnContentsReady = _l === void 0 ? false : _l,
13948
- _m = _b.needPanelThreshold,
13949
- needPanelThreshold = _m === void 0 ? 0 : _m,
13950
- _o = _b.preventEventsBeforeInit,
13951
- preventEventsBeforeInit = _o === void 0 ? true : _o,
13952
- _p = _b.deceleration,
13953
- deceleration = _p === void 0 ? 0.0075 : _p,
13954
- _q = _b.duration,
13955
- duration = _q === void 0 ? 500 : _q,
13956
- _r = _b.easing,
13957
- easing = _r === void 0 ? function (x) {
14115
+ _g = _b.circularFallback,
14116
+ circularFallback = _g === void 0 ? CIRCULAR_FALLBACK.LINEAR : _g,
14117
+ _h = _b.bound,
14118
+ bound = _h === void 0 ? false : _h,
14119
+ _j = _b.adaptive,
14120
+ adaptive = _j === void 0 ? false : _j,
14121
+ _k = _b.panelsPerView,
14122
+ panelsPerView = _k === void 0 ? -1 : _k,
14123
+ _l = _b.noPanelStyleOverride,
14124
+ noPanelStyleOverride = _l === void 0 ? false : _l,
14125
+ _m = _b.resizeOnContentsReady,
14126
+ resizeOnContentsReady = _m === void 0 ? false : _m,
14127
+ _o = _b.needPanelThreshold,
14128
+ needPanelThreshold = _o === void 0 ? 0 : _o,
14129
+ _p = _b.preventEventsBeforeInit,
14130
+ preventEventsBeforeInit = _p === void 0 ? true : _p,
14131
+ _q = _b.deceleration,
14132
+ deceleration = _q === void 0 ? 0.0075 : _q,
14133
+ _r = _b.duration,
14134
+ duration = _r === void 0 ? 500 : _r,
14135
+ _s = _b.easing,
14136
+ easing = _s === void 0 ? function (x) {
13958
14137
  return 1 - Math.pow(1 - x, 3);
13959
- } : _r,
13960
- _s = _b.inputType,
13961
- inputType = _s === void 0 ? ["mouse", "touch"] : _s,
13962
- _t = _b.moveType,
13963
- moveType = _t === void 0 ? "snap" : _t,
13964
- _u = _b.threshold,
13965
- threshold = _u === void 0 ? 40 : _u,
13966
- _v = _b.interruptable,
13967
- interruptable = _v === void 0 ? true : _v,
13968
- _w = _b.bounce,
13969
- bounce = _w === void 0 ? "20%" : _w,
13970
- _x = _b.iOSEdgeSwipeThreshold,
13971
- iOSEdgeSwipeThreshold = _x === void 0 ? 30 : _x,
13972
- _y = _b.preventClickOnDrag,
13973
- preventClickOnDrag = _y === void 0 ? true : _y,
13974
- _z = _b.disableOnInit,
13975
- disableOnInit = _z === void 0 ? false : _z,
13976
- _0 = _b.renderOnlyVisible,
13977
- renderOnlyVisible = _0 === void 0 ? false : _0,
13978
- _1 = _b.virtual,
13979
- virtual = _1 === void 0 ? null : _1,
13980
- _2 = _b.autoInit,
13981
- autoInit = _2 === void 0 ? true : _2,
13982
- _3 = _b.autoResize,
13983
- autoResize = _3 === void 0 ? true : _3,
13984
- _4 = _b.useResizeObserver,
13985
- useResizeObserver = _4 === void 0 ? true : _4,
13986
- _5 = _b.externalRenderer,
13987
- externalRenderer = _5 === void 0 ? null : _5,
13988
- _6 = _b.renderExternal,
13989
- renderExternal = _6 === void 0 ? null : _6;
14138
+ } : _s,
14139
+ _t = _b.inputType,
14140
+ inputType = _t === void 0 ? ["mouse", "touch"] : _t,
14141
+ _u = _b.moveType,
14142
+ moveType = _u === void 0 ? "snap" : _u,
14143
+ _v = _b.threshold,
14144
+ threshold = _v === void 0 ? 40 : _v,
14145
+ _w = _b.interruptable,
14146
+ interruptable = _w === void 0 ? true : _w,
14147
+ _x = _b.bounce,
14148
+ bounce = _x === void 0 ? "20%" : _x,
14149
+ _y = _b.iOSEdgeSwipeThreshold,
14150
+ iOSEdgeSwipeThreshold = _y === void 0 ? 30 : _y,
14151
+ _z = _b.preventClickOnDrag,
14152
+ preventClickOnDrag = _z === void 0 ? true : _z,
14153
+ _0 = _b.disableOnInit,
14154
+ disableOnInit = _0 === void 0 ? false : _0,
14155
+ _1 = _b.renderOnlyVisible,
14156
+ renderOnlyVisible = _1 === void 0 ? false : _1,
14157
+ _2 = _b.virtual,
14158
+ virtual = _2 === void 0 ? null : _2,
14159
+ _3 = _b.autoInit,
14160
+ autoInit = _3 === void 0 ? true : _3,
14161
+ _4 = _b.autoResize,
14162
+ autoResize = _4 === void 0 ? true : _4,
14163
+ _5 = _b.useResizeObserver,
14164
+ useResizeObserver = _5 === void 0 ? true : _5,
14165
+ _6 = _b.resizeDebounce,
14166
+ resizeDebounce = _6 === void 0 ? 0 : _6,
14167
+ _7 = _b.maxResizeDebounce,
14168
+ maxResizeDebounce = _7 === void 0 ? 100 : _7,
14169
+ _8 = _b.externalRenderer,
14170
+ externalRenderer = _8 === void 0 ? null : _8,
14171
+ _9 = _b.renderExternal,
14172
+ renderExternal = _9 === void 0 ? null : _9;
13990
14173
 
13991
14174
  var _this = _super.call(this) || this; // Internal states
13992
14175
 
@@ -13998,6 +14181,7 @@ version: 4.4.2
13998
14181
  _this._defaultIndex = defaultIndex;
13999
14182
  _this._horizontal = horizontal;
14000
14183
  _this._circular = circular;
14184
+ _this._circularFallback = circularFallback;
14001
14185
  _this._bound = bound;
14002
14186
  _this._adaptive = adaptive;
14003
14187
  _this._panelsPerView = panelsPerView;
@@ -14021,6 +14205,8 @@ version: 4.4.2
14021
14205
  _this._autoInit = autoInit;
14022
14206
  _this._autoResize = autoResize;
14023
14207
  _this._useResizeObserver = useResizeObserver;
14208
+ _this._resizeDebounce = resizeDebounce;
14209
+ _this._maxResizeDebounce = maxResizeDebounce;
14024
14210
  _this._externalRenderer = externalRenderer;
14025
14211
  _this._renderExternal = renderExternal; // Create core components
14026
14212
 
@@ -14136,7 +14322,7 @@ version: 4.4.2
14136
14322
  * @readonly
14137
14323
  */
14138
14324
  get: function () {
14139
- return this._camera.controlParams.circular;
14325
+ return this._camera.circularEnabled;
14140
14326
  },
14141
14327
  enumerable: false,
14142
14328
  configurable: true
@@ -14370,6 +14556,24 @@ version: 4.4.2
14370
14556
  enumerable: false,
14371
14557
  configurable: true
14372
14558
  });
14559
+ Object.defineProperty(__proto, "circularFallback", {
14560
+ /**
14561
+ * Set panel control mode for the case when circular cannot be enabled.
14562
+ * "linear" will set the view's range from the top of the first panel to the top of the last panel.
14563
+ * "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.
14564
+ * @ko 순환 모드 사용 불가능시 사용할 패널 조작 범위 설정 방식을 변경합니다.
14565
+ * "linear" 사용시 시점이 첫번째 엘리먼트 위에서부터 마지막 엘리먼트 위까지 움직일 수 있도록 설정합니다.
14566
+ * "bound" 사용시 시점이 첫번째 엘리먼트와 마지막 엘리먼트의 끝과 끝 사이에서 움직일 수 있도록 설정합니다.
14567
+ * @see CIRCULAR_FALLBACK
14568
+ * @type {string}
14569
+ * @default "linear"
14570
+ */
14571
+ get: function () {
14572
+ return this._circularFallback;
14573
+ },
14574
+ enumerable: false,
14575
+ configurable: true
14576
+ });
14373
14577
  Object.defineProperty(__proto, "bound", {
14374
14578
  /**
14375
14579
  * 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
@@ -14851,6 +15055,38 @@ version: 4.4.2
14851
15055
  enumerable: false,
14852
15056
  configurable: true
14853
15057
  });
15058
+ Object.defineProperty(__proto, "resizeDebounce", {
15059
+ /**
15060
+ * Delays size recalculation from `autoResize` by the given time in milisecond.
15061
+ * If the size is changed again while being delayed, it cancels the previous one and delays from the beginning again.
15062
+ * This can increase performance by preventing `resize` being called too often.
15063
+ * @ko `autoResize` 설정시에 호출되는 크기 재계산을 주어진 시간(단위: ms)만큼 지연시킵니다.
15064
+ * 지연시키는 도중 크기가 다시 변경되었을 경우, 이전 것을 취소하고 주어진 시간만큼 다시 지연시킵니다.
15065
+ * 이를 통해 `resize`가 너무 많이 호출되는 것을 방지하여 성능을 향상시킬 수 있습니다.
15066
+ * @type {number}
15067
+ * @default 0
15068
+ */
15069
+ get: function () {
15070
+ return this._resizeDebounce;
15071
+ },
15072
+ enumerable: false,
15073
+ configurable: true
15074
+ });
15075
+ Object.defineProperty(__proto, "maxResizeDebounce", {
15076
+ /**
15077
+ * The maximum time for size recalculation delay when using `resizeDebounce`, in milisecond.
15078
+ * This guarantees that size recalculation is performed at least once every (n)ms.
15079
+ * @ko `resizeDebounce` 사용시에 크기 재계산이 지연되는 최대 시간을 지정합니다. (단위: ms)
15080
+ * 이를 통해, 적어도 (n)ms에 한번은 크기 재계산을 수행하는 것을 보장할 수 있습니다.
15081
+ * @type {number}
15082
+ * @default 100
15083
+ */
15084
+ get: function () {
15085
+ return this._maxResizeDebounce;
15086
+ },
15087
+ enumerable: false,
15088
+ configurable: true
15089
+ });
14854
15090
  Object.defineProperty(__proto, "externalRenderer", {
14855
15091
  /**
14856
15092
  * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
@@ -14886,85 +15122,61 @@ version: 4.4.2
14886
15122
  * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
14887
15123
  * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
14888
15124
  * @fires Flicking#ready
14889
- * @return {this}
15125
+ * @return {Promise<void>}
14890
15126
  */
14891
15127
 
14892
15128
  __proto.init = function () {
14893
- return __awaiter(this, void 0, void 0, function () {
14894
- var camera, renderer, control, virtualManager, originalTrigger, preventEventsBeforeInit;
14895
-
14896
- var _this = this;
14897
-
14898
- return __generator(this, function (_a) {
14899
- switch (_a.label) {
14900
- case 0:
14901
- if (this._initialized) return [2
14902
- /*return*/
14903
- ];
14904
- camera = this._camera;
14905
- renderer = this._renderer;
14906
- control = this._control;
14907
- virtualManager = this._virtualManager;
14908
- originalTrigger = this.trigger;
14909
- preventEventsBeforeInit = this._preventEventsBeforeInit;
14910
- camera.init(this);
14911
- virtualManager.init();
14912
- renderer.init(this);
14913
- control.init(this);
14914
-
14915
- if (preventEventsBeforeInit) {
14916
- this.trigger = function () {
14917
- return _this;
14918
- };
14919
- }
14920
-
14921
- return [4
14922
- /*yield*/
14923
- , this.resize()];
14924
-
14925
- case 1:
14926
- _a.sent(); // Look at initial panel
14927
-
15129
+ var _this = this;
14928
15130
 
14929
- return [4
14930
- /*yield*/
14931
- , this._moveToInitialPanel()];
15131
+ if (this._initialized) return Promise.resolve();
15132
+ var camera = this._camera;
15133
+ var renderer = this._renderer;
15134
+ var control = this._control;
15135
+ var virtualManager = this._virtualManager;
15136
+ var originalTrigger = this.trigger;
15137
+ var preventEventsBeforeInit = this._preventEventsBeforeInit;
15138
+ camera.init();
15139
+ virtualManager.init();
15140
+ renderer.init(this);
15141
+ control.init(this);
15142
+
15143
+ if (preventEventsBeforeInit) {
15144
+ this.trigger = function () {
15145
+ return _this;
15146
+ };
15147
+ }
14932
15148
 
14933
- case 2:
14934
- // Look at initial panel
14935
- _a.sent();
15149
+ this._initialResize(); // Look at initial panel
14936
15150
 
14937
- if (this._autoResize) {
14938
- this._autoResizer.enable();
14939
- }
14940
15151
 
14941
- if (this._preventClickOnDrag) {
14942
- control.controller.addPreventClickHandler();
14943
- }
15152
+ this._moveToInitialPanel();
14944
15153
 
14945
- if (this._disableOnInit) {
14946
- this.disableInput();
14947
- }
15154
+ if (this._autoResize) {
15155
+ this._autoResizer.enable();
15156
+ }
14948
15157
 
14949
- renderer.checkPanelContentsReady(renderer.panels);
15158
+ if (this._preventClickOnDrag) {
15159
+ control.controller.addPreventClickHandler();
15160
+ }
14950
15161
 
14951
- this._plugins.forEach(function (plugin) {
14952
- return plugin.init(_this);
14953
- }); // Done initializing & emit ready event
15162
+ if (this._disableOnInit) {
15163
+ this.disableInput();
15164
+ }
14954
15165
 
15166
+ renderer.checkPanelContentsReady(renderer.panels);
15167
+ return renderer.render().then(function () {
15168
+ // Done initializing & emit ready event
15169
+ _this._plugins.forEach(function (plugin) {
15170
+ return plugin.init(_this);
15171
+ });
14955
15172
 
14956
- this._initialized = true;
15173
+ _this._initialized = true;
14957
15174
 
14958
- if (preventEventsBeforeInit) {
14959
- this.trigger = originalTrigger;
14960
- }
15175
+ if (preventEventsBeforeInit) {
15176
+ _this.trigger = originalTrigger;
15177
+ }
14961
15178
 
14962
- this.trigger(new ComponentEvent$1(EVENTS.READY));
14963
- return [2
14964
- /*return*/
14965
- ];
14966
- }
14967
- });
15179
+ _this.trigger(new ComponentEvent$1(EVENTS.READY));
14968
15180
  });
14969
15181
  };
14970
15182
  /**
@@ -15330,7 +15542,7 @@ version: 4.4.2
15330
15542
  });
15331
15543
  }
15332
15544
 
15333
- (_a = this._plugins).push.apply(_a, __spreadArray([], __read$1(plugins)));
15545
+ (_a = this._plugins).push.apply(_a, __spread$1(plugins));
15334
15546
 
15335
15547
  return this;
15336
15548
  };
@@ -15577,22 +15789,14 @@ version: 4.4.2
15577
15789
  };
15578
15790
 
15579
15791
  __proto._createCamera = function () {
15580
- var cameraOption = {
15581
- align: this._align
15582
- };
15583
-
15584
- if (this._circular) {
15585
- if (this._bound) {
15586
- // eslint-disable-next-line no-console
15587
- console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
15588
- }
15589
-
15590
- return new CircularCamera(cameraOption);
15591
- } else if (this._bound) {
15592
- return new BoundCamera(cameraOption);
15593
- } else {
15594
- return new LinearCamera(cameraOption);
15792
+ if (this._circular && this._bound) {
15793
+ // eslint-disable-next-line no-console
15794
+ console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
15595
15795
  }
15796
+
15797
+ return new Camera$1(this, {
15798
+ align: this._align
15799
+ });
15596
15800
  };
15597
15801
 
15598
15802
  __proto._createRenderer = function () {
@@ -15626,23 +15830,59 @@ version: 4.4.2
15626
15830
  };
15627
15831
 
15628
15832
  __proto._moveToInitialPanel = function () {
15629
- return __awaiter(this, void 0, void 0, function () {
15630
- var renderer, control, initialPanel;
15631
- return __generator(this, function (_a) {
15632
- renderer = this._renderer;
15633
- control = this._control;
15634
- initialPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
15635
- if (!initialPanel) return [2
15636
- /*return*/
15637
- ];
15638
- control.setActive(initialPanel, null, false);
15639
- return [2
15640
- /*return*/
15641
- , control.moveToPanel(initialPanel, {
15642
- duration: 0
15643
- })];
15644
- });
15645
- });
15833
+ var renderer = this._renderer;
15834
+ var control = this._control;
15835
+ var camera = this._camera;
15836
+ var initialPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
15837
+ if (!initialPanel) return;
15838
+ var nearestAnchor = camera.findNearestAnchor(initialPanel.position);
15839
+ control.setActive(initialPanel, null, false);
15840
+
15841
+ if (!nearestAnchor) {
15842
+ throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(initialPanel.position), CODE.POSITION_NOT_REACHABLE);
15843
+ }
15844
+
15845
+ var position = initialPanel.position;
15846
+
15847
+ if (!camera.canReach(initialPanel)) {
15848
+ position = nearestAnchor.position;
15849
+ }
15850
+
15851
+ camera.lookAt(position);
15852
+ control.updateInput();
15853
+ camera.updateOffset();
15854
+ };
15855
+
15856
+ __proto._initialResize = function () {
15857
+ var viewport = this._viewport;
15858
+ var renderer = this._renderer;
15859
+ var camera = this._camera;
15860
+ var control = this._control;
15861
+ this.trigger(new ComponentEvent$1(EVENTS.BEFORE_RESIZE, {
15862
+ width: 0,
15863
+ height: 0,
15864
+ element: viewport.element
15865
+ }));
15866
+ viewport.resize();
15867
+ renderer.updatePanelSize();
15868
+ camera.updateAlignPos();
15869
+ camera.updateRange();
15870
+ camera.updateAnchors();
15871
+ camera.updateOffset();
15872
+ control.updateInput();
15873
+ var newWidth = viewport.width;
15874
+ var newHeight = viewport.height;
15875
+ var sizeChanged = newWidth !== 0 || newHeight !== 0;
15876
+ this.trigger(new ComponentEvent$1(EVENTS.AFTER_RESIZE, {
15877
+ width: viewport.width,
15878
+ height: viewport.height,
15879
+ prev: {
15880
+ width: 0,
15881
+ height: 0
15882
+ },
15883
+ sizeChanged: sizeChanged,
15884
+ element: viewport.element
15885
+ }));
15646
15886
  };
15647
15887
  /**
15648
15888
  * Version info string
@@ -15656,7 +15896,7 @@ version: 4.4.2
15656
15896
  */
15657
15897
 
15658
15898
 
15659
- Flicking.VERSION = "4.4.2";
15899
+ Flicking.VERSION = "4.6.0";
15660
15900
  return Flicking;
15661
15901
  }(Component$1);
15662
15902
 
@@ -15696,7 +15936,7 @@ version: 4.4.2
15696
15936
  var withFlickingMethods = function (prototype, flickingName) {
15697
15937
  [Component$1.prototype, Flicking.prototype].forEach(function (proto) {
15698
15938
  Object.getOwnPropertyNames(proto).filter(function (name) {
15699
- return !prototype[name] && !name.startsWith("_") && name !== "constructor";
15939
+ return !prototype[name] && name.indexOf("_") !== 0 && name !== "constructor";
15700
15940
  }).forEach(function (name) {
15701
15941
  var descriptor = Object.getOwnPropertyDescriptor(proto, name);
15702
15942
 
@@ -15712,7 +15952,7 @@ version: 4.4.2
15712
15952
  args[_i] = arguments[_i];
15713
15953
  }
15714
15954
 
15715
- return (_a = descriptor.value).call.apply(_a, __spreadArray([this[flickingName]], __read$1(args)));
15955
+ return (_a = descriptor.value).call.apply(_a, __spread$1([this[flickingName]], args));
15716
15956
  }
15717
15957
  });
15718
15958
  } else {
@@ -15722,7 +15962,8 @@ version: 4.4.2
15722
15962
  getterDescriptor.get = function () {
15723
15963
  var _a;
15724
15964
 
15725
- return (_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(this[flickingName]);
15965
+ var flicking = this[flickingName];
15966
+ return flicking && ((_a = descriptor.get) === null || _a === void 0 ? void 0 : _a.call(flicking));
15726
15967
  };
15727
15968
  }
15728
15969
 
@@ -15736,7 +15977,7 @@ version: 4.4.2
15736
15977
  args[_i] = arguments[_i];
15737
15978
  }
15738
15979
 
15739
- return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([this[flickingName]], __read$1(args)));
15980
+ return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spread$1([this[flickingName]], args));
15740
15981
  };
15741
15982
  }
15742
15983
 
@@ -15750,7 +15991,10 @@ version: 4.4.2
15750
15991
  var renderer = flicking.renderer;
15751
15992
  var panels = renderer.panels;
15752
15993
 
15753
- var prevList = __spreadArray([], __read$1(diffResult.prevList));
15994
+ var prevList = __spread$1(diffResult.prevList);
15995
+
15996
+ var added = [];
15997
+ var removed = [];
15754
15998
 
15755
15999
  if (diffResult.removed.length > 0) {
15756
16000
  var endIdx_1 = -1;
@@ -15761,7 +16005,7 @@ version: 4.4.2
15761
16005
  }
15762
16006
 
15763
16007
  if (prevIdx_1 >= 0 && removedIdx !== prevIdx_1 - 1) {
15764
- batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
16008
+ removed.push.apply(removed, __spread$1(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
15765
16009
  endIdx_1 = removedIdx;
15766
16010
  prevIdx_1 = removedIdx;
15767
16011
  } else {
@@ -15770,39 +16014,34 @@ version: 4.4.2
15770
16014
 
15771
16015
  prevList.splice(removedIdx, 1);
15772
16016
  });
15773
- batchRemove(renderer, prevIdx_1, endIdx_1 + 1);
16017
+ removed.push.apply(removed, __spread$1(batchRemove(renderer, prevIdx_1, endIdx_1 + 1)));
15774
16018
  }
15775
16019
 
15776
16020
  diffResult.ordered.forEach(function (_a) {
15777
16021
  var _b = __read$1(_a, 2),
15778
- prevIdx = _b[0],
15779
- newIdx = _b[1];
15780
-
15781
- var prevPanel = panels[prevIdx];
15782
- var indexDiff = newIdx - prevIdx;
15783
-
15784
- if (indexDiff > 0) {
15785
- var middlePanels = panels.slice(prevIdx + 1, newIdx + 1);
15786
- prevPanel.increaseIndex(indexDiff);
15787
- middlePanels.forEach(function (panel) {
15788
- return panel.decreaseIndex(1);
15789
- });
15790
- } else {
15791
- var middlePanels = panels.slice(newIdx, prevIdx);
15792
- prevPanel.decreaseIndex(-indexDiff);
15793
- middlePanels.forEach(function (panel) {
15794
- return panel.increaseIndex(1);
15795
- });
15796
- } // Update position
16022
+ from = _b[0],
16023
+ to = _b[1];
15797
16024
 
15798
-
15799
- prevPanel.resize();
16025
+ var prevPanel = panels.splice(from, 1)[0];
16026
+ panels.splice(to, 0, prevPanel);
15800
16027
  });
15801
16028
 
15802
16029
  if (diffResult.ordered.length > 0) {
16030
+ panels.forEach(function (panel, idx) {
16031
+ var indexDiff = idx - panel.index;
16032
+
16033
+ if (indexDiff > 0) {
16034
+ panel.increaseIndex(indexDiff);
16035
+ } else {
16036
+ panel.decreaseIndex(-indexDiff);
16037
+ }
16038
+ });
15803
16039
  panels.sort(function (panel1, panel2) {
15804
16040
  return panel1.index - panel2.index;
15805
16041
  });
16042
+ panels.forEach(function (panel) {
16043
+ panel.updatePosition();
16044
+ });
15806
16045
  }
15807
16046
 
15808
16047
  if (diffResult.added.length > 0) {
@@ -15815,7 +16054,7 @@ version: 4.4.2
15815
16054
  }
15816
16055
 
15817
16056
  if (prevIdx_2 >= 0 && addedIdx !== prevIdx_2 + 1) {
15818
- batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1);
16057
+ added.push.apply(added, __spread$1(batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1)));
15819
16058
  startIdx_1 = -1;
15820
16059
  prevIdx_2 = -1;
15821
16060
  } else {
@@ -15824,24 +16063,26 @@ version: 4.4.2
15824
16063
  });
15825
16064
 
15826
16065
  if (startIdx_1 >= 0) {
15827
- batchInsert(renderer, diffResult, addedElements_1, startIdx_1);
16066
+ added.push.apply(added, __spread$1(batchInsert(renderer, diffResult, addedElements_1, startIdx_1)));
15828
16067
  }
15829
16068
  }
16069
+
16070
+ renderer.updateAfterPanelChange(added, removed);
15830
16071
  });
15831
16072
 
15832
16073
  var batchInsert = function (renderer, diffResult, addedElements, startIdx, endIdx) {
15833
- renderer.batchInsert.apply(renderer, __spreadArray([], __read$1(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
16074
+ return renderer.batchInsertDefer.apply(renderer, __spread$1(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
15834
16075
  return {
15835
16076
  index: index,
15836
16077
  elements: [addedElements[elIdx]],
15837
16078
  hasDOMInElements: false
15838
16079
  };
15839
- }))));
16080
+ })));
15840
16081
  };
15841
16082
 
15842
16083
  var batchRemove = function (renderer, startIdx, endIdx) {
15843
16084
  var removed = renderer.panels.slice(startIdx, endIdx);
15844
- renderer.batchRemove({
16085
+ return renderer.batchRemoveDefer({
15845
16086
  index: startIdx,
15846
16087
  deleteCount: removed.length,
15847
16088
  hasDOMInElements: false
@@ -15861,16 +16102,16 @@ version: 4.4.2
15861
16102
  map[prev] = current;
15862
16103
  return map;
15863
16104
  }, {});
15864
- return __spreadArray(__spreadArray([], __read$1(flicking.panels.filter(function (panel) {
16105
+ return __spread$1(flicking.panels.filter(function (panel) {
15865
16106
  return !removedPanels[panel.index];
15866
16107
  }) // Sort panels by position
15867
16108
  .sort(function (panel1, panel2) {
15868
16109
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
15869
16110
  }).map(function (panel) {
15870
16111
  return diffResult.list[maintainedMap[panel.index]];
15871
- })), false), __read$1(diffResult.added.map(function (idx) {
16112
+ }), diffResult.added.map(function (idx) {
15872
16113
  return diffResult.list[idx];
15873
- })));
16114
+ }));
15874
16115
  });
15875
16116
 
15876
16117
  var getDefaultCameraTransform = (function (align, horizontal, firstPanelSize) {