@egjs/flicking 4.4.2 → 4.5.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 (35) hide show
  1. package/declaration/Flicking.d.ts +8 -2
  2. package/declaration/camera/Camera.d.ts +26 -24
  3. package/declaration/camera/index.d.ts +2 -4
  4. package/declaration/camera/mode/BoundCameraMode.d.ts +13 -0
  5. package/declaration/camera/mode/CameraMode.d.ts +19 -0
  6. package/declaration/camera/mode/CircularCameraMode.d.ts +18 -0
  7. package/declaration/camera/mode/LinearCameraMode.d.ts +9 -0
  8. package/declaration/camera/mode/index.d.ts +6 -0
  9. package/declaration/const/external.d.ts +4 -0
  10. package/declaration/type/external.d.ts +1 -3
  11. package/dist/flicking.esm.js +1181 -1090
  12. package/dist/flicking.esm.js.map +1 -1
  13. package/dist/flicking.js +1184 -1092
  14. package/dist/flicking.js.map +1 -1
  15. package/dist/flicking.min.js +2 -2
  16. package/dist/flicking.min.js.map +1 -1
  17. package/dist/flicking.pkgd.js +1183 -1091
  18. package/dist/flicking.pkgd.js.map +1 -1
  19. package/dist/flicking.pkgd.min.js +2 -2
  20. package/dist/flicking.pkgd.min.js.map +1 -1
  21. package/package.json +4 -3
  22. package/src/Flicking.ts +26 -15
  23. package/src/camera/Camera.ts +155 -70
  24. package/src/camera/index.ts +3 -7
  25. package/src/camera/{BoundCamera.ts → mode/BoundCameraMode.ts} +46 -43
  26. package/src/camera/mode/CameraMode.ts +77 -0
  27. package/src/camera/mode/CircularCameraMode.ts +171 -0
  28. package/src/camera/mode/LinearCameraMode.ts +23 -0
  29. package/src/camera/mode/index.ts +14 -0
  30. package/src/const/external.ts +12 -0
  31. package/declaration/camera/BoundCamera.d.ts +0 -9
  32. package/declaration/camera/CircularCamera.d.ts +0 -37
  33. package/declaration/camera/LinearCamera.d.ts +0 -5
  34. package/src/camera/CircularCamera.ts +0 -268
  35. 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.5.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);
@@ -9443,9 +9458,8 @@ version: 4.4.2
9443
9458
 
9444
9459
 
9445
9460
  function SnapControl(_a) {
9446
- var _b = _a === void 0 ? {} : _a,
9447
- _c = _b.count,
9448
- count = _c === void 0 ? Infinity : _c;
9461
+ var _b = (_a === void 0 ? {} : _a).count,
9462
+ count = _b === void 0 ? Infinity : _b;
9449
9463
 
9450
9464
  var _this = _super.call(this) || this;
9451
9465
 
@@ -9651,9 +9665,8 @@ version: 4.4.2
9651
9665
 
9652
9666
 
9653
9667
  function FreeControl(_a) {
9654
- var _b = _a === void 0 ? {} : _a,
9655
- _c = _b.stopAtEdge,
9656
- stopAtEdge = _c === void 0 ? true : _c;
9668
+ var _b = (_a === void 0 ? {} : _a).stopAtEdge,
9669
+ stopAtEdge = _b === void 0 ? true : _b;
9657
9670
 
9658
9671
  var _this = _super.call(this) || this;
9659
9672
 
@@ -9787,9 +9800,8 @@ version: 4.4.2
9787
9800
 
9788
9801
 
9789
9802
  function StrictControl(_a) {
9790
- var _b = _a === void 0 ? {} : _a,
9791
- _c = _b.count,
9792
- count = _c === void 0 ? 1 : _c;
9803
+ var _b = (_a === void 0 ? {} : _a).count,
9804
+ count = _b === void 0 ? 1 : _b;
9793
9805
 
9794
9806
  var _this = _super.call(this) || this;
9795
9807
 
@@ -10042,761 +10054,826 @@ version: 4.4.2
10042
10054
  };
10043
10055
 
10044
10056
  /**
10045
- * A component that manages actual movement inside the viewport
10046
- * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
10057
+ * A mode of camera
10047
10058
  */
10048
10059
 
10049
- var Camera$1 =
10060
+ var CameraMode =
10050
10061
  /*#__PURE__*/
10051
10062
  function () {
10052
10063
  /** */
10053
- function Camera(_a) {
10054
- var _this = this;
10064
+ function CameraMode(flicking) {
10065
+ this._flicking = flicking;
10066
+ }
10055
10067
 
10056
- var _b = _a === void 0 ? {} : _a,
10057
- _c = _b.align,
10058
- align = _c === void 0 ? ALIGN.CENTER : _c;
10068
+ var __proto = CameraMode.prototype;
10059
10069
 
10060
- this._checkTranslateSupport = function () {
10061
- var e_1, _a;
10070
+ __proto.getAnchors = function () {
10071
+ var panels = this._flicking.renderer.panels;
10072
+ return panels.map(function (panel, index) {
10073
+ return new AnchorPoint({
10074
+ index: index,
10075
+ position: panel.position,
10076
+ panel: panel
10077
+ });
10078
+ });
10079
+ };
10062
10080
 
10063
- var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
10064
- var supportedStyle = document.documentElement.style;
10065
- var transformName = "";
10081
+ __proto.findAnchorIncludePosition = function (position) {
10082
+ var anchors = this._flicking.camera.anchorPoints;
10083
+ var anchorsIncludingPosition = anchors.filter(function (anchor) {
10084
+ return anchor.panel.includePosition(position, true);
10085
+ });
10086
+ return anchorsIncludingPosition.reduce(function (nearest, anchor) {
10087
+ if (!nearest) return anchor;
10088
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
10089
+ }, null);
10090
+ };
10066
10091
 
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;
10092
+ __proto.clampToReachablePosition = function (position) {
10093
+ var camera = this._flicking.camera;
10094
+ var range = camera.range;
10095
+ return clamp(position, range.min, range.max);
10096
+ };
10070
10097
 
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
- }
10098
+ __proto.getCircularOffset = function () {
10099
+ return 0;
10100
+ };
10086
10101
 
10087
- if (!transformName) {
10088
- throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
10089
- }
10102
+ __proto.canReach = function (panel) {
10103
+ var camera = this._flicking.camera;
10104
+ var range = camera.range;
10105
+ if (panel.removed) return false;
10106
+ var panelPos = panel.position;
10107
+ return panelPos >= range.min && panelPos <= range.max;
10108
+ };
10090
10109
 
10091
- _this._transform = transformName;
10110
+ __proto.canSee = function (panel) {
10111
+ var camera = this._flicking.camera;
10112
+ var visibleRange = camera.visibleRange; // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
10113
+
10114
+ return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
10115
+ };
10116
+
10117
+ return CameraMode;
10118
+ }();
10119
+
10120
+ var LinearCameraMode =
10121
+ /*#__PURE__*/
10122
+ function (_super) {
10123
+ __extends$2(LinearCameraMode, _super);
10124
+
10125
+ function LinearCameraMode() {
10126
+ return _super !== null && _super.apply(this, arguments) || this;
10127
+ }
10128
+
10129
+ var __proto = LinearCameraMode.prototype;
10130
+
10131
+ __proto.checkAvailability = function () {
10132
+ // It's always available
10133
+ return true;
10134
+ };
10135
+
10136
+ __proto.getRange = function () {
10137
+ var _a, _b;
10138
+
10139
+ var renderer = this._flicking.renderer;
10140
+ var firstPanel = renderer.getPanel(0);
10141
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
10142
+ return {
10143
+ min: (_a = firstPanel === null || firstPanel === void 0 ? void 0 : firstPanel.position) !== null && _a !== void 0 ? _a : 0,
10144
+ max: (_b = lastPanel === null || lastPanel === void 0 ? void 0 : lastPanel.position) !== null && _b !== void 0 ? _b : 0
10092
10145
  };
10146
+ };
10093
10147
 
10094
- this._flicking = null;
10148
+ return LinearCameraMode;
10149
+ }(CameraMode);
10095
10150
 
10096
- this._resetInternalValues(); // Options
10151
+ /**
10152
+ * A {@link Camera} mode that connects the last panel and the first panel, enabling continuous loop
10153
+ * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera} 모드
10154
+ */
10097
10155
 
10156
+ var CircularCameraMode =
10157
+ /*#__PURE__*/
10158
+ function (_super) {
10159
+ __extends$2(CircularCameraMode, _super);
10098
10160
 
10099
- this._align = align;
10161
+ function CircularCameraMode() {
10162
+ return _super !== null && _super.apply(this, arguments) || this;
10100
10163
  }
10101
10164
 
10102
- var __proto = Camera.prototype;
10103
- Object.defineProperty(__proto, "element", {
10104
- // Internal states getter
10165
+ var __proto = CircularCameraMode.prototype;
10105
10166
 
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 () {
10167
+ __proto.checkAvailability = function () {
10168
+ var flicking = this._flicking;
10169
+ var renderer = flicking.renderer;
10170
+ var panels = renderer.panels;
10171
+
10172
+ if (panels.length <= 0) {
10173
+ return false;
10174
+ }
10175
+
10176
+ var firstPanel = panels[0];
10177
+ var lastPanel = panels[panels.length - 1];
10178
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
10179
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
10180
+ var visibleSize = flicking.camera.size;
10181
+ var panelSizeSum = lastPanelNext - firstPanelPrev;
10182
+ var canSetCircularMode = panels.every(function (panel) {
10183
+ return panelSizeSum - panel.size >= visibleSize;
10184
+ });
10185
+ return canSetCircularMode;
10186
+ };
10187
+
10188
+ __proto.getRange = function () {
10189
+ var flicking = this._flicking;
10190
+ var panels = flicking.renderer.panels;
10191
+
10192
+ if (panels.length <= 0) {
10222
10193
  return {
10223
- min: this._position - this._alignPos,
10224
- max: this._position - this._alignPos + this.size
10194
+ min: 0,
10195
+ max: 0
10225
10196
  };
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
10236
- */
10237
- get: function () {
10238
- return this._anchors;
10239
- },
10240
- enumerable: false,
10241
- configurable: true
10242
- });
10243
- Object.defineProperty(__proto, "controlParams", {
10244
- /**
10245
- * A current parameters of the Camera for updating {@link AxesController}
10246
- * @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
10247
- * @type {ControlParams}
10248
- * @readonly
10249
- */
10250
- get: function () {
10251
- return {
10252
- range: this._range,
10253
- position: this._position,
10254
- circular: false
10255
- };
10256
- },
10257
- enumerable: false,
10258
- configurable: true
10259
- });
10260
- Object.defineProperty(__proto, "atEdge", {
10261
- /**
10262
- * A Boolean value indicating whether Camera's over the minimum or maximum position reachable
10263
- * @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
10264
- * @type {boolean}
10265
- * @readonly
10266
- */
10267
- get: function () {
10268
- return this._position <= this._range.min || this._position >= this._range.max;
10269
- },
10270
- enumerable: false,
10271
- configurable: true
10272
- });
10273
- Object.defineProperty(__proto, "size", {
10274
- /**
10275
- * Return the size of the viewport
10276
- * @ko 뷰포트 크기를 반환합니다
10277
- * @type {number}
10278
- * @readonly
10279
- */
10280
- get: function () {
10281
- var flicking = this._flicking;
10282
- return flicking ? flicking.horizontal ? flicking.viewport.width : flicking.viewport.height : 0;
10283
- },
10284
- enumerable: false,
10285
- configurable: true
10286
- });
10287
- Object.defineProperty(__proto, "progress", {
10288
- /**
10289
- * Return the camera's position progress from the first panel to last panel
10290
- * Range is from 0 to last panel's index
10291
- * @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
10292
- * 범위는 0부터 마지막 패널의 인덱스까지입니다
10293
- * @type {number}
10294
- * @readonly
10295
- */
10296
- get: function () {
10297
- var flicking = this._flicking;
10298
- var position = this._position + this._offset;
10299
- var nearestAnchor = this.findNearestAnchor(this._position);
10197
+ }
10300
10198
 
10301
- if (!flicking || !nearestAnchor) {
10302
- return NaN;
10303
- }
10199
+ var firstPanel = panels[0];
10200
+ var lastPanel = panels[panels.length - 1];
10201
+ var firstPanelPrev = firstPanel.range.min - firstPanel.margin.prev;
10202
+ var lastPanelNext = lastPanel.range.max + lastPanel.margin.next;
10203
+ return {
10204
+ min: firstPanelPrev,
10205
+ max: lastPanelNext
10206
+ };
10207
+ };
10304
10208
 
10305
- var nearestPanel = nearestAnchor.panel;
10306
- var panelPos = nearestPanel.position + nearestPanel.offset;
10307
- var bounceSize = flicking.control.controller.bounce;
10308
- var _a = this.range,
10309
- prevRange = _a.min,
10310
- nextRange = _a.max;
10311
- var rangeDiff = this.rangeDiff;
10209
+ __proto.getAnchors = function () {
10210
+ var flicking = this._flicking;
10211
+ var panels = flicking.renderer.panels;
10212
+ return panels.map(function (panel, index) {
10213
+ return new AnchorPoint({
10214
+ index: index,
10215
+ position: panel.position,
10216
+ panel: panel
10217
+ });
10218
+ });
10219
+ };
10312
10220
 
10313
- if (position === panelPos) {
10314
- return nearestPanel.index;
10315
- }
10221
+ __proto.findAnchorIncludePosition = function (position) {
10222
+ var camera = this._flicking.camera;
10223
+ var range = camera.range;
10224
+ var anchors = camera.anchorPoints;
10225
+ var rangeDiff = camera.rangeDiff;
10226
+ var anchorCount = anchors.length;
10227
+ var positionInRange = circulatePosition(position, range.min, range.max);
10316
10228
 
10317
- if (position < panelPos) {
10318
- var prevPanel = nearestPanel.prev();
10319
- var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
10229
+ var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
10320
10230
 
10321
- if (prevPosition > panelPos) {
10322
- prevPosition -= rangeDiff;
10323
- }
10231
+ if (anchorCount > 0 && (position === range.min || position === range.max)) {
10232
+ var possibleAnchors = [anchorInRange, new AnchorPoint({
10233
+ index: 0,
10234
+ position: anchors[0].position + rangeDiff,
10235
+ panel: anchors[0].panel
10236
+ }), new AnchorPoint({
10237
+ index: anchorCount - 1,
10238
+ position: anchors[anchorCount - 1].position - rangeDiff,
10239
+ panel: anchors[anchorCount - 1].panel
10240
+ })].filter(function (anchor) {
10241
+ return !!anchor;
10242
+ });
10243
+ anchorInRange = possibleAnchors.reduce(function (nearest, anchor) {
10244
+ if (!nearest) return anchor;
10245
+ return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
10246
+ }, null);
10247
+ }
10324
10248
 
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
10249
+ if (!anchorInRange) return null;
10329
10250
 
10330
- if (nextPosition < panelPos) {
10331
- nextPosition += rangeDiff;
10332
- }
10251
+ if (position < range.min) {
10252
+ var loopCount = -Math.floor((range.min - position) / rangeDiff) - 1;
10253
+ return new AnchorPoint({
10254
+ index: anchorInRange.index,
10255
+ position: anchorInRange.position + rangeDiff * loopCount,
10256
+ panel: anchorInRange.panel
10257
+ });
10258
+ } else if (position > range.max) {
10259
+ var loopCount = Math.floor((position - range.max) / rangeDiff) + 1;
10260
+ return new AnchorPoint({
10261
+ index: anchorInRange.index,
10262
+ position: anchorInRange.position + rangeDiff * loopCount,
10263
+ panel: anchorInRange.panel
10264
+ });
10265
+ }
10333
10266
 
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
10267
+ return anchorInRange;
10268
+ };
10342
10269
 
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
- */
10270
+ __proto.getCircularOffset = function () {
10271
+ var flicking = this._flicking;
10272
+ var camera = flicking.camera;
10273
+ if (!camera.circularEnabled) return 0;
10274
+ var toggled = flicking.panels.filter(function (panel) {
10275
+ return panel.toggled;
10276
+ });
10277
+ var toggledPrev = toggled.filter(function (panel) {
10278
+ return panel.toggleDirection === DIRECTION.PREV;
10279
+ });
10280
+ var toggledNext = toggled.filter(function (panel) {
10281
+ return panel.toggleDirection === DIRECTION.NEXT;
10282
+ });
10283
+ return this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
10284
+ };
10368
10285
 
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;
10286
+ __proto.clampToReachablePosition = function (position) {
10287
+ // Basically all position is reachable for circular camera
10288
+ return position;
10289
+ };
10374
10290
 
10375
- this._checkTranslateSupport();
10291
+ __proto.canReach = function (panel) {
10292
+ if (panel.removed) return false; // Always reachable on circular mode
10376
10293
 
10377
- return this;
10294
+ return true;
10378
10295
  };
10379
- /**
10380
- * Destroy Camera and return to initial state
10381
- * @ko Camera를 초기 상태로 되돌립니다
10382
- * @return {void}
10383
- */
10384
10296
 
10297
+ __proto.canSee = function (panel) {
10298
+ var camera = this._flicking.camera;
10299
+ var range = camera.range;
10300
+ var rangeDiff = camera.rangeDiff;
10301
+ var visibleRange = camera.visibleRange;
10385
10302
 
10386
- __proto.destroy = function () {
10387
- this._flicking = null;
10303
+ var visibleInCurrentRange = _super.prototype.canSee.call(this, panel); // Check looped visible area for circular case
10388
10304
 
10389
- this._resetInternalValues();
10390
10305
 
10391
- return this;
10306
+ if (visibleRange.min < range.min) {
10307
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min + rangeDiff, visibleRange.max + rangeDiff);
10308
+ } else if (visibleRange.max > range.max) {
10309
+ return visibleInCurrentRange || panel.isVisibleOnRange(visibleRange.min - rangeDiff, visibleRange.max - rangeDiff);
10310
+ }
10311
+
10312
+ return visibleInCurrentRange;
10392
10313
  };
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
10314
 
10315
+ __proto._calcPanelAreaSum = function (panels) {
10316
+ return panels.reduce(function (sum, panel) {
10317
+ return sum + panel.sizeIncludingMargin;
10318
+ }, 0);
10319
+ };
10403
10320
 
10404
- __proto.lookAt = function (pos) {
10405
- var prevPos = this._position;
10406
- this._position = pos;
10321
+ return CircularCameraMode;
10322
+ }(CameraMode);
10407
10323
 
10408
- this._refreshVisiblePanels();
10324
+ var BoundCameraMode =
10325
+ /*#__PURE__*/
10326
+ function (_super) {
10327
+ __extends$2(BoundCameraMode, _super);
10409
10328
 
10410
- this._checkNeedPanel();
10329
+ function BoundCameraMode() {
10330
+ return _super !== null && _super.apply(this, arguments) || this;
10331
+ }
10411
10332
 
10412
- this._checkReachEnd(prevPos, pos);
10333
+ var __proto = BoundCameraMode.prototype;
10413
10334
 
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
- */
10335
+ __proto.checkAvailability = function () {
10336
+ var flicking = this._flicking;
10337
+ var renderer = flicking.renderer;
10338
+ var firstPanel = renderer.getPanel(0);
10339
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
10424
10340
 
10341
+ if (!firstPanel || !lastPanel) {
10342
+ return false;
10343
+ }
10425
10344
 
10426
- __proto.getPrevAnchor = function (anchor) {
10427
- return this._anchors[anchor.index - 1] || null;
10345
+ var viewportSize = flicking.camera.size;
10346
+ var firstPanelPrev = firstPanel.range.min;
10347
+ var lastPanelNext = lastPanel.range.max;
10348
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
10349
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
10350
+ return isBiggerThanViewport;
10428
10351
  };
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
10352
 
10353
+ __proto.getRange = function () {
10354
+ var flicking = this._flicking;
10355
+ var renderer = flicking.renderer;
10356
+ var alignPos = flicking.camera.alignPosition;
10357
+ var firstPanel = renderer.getPanel(0);
10358
+ var lastPanel = renderer.getPanel(renderer.panelCount - 1);
10438
10359
 
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
- */
10360
+ if (!firstPanel || !lastPanel) {
10361
+ return {
10362
+ min: 0,
10363
+ max: 0
10364
+ };
10365
+ }
10450
10366
 
10367
+ var viewportSize = flicking.camera.size;
10368
+ var firstPanelPrev = firstPanel.range.min;
10369
+ var lastPanelNext = lastPanel.range.max;
10370
+ var panelAreaSize = lastPanelNext - firstPanelPrev;
10371
+ var isBiggerThanViewport = viewportSize < panelAreaSize;
10372
+ var firstPos = firstPanelPrev + alignPos;
10373
+ var lastPos = lastPanelNext - viewportSize + alignPos;
10451
10374
 
10452
- __proto.getProgressInPanel = function (panel) {
10453
- var panelRange = panel.range;
10454
- return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
10375
+ if (isBiggerThanViewport) {
10376
+ return {
10377
+ min: firstPos,
10378
+ max: lastPos
10379
+ };
10380
+ } else {
10381
+ var align = flicking.camera.align;
10382
+ var alignVal = typeof align === "object" ? align.camera : align;
10383
+ var pos = firstPos + parseAlign$1(alignVal, lastPos - firstPos);
10384
+ return {
10385
+ min: pos,
10386
+ max: pos
10387
+ };
10388
+ }
10455
10389
  };
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
10390
 
10391
+ __proto.getAnchors = function () {
10392
+ var flicking = this._flicking;
10393
+ var camera = flicking.camera;
10394
+ var panels = flicking.renderer.panels;
10465
10395
 
10466
- __proto.findAnchorIncludePosition = function (position) {
10467
- var anchors = this._anchors;
10468
- var anchorsIncludingPosition = anchors.filter(function (anchor) {
10469
- return anchor.panel.includePosition(position, true);
10396
+ if (panels.length <= 0) {
10397
+ return [];
10398
+ }
10399
+
10400
+ var range = flicking.camera.range;
10401
+ var reachablePanels = panels.filter(function (panel) {
10402
+ return camera.canReach(panel);
10470
10403
  });
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
10404
 
10405
+ if (reachablePanels.length > 0) {
10406
+ var shouldPrependBoundAnchor = reachablePanels[0].position !== range.min;
10407
+ var shouldAppendBoundAnchor = reachablePanels[reachablePanels.length - 1].position !== range.max;
10408
+ var indexOffset_1 = shouldPrependBoundAnchor ? 1 : 0;
10409
+ var newAnchors = reachablePanels.map(function (panel, idx) {
10410
+ return new AnchorPoint({
10411
+ index: idx + indexOffset_1,
10412
+ position: panel.position,
10413
+ panel: panel
10414
+ });
10415
+ });
10485
10416
 
10486
- __proto.findNearestAnchor = function (position) {
10487
- var anchors = this._anchors;
10417
+ if (shouldPrependBoundAnchor) {
10418
+ newAnchors.splice(0, 0, new AnchorPoint({
10419
+ index: 0,
10420
+ position: range.min,
10421
+ panel: panels[reachablePanels[0].index - 1]
10422
+ }));
10423
+ }
10424
+
10425
+ if (shouldAppendBoundAnchor) {
10426
+ newAnchors.push(new AnchorPoint({
10427
+ index: newAnchors.length,
10428
+ position: range.max,
10429
+ panel: panels[reachablePanels[reachablePanels.length - 1].index + 1]
10430
+ }));
10431
+ }
10432
+
10433
+ return newAnchors;
10434
+ } else if (range.min !== range.max) {
10435
+ // There're more than 2 panels
10436
+ var nearestPanelAtMin = this._findNearestPanel(range.min, panels);
10437
+
10438
+ var panelAtMin = nearestPanelAtMin.index === panels.length - 1 ? nearestPanelAtMin.prev() : nearestPanelAtMin;
10439
+ var panelAtMax = panelAtMin.next();
10440
+ return [new AnchorPoint({
10441
+ index: 0,
10442
+ position: range.min,
10443
+ panel: panelAtMin
10444
+ }), new AnchorPoint({
10445
+ index: 1,
10446
+ position: range.max,
10447
+ panel: panelAtMax
10448
+ })];
10449
+ } else {
10450
+ return [new AnchorPoint({
10451
+ index: 0,
10452
+ position: range.min,
10453
+ panel: this._findNearestPanel(range.min, panels)
10454
+ })];
10455
+ }
10456
+ };
10457
+
10458
+ __proto.findAnchorIncludePosition = function (position) {
10459
+ var camera = this._flicking.camera;
10460
+ var range = camera.range;
10461
+ var anchors = camera.anchorPoints;
10488
10462
  if (anchors.length <= 0) return null;
10463
+
10464
+ if (position <= range.min) {
10465
+ return anchors[0];
10466
+ } else if (position >= range.max) {
10467
+ return anchors[anchors.length - 1];
10468
+ } else {
10469
+ return _super.prototype.findAnchorIncludePosition.call(this, position);
10470
+ }
10471
+ };
10472
+
10473
+ __proto._findNearestPanel = function (pos, panels) {
10489
10474
  var prevDist = Infinity;
10490
10475
 
10491
- for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
10492
- var anchor = anchors[anchorIdx];
10493
- var dist = Math.abs(anchor.position - position);
10476
+ for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
10477
+ var panel = panels[panelIdx];
10478
+ var dist = Math.abs(panel.position - pos);
10494
10479
 
10495
10480
  if (dist > prevDist) {
10496
10481
  // Return previous anchor
10497
- return anchors[anchorIdx - 1];
10482
+ return panels[panelIdx - 1];
10498
10483
  }
10499
10484
 
10500
10485
  prevDist = dist;
10501
10486
  } // Return last anchor
10502
10487
 
10503
10488
 
10504
- return anchors[anchors.length - 1];
10489
+ return panels[panels.length - 1];
10505
10490
  };
10506
- /**
10507
- * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
10508
- * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
10509
- * @return {AnchorPoint | null}
10510
- */
10511
10491
 
10492
+ return BoundCameraMode;
10493
+ }(CameraMode);
10512
10494
 
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
- */
10495
+ /**
10496
+ * A component that manages actual movement inside the viewport
10497
+ * @ko 뷰포트 내에서의 실제 움직임을 담당하는 컴포넌트
10498
+ */
10526
10499
 
10500
+ var Camera$1 =
10501
+ /*#__PURE__*/
10502
+ function () {
10503
+ /** */
10504
+ function Camera(_a) {
10505
+ var _this = this;
10527
10506
 
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
- */
10507
+ var _b = (_a === void 0 ? {} : _a).align,
10508
+ align = _b === void 0 ? ALIGN.CENTER : _b;
10538
10509
 
10510
+ this._checkTranslateSupport = function () {
10511
+ var e_1, _a;
10539
10512
 
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
- */
10513
+ var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
10514
+ var supportedStyle = document.documentElement.style;
10515
+ var transformName = "";
10552
10516
 
10517
+ try {
10518
+ for (var transforms_1 = __values$2(transforms), transforms_1_1 = transforms_1.next(); !transforms_1_1.done; transforms_1_1 = transforms_1.next()) {
10519
+ var prefixedTransform = transforms_1_1.value;
10553
10520
 
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.
10521
+ if (prefixedTransform in supportedStyle) {
10522
+ transformName = prefixedTransform;
10523
+ }
10524
+ }
10525
+ } catch (e_1_1) {
10526
+ e_1 = {
10527
+ error: e_1_1
10528
+ };
10529
+ } finally {
10530
+ try {
10531
+ if (transforms_1_1 && !transforms_1_1.done && (_a = transforms_1.return)) _a.call(transforms_1);
10532
+ } finally {
10533
+ if (e_1) throw e_1.error;
10534
+ }
10535
+ }
10556
10536
 
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
- */
10537
+ if (!transformName) {
10538
+ throw new FlickingError(MESSAGE.TRANSFORM_NOT_SUPPORTED, CODE.TRANSFORM_NOT_SUPPORTED);
10539
+ }
10565
10540
 
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
- */
10582
-
10583
-
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
- */
10605
-
10606
-
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
- };
10615
- /**
10616
- * Update current offset of the camera
10617
- * @ko 현재 카메라의 오프셋을 업데이트합니다
10618
- * @chainable
10619
- * @return {this}
10620
- */
10621
-
10622
-
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
- */
10643
-
10644
-
10645
- __proto.resetNeedPanelHistory = function () {
10646
- this._needPanelTriggered = {
10647
- prev: false,
10648
- next: false
10541
+ _this._transform = transformName;
10649
10542
  };
10650
- return this;
10651
- };
10652
- /**
10653
- * Apply "transform" style with the current position to camera element
10654
- * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
10655
- * @chainable
10656
- * @return {this}
10657
- */
10658
10543
 
10544
+ this._flicking = null;
10659
10545
 
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
- };
10546
+ this._resetInternalValues(); // Options
10667
10547
 
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
10548
 
10684
- __proto._refreshVisiblePanels = function () {
10685
- var _this = this;
10549
+ this._align = align;
10550
+ }
10686
10551
 
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
- });
10552
+ var __proto = Camera.prototype;
10553
+ Object.defineProperty(__proto, "element", {
10554
+ // Internal states getter
10555
+
10556
+ /**
10557
+ * The camera element(`.flicking-camera`)
10558
+ * @ko 카메라 엘리먼트(`.flicking-camera`)
10559
+ * @type {HTMLElement}
10560
+ * @readonly
10561
+ */
10562
+ get: function () {
10563
+ return this._el;
10564
+ },
10565
+ enumerable: false,
10566
+ configurable: true
10567
+ });
10568
+ Object.defineProperty(__proto, "children", {
10569
+ /**
10570
+ * An array of the child elements of the camera element(`.flicking-camera`)
10571
+ * @ko 카메라 엘리먼트(`.flicking-camera`)의 자식 엘리먼트 배열
10572
+ * @type {HTMLElement[]}
10573
+ * @readonly
10574
+ */
10575
+ get: function () {
10576
+ return toArray$3(this._el.children);
10577
+ },
10578
+ enumerable: false,
10579
+ configurable: true
10580
+ });
10581
+ Object.defineProperty(__proto, "position", {
10582
+ /**
10583
+ * Current position of the camera
10584
+ * @ko Camera의 현재 좌표
10585
+ * @type {number}
10586
+ * @readonly
10587
+ */
10588
+ get: function () {
10589
+ return this._position;
10590
+ },
10591
+ enumerable: false,
10592
+ configurable: true
10593
+ });
10594
+ Object.defineProperty(__proto, "alignPosition", {
10595
+ /**
10596
+ * Align position inside the viewport where {@link Panel}'s {@link Panel#alignPosition alignPosition} should be located at
10597
+ * @ko 패널의 정렬 기준 위치. 뷰포트 내에서 {@link Panel}의 {@link Panel#alignPosition alignPosition}이 위치해야 하는 곳입니다
10598
+ * @type {number}
10599
+ * @readonly
10600
+ */
10601
+ get: function () {
10602
+ return this._alignPos;
10603
+ },
10604
+ enumerable: false,
10605
+ configurable: true
10606
+ });
10607
+ Object.defineProperty(__proto, "offset", {
10608
+ /**
10609
+ * Position offset, used for the {@link Flicking#renderOnlyVisible renderOnlyVisible} option
10610
+ * @ko Camera의 좌표 오프셋. {@link Flicking#renderOnlyVisible renderOnlyVisible} 옵션을 위해 사용됩니다.
10611
+ * @type {number}
10612
+ * @default 0
10613
+ * @readonly
10614
+ */
10615
+ get: function () {
10616
+ return this._offset - this._circularOffset;
10617
+ },
10618
+ enumerable: false,
10619
+ configurable: true
10620
+ });
10621
+ Object.defineProperty(__proto, "circularEnabled", {
10622
+ /**
10623
+ * Whether the `circular` option is enabled.
10624
+ * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
10625
+ * @ko {@link Flicking#circular circular} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
10626
+ * {@link Flicking#circular circular} 옵션은 패널의 크기의 합이 충분하지 않을 경우 비활성화됩니다.
10627
+ * @type {boolean}
10628
+ * @default false
10629
+ * @readonly
10630
+ */
10631
+ get: function () {
10632
+ return this._circularEnabled;
10633
+ },
10634
+ enumerable: false,
10635
+ configurable: true
10636
+ });
10637
+ Object.defineProperty(__proto, "mode", {
10638
+ /**
10639
+ * A current camera mode
10640
+ * @type {CameraMode}
10641
+ * @readonly
10642
+ */
10643
+ get: function () {
10644
+ return this._mode;
10645
+ },
10646
+ enumerable: false,
10647
+ configurable: true
10648
+ });
10649
+ Object.defineProperty(__proto, "range", {
10650
+ /**
10651
+ * A range that Camera's {@link Camera#position position} can reach
10652
+ * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
10653
+ * @type {object}
10654
+ * @property {number} min A minimum position<ko>최소 위치</ko>
10655
+ * @property {number} max A maximum position<ko>최대 위치</ko>
10656
+ * @readonly
10657
+ */
10658
+ get: function () {
10659
+ return this._range;
10660
+ },
10661
+ enumerable: false,
10662
+ configurable: true
10663
+ });
10664
+ Object.defineProperty(__proto, "rangeDiff", {
10665
+ /**
10666
+ * A difference between Camera's minimum and maximum position that can reach
10667
+ * @ko Camera가 도달 가능한 최소/최대 좌표의 차이
10668
+ * @type {number}
10669
+ * @readonly
10670
+ */
10671
+ get: function () {
10672
+ return this._range.max - this._range.min;
10673
+ },
10674
+ enumerable: false,
10675
+ configurable: true
10676
+ });
10677
+ Object.defineProperty(__proto, "visiblePanels", {
10678
+ /**
10679
+ * An array of visible panels from the current position
10680
+ * @ko 현재 보이는 패널들의 배열
10681
+ * @type {Panel[]}
10682
+ * @readonly
10683
+ */
10684
+ get: function () {
10685
+ return this._visiblePanels;
10686
+ },
10687
+ enumerable: false,
10688
+ configurable: true
10689
+ });
10690
+ Object.defineProperty(__proto, "visibleRange", {
10691
+ /**
10692
+ * A range of the visible area from the current position
10693
+ * @ko 현재 위치에서 보이는 범위
10694
+ * @type {object}
10695
+ * @property {number} min A minimum position<ko>최소 위치</ko>
10696
+ * @property {number} min A maximum position<ko>최대 위치</ko>
10697
+ * @readonly
10698
+ */
10699
+ get: function () {
10700
+ return {
10701
+ min: this._position - this._alignPos,
10702
+ max: this._position - this._alignPos + this.size
10703
+ };
10704
+ },
10705
+ enumerable: false,
10706
+ configurable: true
10707
+ });
10708
+ Object.defineProperty(__proto, "anchorPoints", {
10709
+ /**
10710
+ * An array of {@link AnchorPoint}s that Camera can be stopped at
10711
+ * @ko 카메라가 도달 가능한 {@link AnchorPoint}의 목록
10712
+ * @type {AnchorPoint[]}
10713
+ * @readonly
10714
+ */
10715
+ get: function () {
10716
+ return this._anchors;
10717
+ },
10718
+ enumerable: false,
10719
+ configurable: true
10720
+ });
10721
+ Object.defineProperty(__proto, "controlParams", {
10722
+ /**
10723
+ * A current parameters of the Camera for updating {@link AxesController}
10724
+ * @ko {@link AxesController}를 업데이트하기 위한 현재 Camera 패러미터들
10725
+ * @type {ControlParams}
10726
+ * @readonly
10727
+ */
10728
+ get: function () {
10729
+ return {
10730
+ range: this._range,
10731
+ position: this._position,
10732
+ circular: this._circularEnabled
10733
+ };
10734
+ },
10735
+ enumerable: false,
10736
+ configurable: true
10737
+ });
10738
+ Object.defineProperty(__proto, "atEdge", {
10739
+ /**
10740
+ * A Boolean value indicating whether Camera's over the minimum or maximum position reachable
10741
+ * @ko 현재 카메라가 도달 가능한 범위의 최소 혹은 최대점을 넘어섰는지를 나타냅니다
10742
+ * @type {boolean}
10743
+ * @readonly
10744
+ */
10745
+ get: function () {
10746
+ return this._position <= this._range.min || this._position >= this._range.max;
10747
+ },
10748
+ enumerable: false,
10749
+ configurable: true
10750
+ });
10751
+ Object.defineProperty(__proto, "size", {
10752
+ /**
10753
+ * Return the size of the viewport
10754
+ * @ko 뷰포트 크기를 반환합니다
10755
+ * @type {number}
10756
+ * @readonly
10757
+ */
10758
+ get: function () {
10759
+ var flicking = this._flicking;
10760
+ return flicking ? flicking.horizontal ? flicking.viewport.width : flicking.viewport.height : 0;
10761
+ },
10762
+ enumerable: false,
10763
+ configurable: true
10764
+ });
10765
+ Object.defineProperty(__proto, "progress", {
10766
+ /**
10767
+ * Return the camera's position progress from the first panel to last panel
10768
+ * Range is from 0 to last panel's index
10769
+ * @ko 첫번째 패널로부터 마지막 패널까지의 카메라 위치의 진행도를 반환합니다
10770
+ * 범위는 0부터 마지막 패널의 인덱스까지입니다
10771
+ * @type {number}
10772
+ * @readonly
10773
+ */
10774
+ get: function () {
10775
+ var flicking = this._flicking;
10776
+ var position = this._position + this._offset;
10777
+ var nearestAnchor = this.findNearestAnchor(this._position);
10700
10778
 
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
- };
10779
+ if (!flicking || !nearestAnchor) {
10780
+ return NaN;
10781
+ }
10711
10782
 
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;
10783
+ var nearestPanel = nearestAnchor.panel;
10784
+ var panelPos = nearestPanel.position + nearestPanel.offset;
10785
+ var bounceSize = flicking.control.controller.bounce;
10786
+ var _a = this.range,
10787
+ prevRange = _a.min,
10788
+ nextRange = _a.max;
10789
+ var rangeDiff = this.rangeDiff;
10717
10790
 
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;
10791
+ if (position === panelPos) {
10792
+ return nearestPanel.index;
10724
10793
  }
10725
10794
 
10726
- if (!needPanelTriggered.next) {
10727
- flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
10728
- direction: DIRECTION.NEXT
10729
- }));
10730
- needPanelTriggered.next = true;
10731
- }
10795
+ if (position < panelPos) {
10796
+ var prevPanel = nearestPanel.prev();
10797
+ var prevPosition = prevPanel ? prevPanel.position + prevPanel.offset : prevRange - bounceSize[0]; // Looped
10732
10798
 
10733
- return;
10734
- }
10799
+ if (prevPosition > panelPos) {
10800
+ prevPosition -= rangeDiff;
10801
+ }
10735
10802
 
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];
10803
+ return nearestPanel.index - 1 + getProgress(position, prevPosition, panelPos);
10804
+ } else {
10805
+ var nextPanel = nearestPanel.next();
10806
+ var nextPosition = nextPanel ? nextPanel.position + nextPanel.offset : nextRange + bounceSize[1]; // Looped
10744
10807
 
10745
- if (!needPanelTriggered.prev) {
10746
- var firstPanelPrev = firstPanel.range.min;
10808
+ if (nextPosition < panelPos) {
10809
+ nextPosition += rangeDiff;
10810
+ }
10747
10811
 
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;
10812
+ return nearestPanel.index + getProgress(position, panelPos, nextPosition);
10753
10813
  }
10754
- }
10814
+ },
10815
+ enumerable: false,
10816
+ configurable: true
10817
+ });
10818
+ Object.defineProperty(__proto, "align", {
10819
+ // Options Getter
10755
10820
 
10756
- if (!needPanelTriggered.next) {
10757
- var lastPanelNext = lastPanel.range.max;
10821
+ /**
10822
+ * A value indicating where the {@link Camera#alignPosition alignPosition} should be located at inside the viewport element
10823
+ * @ko {@link Camera#alignPosition alignPosition}이 뷰포트 엘리먼트 내의 어디에 위치해야 하는지를 나타내는 값
10824
+ * @type {ALIGN | string | number}
10825
+ */
10826
+ get: function () {
10827
+ return this._align;
10828
+ },
10829
+ // Options Setter
10830
+ set: function (val) {
10831
+ this._align = val;
10832
+ },
10833
+ enumerable: false,
10834
+ configurable: true
10835
+ });
10836
+ /**
10837
+ * Initialize Camera
10838
+ * @ko Camera를 초기화합니다
10839
+ * @param {Flicking} flicking An instance of {@link Flicking}<ko>Flicking의 인스턴스</ko>
10840
+ * @chainable
10841
+ * @throws {FlickingError}
10842
+ * {@link ERROR_CODE VAL_MUST_NOT_NULL} If the camera element(`.flicking-camera`) does not exist inside viewport element
10843
+ * <ko>{@link ERROR_CODE VAL_MUST_NOT_NULL} 뷰포트 엘리먼트 내부에 카메라 엘리먼트(`.flicking-camera`)가 존재하지 않을 경우</ko>
10844
+ * @return {this}
10845
+ */
10758
10846
 
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
- };
10847
+ __proto.init = function (flicking) {
10848
+ this._flicking = flicking;
10849
+ var viewportEl = flicking.viewport.element;
10850
+ checkExistence(viewportEl.firstElementChild, "First element child of the viewport element");
10851
+ this._el = viewportEl.firstElementChild;
10767
10852
 
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
- }));
10853
+ this._checkTranslateSupport();
10854
+
10855
+ this._updateMode();
10856
+
10857
+ return this;
10778
10858
  };
10859
+ /**
10860
+ * Destroy Camera and return to initial state
10861
+ * @ko Camera를 초기 상태로 되돌립니다
10862
+ * @return {void}
10863
+ */
10779
10864
 
10780
- return Camera;
10781
- }();
10782
10865
 
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
- */
10866
+ __proto.destroy = function () {
10867
+ this._flicking = null;
10787
10868
 
10788
- var LinearCamera =
10789
- /*#__PURE__*/
10790
- function (_super) {
10791
- __extends$2(LinearCamera, _super);
10869
+ this._resetInternalValues();
10792
10870
 
10793
- function LinearCamera() {
10794
- return _super !== null && _super.apply(this, arguments) || this;
10795
- }
10871
+ return this;
10872
+ };
10796
10873
  /**
10797
- * Update {@link Camera#range range} of Camera
10798
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
10799
- * @chainable
10874
+ * Move to the given position and apply CSS transform
10875
+ * @ko 해당 좌표로 이동하고, CSS transform을 적용합니다
10876
+ * @param {number} pos A new position<ko>움직일 위치</ko>
10800
10877
  * @throws {FlickingError}
10801
10878
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
10802
10879
  * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
@@ -10804,170 +10881,190 @@ version: 4.4.2
10804
10881
  */
10805
10882
 
10806
10883
 
10807
- var __proto = LinearCamera.prototype;
10808
-
10809
- __proto.updateRange = function () {
10810
- var _a, _b;
10884
+ __proto.lookAt = function (pos) {
10885
+ var _this = this;
10811
10886
 
10812
10887
  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
- };
10888
+ var prevPos = this._position;
10889
+ this._position = pos;
10822
10890
 
10823
- return LinearCamera;
10824
- }(Camera$1);
10891
+ var toggled = this._togglePanels(prevPos, pos);
10825
10892
 
10826
- /**
10827
- * A {@link Camera} that connects the last panel and the first panel, enabling continuous loop
10828
- * @ko 첫번째 패널과 마지막 패널이 이어진 상태로, 무한히 회전할 수 있는 종류의 {@link Camera}
10829
- */
10893
+ this._refreshVisiblePanels();
10830
10894
 
10831
- var CircularCamera =
10832
- /*#__PURE__*/
10833
- function (_super) {
10834
- __extends$2(CircularCamera, _super);
10895
+ this._checkNeedPanel();
10835
10896
 
10836
- function CircularCamera() {
10837
- var _this = _super !== null && _super.apply(this, arguments) || this;
10897
+ this._checkReachEnd(prevPos, pos);
10838
10898
 
10839
- _this._circularOffset = 0;
10840
- _this._circularEnabled = false;
10841
- return _this;
10842
- }
10899
+ this.applyTransform();
10900
+
10901
+ if (toggled) {
10902
+ void flicking.renderer.render().then(function () {
10903
+ _this.updateOffset();
10904
+ });
10905
+ }
10906
+ };
10907
+ /**
10908
+ * Return a previous {@link AnchorPoint} of given {@link AnchorPoint}
10909
+ * If it does not exist, return `null` instead
10910
+ * @ko 주어진 {@link AnchorPoint}의 이전 {@link AnchorPoint}를 반환합니다
10911
+ * 존재하지 않을 경우 `null`을 반환합니다
10912
+ * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
10913
+ * @return {AnchorPoint | null} The previous {@link AnchorPoint}<ko>이전 {@link AnchorPoint}</ko>
10914
+ */
10843
10915
 
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
10916
 
10864
10917
  __proto.getPrevAnchor = function (anchor) {
10865
- if (!this._circularEnabled || anchor.index !== 0) return _super.prototype.getPrevAnchor.call(this, anchor);
10918
+ if (!this._circularEnabled || anchor.index !== 0) {
10919
+ return this._anchors[anchor.index - 1] || null;
10920
+ } else {
10921
+ var anchors = this._anchors;
10922
+ var rangeDiff = this.rangeDiff;
10923
+ var lastAnchor = anchors[anchors.length - 1];
10924
+ return new AnchorPoint({
10925
+ index: lastAnchor.index,
10926
+ position: lastAnchor.position - rangeDiff,
10927
+ panel: lastAnchor.panel
10928
+ });
10929
+ }
10930
+ };
10931
+ /**
10932
+ * Return a next {@link AnchorPoint} of given {@link AnchorPoint}
10933
+ * If it does not exist, return `null` instead
10934
+ * @ko 주어진 {@link AnchorPoint}의 다음 {@link AnchorPoint}를 반환합니다
10935
+ * 존재하지 않을 경우 `null`을 반환합니다
10936
+ * @param {AnchorPoint} anchor A reference {@link AnchorPoint}<ko>기준 {@link AnchorPoint}</ko>
10937
+ * @return {AnchorPoint | null} The next {@link AnchorPoint}<ko>다음 {@link AnchorPoint}</ko>
10938
+ */
10939
+
10940
+
10941
+ __proto.getNextAnchor = function (anchor) {
10866
10942
  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
- });
10943
+
10944
+ if (!this._circularEnabled || anchor.index !== anchors.length - 1) {
10945
+ return anchors[anchor.index + 1] || null;
10946
+ } else {
10947
+ var rangeDiff = this.rangeDiff;
10948
+ var firstAnchor = anchors[0];
10949
+ return new AnchorPoint({
10950
+ index: firstAnchor.index,
10951
+ position: firstAnchor.position + rangeDiff,
10952
+ panel: firstAnchor.panel
10953
+ });
10954
+ }
10874
10955
  };
10956
+ /**
10957
+ * Return the camera's position progress in the panel below
10958
+ * Value is from 0 to 1 when the camera's inside panel
10959
+ * Value can be lower than 0 or bigger than 1 when it's in the margin area
10960
+ * @ko 현재 카메라 아래 패널에서의 위치 진행도를 반환합니다
10961
+ * 반환값은 카메라가 패널 내부에 있을 경우 0부터 1까지의 값을 갖습니다
10962
+ * 패널의 margin 영역에 있을 경우 0보다 작거나 1보다 큰 값을 반환할 수 있습니다
10963
+ */
10875
10964
 
10876
- __proto.getNextAnchor = function (anchor) {
10877
- 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
- });
10965
+
10966
+ __proto.getProgressInPanel = function (panel) {
10967
+ var panelRange = panel.range;
10968
+ return (this._position - panelRange.min) / (panelRange.max - panelRange.min);
10886
10969
  };
10970
+ /**
10971
+ * Return {@link AnchorPoint} that includes given position
10972
+ * If there's no {@link AnchorPoint} that includes the given position, return `null` instead
10973
+ * @ko 주어진 좌표를 포함하는 {@link AnchorPoint}를 반환합니다
10974
+ * 주어진 좌표를 포함하는 {@link AnchorPoint}가 없을 경우 `null`을 반환합니다
10975
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
10976
+ * @return {AnchorPoint | null} The {@link AnchorPoint} that includes the given position<ko>해당 좌표를 포함하는 {@link AnchorPoint}</ko>
10977
+ */
10978
+
10887
10979
 
10888
10980
  __proto.findAnchorIncludePosition = function (position) {
10889
- if (!this._circularEnabled) return _super.prototype.findAnchorIncludePosition.call(this, position);
10890
- var range = this._range;
10981
+ return this._mode.findAnchorIncludePosition(position);
10982
+ };
10983
+ /**
10984
+ * Return {@link AnchorPoint} nearest to given position
10985
+ * If there're no {@link AnchorPoint}s, return `null` instead
10986
+ * @ko 해당 좌표에서 가장 가까운 {@link AnchorPoint}를 반환합니다
10987
+ * {@link AnchorPoint}가 하나도 없을 경우 `null`을 반환합니다
10988
+ * @param {number} position A position to check<ko>확인할 좌표</ko>
10989
+ * @return {AnchorPoint | null} The {@link AnchorPoint} nearest to the given position<ko>해당 좌표에 가장 인접한 {@link AnchorPoint}</ko>
10990
+ */
10991
+
10992
+
10993
+ __proto.findNearestAnchor = function (position) {
10891
10994
  var anchors = this._anchors;
10892
- var rangeDiff = this.rangeDiff;
10893
- var anchorCount = anchors.length;
10894
- var positionInRange = circulatePosition(position, range.min, range.max);
10995
+ if (anchors.length <= 0) return null;
10996
+ var prevDist = Infinity;
10895
10997
 
10896
- var anchorInRange = _super.prototype.findAnchorIncludePosition.call(this, positionInRange);
10998
+ for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
10999
+ var anchor = anchors[anchorIdx];
11000
+ var dist = Math.abs(anchor.position - position);
10897
11001
 
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
- }
11002
+ if (dist > prevDist) {
11003
+ // Return previous anchor
11004
+ return anchors[anchorIdx - 1];
11005
+ }
10915
11006
 
10916
- if (!anchorInRange) return null;
11007
+ prevDist = dist;
11008
+ } // Return last anchor
10917
11009
 
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
11010
 
10934
- return anchorInRange;
11011
+ return anchors[anchors.length - 1];
10935
11012
  };
11013
+ /**
11014
+ * Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
11015
+ * @ko 현재 {@link Flicking#currentPanel}에 해당하는 {@link AnchorPoint}를 반환합니다
11016
+ * @return {AnchorPoint | null}
11017
+ */
10936
11018
 
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
11019
 
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);
11020
+ __proto.findActiveAnchor = function () {
11021
+ var flicking = getFlickingAttached(this._flicking);
11022
+ var activeIndex = flicking.control.activeIndex;
11023
+ return find$1(this._anchors, function (anchor) {
11024
+ return anchor.panel.index === activeIndex;
11025
+ });
10946
11026
  };
11027
+ /**
11028
+ * Clamp the given position between camera's range
11029
+ * @ko 주어진 좌표를 Camera가 도달 가능한 범위 사이의 값으로 만듭니다
11030
+ * @param {number} position A position to clamp<ko>범위를 제한할 좌표</ko>
11031
+ * @return {number} A clamped position<ko>범위 제한된 좌표</ko>
11032
+ */
10947
11033
 
10948
- __proto.canSee = function (panel) {
10949
- var range = this._range;
10950
- var rangeDiff = this.rangeDiff;
10951
- var visibleRange = this.visibleRange;
10952
11034
 
10953
- var visibleInCurrentRange = _super.prototype.canSee.call(this, panel);
11035
+ __proto.clampToReachablePosition = function (position) {
11036
+ return this._mode.clampToReachablePosition(position);
11037
+ };
11038
+ /**
11039
+ * Check whether the given panel is inside of the Camera's range
11040
+ * @ko 해당 {@link Panel}이 Camera가 도달 가능한 범위 내에 있는지를 반환합니다
11041
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
11042
+ * @return {boolean} Whether the panel's inside Camera's range<ko>도달 가능한 범위 내에 해당 패널이 존재하는지 여부</ko>
11043
+ */
10954
11044
 
10955
- if (!this._circularEnabled) {
10956
- return visibleInCurrentRange;
10957
- } // Check looped visible area for circular case
10958
11045
 
11046
+ __proto.canReach = function (panel) {
11047
+ return this._mode.canReach(panel);
11048
+ };
11049
+ /**
11050
+ * Check whether the given panel element is visible at the current position
11051
+ * @ko 현재 좌표에서 해당 패널 엘리먼트를 볼 수 있는지 여부를 반환합니다
11052
+ * @param panel An instance of {@link Panel} to check<ko>확인할 {@link Panel}의 인스턴스</ko>
11053
+ * @return Whether the panel element is visible at the current position<ko>현재 위치에서 해당 패널 엘리먼트가 보이는지 여부</ko>
11054
+ */
10959
11055
 
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
11056
 
10966
- return visibleInCurrentRange;
11057
+ __proto.canSee = function (panel) {
11058
+ return this._mode.canSee(panel);
10967
11059
  };
10968
11060
  /**
10969
11061
  * Update {@link Camera#range range} of Camera
10970
11062
  * @ko Camera의 {@link Camera#range range}를 업데이트합니다
11063
+ * @method
11064
+ * @abstract
11065
+ * @memberof Camera
11066
+ * @instance
11067
+ * @name updateRange
10971
11068
  * @chainable
10972
11069
  * @throws {FlickingError}
10973
11070
  * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
@@ -10981,287 +11078,269 @@ version: 4.4.2
10981
11078
  var renderer = flicking.renderer;
10982
11079
  var panels = renderer.panels;
10983
11080
 
10984
- if (panels.length <= 0) {
10985
- this._resetInternalValues();
10986
-
10987
- return this;
10988
- }
11081
+ this._updateMode();
10989
11082
 
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;
11083
+ this._range = this._mode.getRange();
11000
11084
 
11001
- if (canSetCircularMode) {
11002
- this._range = {
11003
- min: firstPanelPrev,
11004
- max: lastPanelNext
11005
- };
11085
+ if (this._circularEnabled) {
11006
11086
  panels.forEach(function (panel) {
11007
11087
  return panel.updateCircularToggleDirection();
11008
11088
  });
11009
- } else {
11010
- this._range = {
11011
- min: firstPanel.position,
11012
- max: lastPanel.position
11013
- };
11014
11089
  }
11015
11090
 
11016
11091
  this.updateOffset();
11017
11092
  return this;
11018
11093
  };
11094
+ /**
11095
+ * Update Camera's {@link Camera#alignPosition alignPosition}
11096
+ * @ko Camera의 {@link Camera#alignPosition alignPosition}을 업데이트합니다
11097
+ * @chainable
11098
+ * @return {this}
11099
+ */
11019
11100
 
11020
- __proto.updateOffset = function () {
11021
- this._updateCircularOffset();
11022
11101
 
11023
- return _super.prototype.updateOffset.call(this);
11102
+ __proto.updateAlignPos = function () {
11103
+ var align = this._align;
11104
+ var alignVal = typeof align === "object" ? align.camera : align;
11105
+ this._alignPos = parseAlign$1(alignVal, this.size);
11106
+ return this;
11024
11107
  };
11108
+ /**
11109
+ * Update Camera's {@link Camera#anchorPoints anchorPoints}
11110
+ * @ko Camera의 {@link Camera#anchorPoints anchorPoints}를 업데이트합니다
11111
+ * @throws {FlickingError}
11112
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
11113
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
11114
+ * @chainable
11115
+ * @return {this}
11116
+ */
11025
11117
 
11026
- __proto.lookAt = function (pos) {
11027
- var _this = this;
11028
-
11029
- 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);
11035
- });
11036
- this._position = pos;
11037
-
11038
- _super.prototype.lookAt.call(this, pos);
11039
-
11040
- if (toggled.some(function (isToggled) {
11041
- return isToggled;
11042
- })) {
11043
- void flicking.renderer.render().then(function () {
11044
- _this.updateOffset();
11045
- });
11046
- }
11047
- };
11048
11118
 
11049
- __proto.applyTransform = function () {
11050
- var el = this._el;
11051
- var flicking = getFlickingAttached(this._flicking);
11052
- var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
11053
- el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
11119
+ __proto.updateAnchors = function () {
11120
+ this._anchors = this._mode.getAnchors();
11054
11121
  return this;
11055
11122
  };
11123
+ /**
11124
+ * Update Viewport's height to active panel's height
11125
+ * @ko 현재 선택된 패널의 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
11126
+ * @throws {FlickingError}
11127
+ * {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
11128
+ * <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
11129
+ * @chainable
11130
+ * @return {this}
11131
+ */
11056
11132
 
11057
- __proto._resetInternalValues = function () {
11058
- _super.prototype._resetInternalValues.call(this);
11059
-
11060
- this._circularOffset = 0;
11061
- this._circularEnabled = false;
11062
- };
11063
11133
 
11064
- __proto._calcPanelAreaSum = function (panels) {
11065
- return panels.reduce(function (sum, panel) {
11066
- return sum + panel.sizeIncludingMargin;
11067
- }, 0);
11134
+ __proto.updateAdaptiveHeight = function () {
11135
+ var flicking = getFlickingAttached(this._flicking);
11136
+ var activePanel = flicking.control.activePanel;
11137
+ if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
11138
+ flicking.viewport.setSize({
11139
+ height: activePanel.height
11140
+ });
11068
11141
  };
11142
+ /**
11143
+ * Update current offset of the camera
11144
+ * @ko 현재 카메라의 오프셋을 업데이트합니다
11145
+ * @chainable
11146
+ * @return {this}
11147
+ */
11069
11148
 
11070
- __proto._updateCircularOffset = function () {
11071
- if (!this._circularEnabled) {
11072
- this._circularOffset = 0;
11073
- return;
11074
- }
11075
11149
 
11150
+ __proto.updateOffset = function () {
11076
11151
  var flicking = getFlickingAttached(this._flicking);
11077
- var toggled = flicking.panels.filter(function (panel) {
11078
- return panel.toggled;
11079
- });
11080
- var toggledPrev = toggled.filter(function (panel) {
11081
- return panel.toggleDirection === DIRECTION.PREV;
11082
- });
11083
- var toggledNext = toggled.filter(function (panel) {
11084
- return panel.toggleDirection === DIRECTION.NEXT;
11152
+ var position = this._position;
11153
+ var unRenderedPanels = flicking.panels.filter(function (panel) {
11154
+ return !panel.rendered;
11085
11155
  });
11086
- this._circularOffset = this._calcPanelAreaSum(toggledPrev) - this._calcPanelAreaSum(toggledNext);
11156
+ this._offset = unRenderedPanels.filter(function (panel) {
11157
+ return panel.position + panel.offset < position;
11158
+ }).reduce(function (offset, panel) {
11159
+ return offset + panel.sizeIncludingMargin;
11160
+ }, 0);
11161
+ this._circularOffset = this._mode.getCircularOffset();
11162
+ this.applyTransform();
11163
+ return this;
11087
11164
  };
11165
+ /**
11166
+ * Reset the history of {@link Flicking#event:needPanel needPanel} events so it can be triggered again
11167
+ * @ko 발생한 {@link Flicking#event:needPanel needPanel} 이벤트들을 초기화하여 다시 발생할 수 있도록 합니다
11168
+ * @chainable
11169
+ * @return {this}
11170
+ */
11088
11171
 
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
11172
 
11102
- function BoundCamera() {
11103
- return _super !== null && _super.apply(this, arguments) || this;
11104
- }
11173
+ __proto.resetNeedPanelHistory = function () {
11174
+ this._needPanelTriggered = {
11175
+ prev: false,
11176
+ next: false
11177
+ };
11178
+ return this;
11179
+ };
11105
11180
  /**
11106
- * Update {@link Camera#range range} of Camera
11107
- * @ko Camera의 {@link Camera#range range}를 업데이트합니다
11181
+ * Apply "transform" style with the current position to camera element
11182
+ * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
11108
11183
  * @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
11184
  * @return {this}
11113
11185
  */
11114
11186
 
11115
11187
 
11116
- var __proto = BoundCamera.prototype;
11117
-
11118
- __proto.updateRange = function () {
11188
+ __proto.applyTransform = function () {
11189
+ var el = this._el;
11119
11190
  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
-
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
- };
11154
- }
11155
-
11191
+ var actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
11192
+ el.style[this._transform] = flicking.horizontal ? "translate(" + -actualPosition + "px)" : "translate(0, " + -actualPosition + "px)";
11156
11193
  return this;
11157
11194
  };
11158
11195
 
11159
- __proto.updateAnchors = function () {
11196
+ __proto._resetInternalValues = function () {
11197
+ this._position = 0;
11198
+ this._alignPos = 0;
11199
+ this._offset = 0;
11200
+ this._circularOffset = 0;
11201
+ this._circularEnabled = false;
11202
+ this._range = {
11203
+ min: 0,
11204
+ max: 0
11205
+ };
11206
+ this._visiblePanels = [];
11207
+ this._anchors = [];
11208
+ this._needPanelTriggered = {
11209
+ prev: false,
11210
+ next: false
11211
+ };
11212
+ };
11213
+
11214
+ __proto._refreshVisiblePanels = function () {
11160
11215
  var _this = this;
11161
11216
 
11162
11217
  var flicking = getFlickingAttached(this._flicking);
11163
11218
  var panels = flicking.renderer.panels;
11164
-
11165
- 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);
11219
+ var newVisiblePanels = panels.filter(function (panel) {
11220
+ return _this.canSee(panel);
11221
+ });
11222
+ var prevVisiblePanels = this._visiblePanels;
11223
+ this._visiblePanels = newVisiblePanels;
11224
+ var added = newVisiblePanels.filter(function (panel) {
11225
+ return !includes(prevVisiblePanels, panel);
11226
+ });
11227
+ var removed = prevVisiblePanels.filter(function (panel) {
11228
+ return !includes(newVisiblePanels, panel);
11173
11229
  });
11174
11230
 
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
- });
11231
+ if (added.length > 0 || removed.length > 0) {
11232
+ void flicking.renderer.render().then(function () {
11233
+ flicking.trigger(new ComponentEvent$1(EVENTS.VISIBLE_CHANGE, {
11234
+ added: added,
11235
+ removed: removed,
11236
+ visiblePanels: newVisiblePanels
11237
+ }));
11185
11238
  });
11239
+ }
11240
+ };
11186
11241
 
11187
- if (shouldPrependBoundAnchor) {
11188
- newAnchors.splice(0, 0, new AnchorPoint({
11189
- index: 0,
11190
- position: range.min,
11191
- panel: panels[reachablePanels[0].index - 1]
11242
+ __proto._checkNeedPanel = function () {
11243
+ var needPanelTriggered = this._needPanelTriggered;
11244
+ if (needPanelTriggered.prev && needPanelTriggered.next) return;
11245
+ var flicking = getFlickingAttached(this._flicking);
11246
+ var panels = flicking.renderer.panels;
11247
+
11248
+ if (panels.length <= 0) {
11249
+ if (!needPanelTriggered.prev) {
11250
+ flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
11251
+ direction: DIRECTION.PREV
11192
11252
  }));
11253
+ needPanelTriggered.prev = true;
11193
11254
  }
11194
11255
 
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]
11256
+ if (!needPanelTriggered.next) {
11257
+ flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
11258
+ direction: DIRECTION.NEXT
11200
11259
  }));
11260
+ needPanelTriggered.next = true;
11201
11261
  }
11202
11262
 
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);
11263
+ return;
11264
+ }
11207
11265
 
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
- })];
11266
+ var cameraPosition = this._position;
11267
+ var cameraSize = this.size;
11268
+ var cameraRange = this._range;
11269
+ var needPanelThreshold = flicking.needPanelThreshold;
11270
+ var cameraPrev = cameraPosition - this._alignPos;
11271
+ var cameraNext = cameraPrev + cameraSize;
11272
+ var firstPanel = panels[0];
11273
+ var lastPanel = panels[panels.length - 1];
11274
+
11275
+ if (!needPanelTriggered.prev) {
11276
+ var firstPanelPrev = firstPanel.range.min;
11277
+
11278
+ if (cameraPrev <= firstPanelPrev + needPanelThreshold || cameraPosition <= cameraRange.min + needPanelThreshold) {
11279
+ flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
11280
+ direction: DIRECTION.PREV
11281
+ }));
11282
+ needPanelTriggered.prev = true;
11283
+ }
11225
11284
  }
11226
11285
 
11227
- return this;
11286
+ if (!needPanelTriggered.next) {
11287
+ var lastPanelNext = lastPanel.range.max;
11288
+
11289
+ if (cameraNext >= lastPanelNext - needPanelThreshold || cameraPosition >= cameraRange.max - needPanelThreshold) {
11290
+ flicking.trigger(new ComponentEvent$1(EVENTS.NEED_PANEL, {
11291
+ direction: DIRECTION.NEXT
11292
+ }));
11293
+ needPanelTriggered.next = true;
11294
+ }
11295
+ }
11228
11296
  };
11229
11297
 
11230
- __proto.findAnchorIncludePosition = function (position) {
11298
+ __proto._checkReachEnd = function (prevPos, newPos) {
11299
+ var flicking = getFlickingAttached(this._flicking);
11231
11300
  var range = this._range;
11232
- var anchors = this._anchors;
11233
- if (anchors.length <= 0) return null;
11234
-
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);
11241
- }
11301
+ var wasBetweenRange = prevPos > range.min && prevPos < range.max;
11302
+ var isBetweenRange = newPos > range.min && newPos < range.max;
11303
+ if (!wasBetweenRange || isBetweenRange) return;
11304
+ var direction = newPos <= range.min ? DIRECTION.PREV : DIRECTION.NEXT;
11305
+ flicking.trigger(new ComponentEvent$1(EVENTS.REACH_EDGE, {
11306
+ direction: direction
11307
+ }));
11242
11308
  };
11243
11309
 
11244
- __proto._findNearestPanel = function (pos, panels) {
11245
- var prevDist = Infinity;
11310
+ __proto._updateMode = function () {
11311
+ var flicking = getFlickingAttached(this._flicking);
11246
11312
 
11247
- for (var panelIdx = 0; panelIdx < panels.length; panelIdx++) {
11248
- var panel = panels[panelIdx];
11249
- var dist = Math.abs(panel.position - pos);
11313
+ if (flicking.circular) {
11314
+ var circularMode = new CircularCameraMode(flicking);
11315
+ var canSetCircularMode = circularMode.checkAvailability();
11250
11316
 
11251
- if (dist > prevDist) {
11252
- // Return previous anchor
11253
- return panels[panelIdx - 1];
11317
+ if (canSetCircularMode) {
11318
+ this._mode = circularMode;
11319
+ } else {
11320
+ var fallbackMode = flicking.circularFallback;
11321
+ this._mode = fallbackMode === CIRCULAR_FALLBACK.BOUND ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
11254
11322
  }
11255
11323
 
11256
- prevDist = dist;
11257
- } // Return last anchor
11258
-
11324
+ this._circularEnabled = canSetCircularMode;
11325
+ } else {
11326
+ this._mode = flicking.bound ? new BoundCameraMode(flicking) : new LinearCameraMode(flicking);
11327
+ }
11328
+ };
11259
11329
 
11260
- return panels[panels.length - 1];
11330
+ __proto._togglePanels = function (prevPos, pos) {
11331
+ if (pos === prevPos) return false;
11332
+ var flicking = getFlickingAttached(this._flicking);
11333
+ var panels = flicking.renderer.panels;
11334
+ var toggled = panels.map(function (panel) {
11335
+ return panel.toggle(prevPos, pos);
11336
+ });
11337
+ return toggled.some(function (isToggled) {
11338
+ return isToggled;
11339
+ });
11261
11340
  };
11262
11341
 
11263
- return BoundCamera;
11264
- }(Camera$1);
11342
+ return Camera;
11343
+ }();
11265
11344
 
11266
11345
  /*
11267
11346
  * Copyright (c) 2015 NAVER Corp.
@@ -11271,9 +11350,9 @@ version: 4.4.2
11271
11350
  var Camera = {
11272
11351
  __proto__: null,
11273
11352
  Camera: Camera$1,
11274
- LinearCamera: LinearCamera,
11275
- CircularCamera: CircularCamera,
11276
- BoundCamera: BoundCamera
11353
+ LinearCameraMode: LinearCameraMode,
11354
+ CircularCameraMode: CircularCameraMode,
11355
+ BoundCameraMode: BoundCameraMode
11277
11356
  };
11278
11357
 
11279
11358
  /*
@@ -12480,7 +12559,7 @@ version: 4.4.2
12480
12559
  flicking: flicking
12481
12560
  });
12482
12561
  });
12483
- panels.splice.apply(panels, __spreadArray([insertingIdx, 0], __read$1(panelsInserted)));
12562
+ panels.splice.apply(panels, __spread$1([insertingIdx, 0], panelsInserted));
12484
12563
 
12485
12564
  if (item.hasDOMInElements) {
12486
12565
  // Insert the actual elements as camera element's children
@@ -12503,7 +12582,7 @@ version: 4.4.2
12503
12582
  panel.increaseIndex(panelsInserted.length);
12504
12583
  panel.updatePosition();
12505
12584
  });
12506
- return __spreadArray(__spreadArray([], __read$1(addedPanels), false), __read$1(panelsInserted));
12585
+ return __spread$1(addedPanels, panelsInserted);
12507
12586
  }, []);
12508
12587
  if (allPanelsInserted.length <= 0) return []; // Update camera & control
12509
12588
 
@@ -12582,7 +12661,7 @@ version: 4.4.2
12582
12661
  control.resetActive();
12583
12662
  }
12584
12663
 
12585
- return __spreadArray(__spreadArray([], __read$1(removed), false), __read$1(panelsRemoved));
12664
+ return __spread$1(removed, panelsRemoved);
12586
12665
  }, []); // Update camera & control
12587
12666
 
12588
12667
  this._updateCameraAndControl();
@@ -13581,7 +13660,7 @@ version: 4.4.2
13581
13660
  var notToggled = renderedPanels.filter(function (panel) {
13582
13661
  return !panel.toggled;
13583
13662
  });
13584
- return __spreadArray(__spreadArray(__spreadArray([], __read$1(toggledPrev), false), __read$1(notToggled), false), __read$1(toggledNext)).map(function (panel) {
13663
+ return __spread$1(toggledPrev, notToggled, toggledNext).map(function (panel) {
13585
13664
  return panel.index;
13586
13665
  });
13587
13666
  };
@@ -13791,7 +13870,7 @@ version: 4.4.2
13791
13870
  __proto.getRenderingIndexesByOrder = function (flicking) {
13792
13871
  var virtualManager = flicking.virtual;
13793
13872
 
13794
- var visiblePanels = __spreadArray([], __read$1(flicking.visiblePanels)).filter(function (panel) {
13873
+ var visiblePanels = __spread$1(flicking.visiblePanels).filter(function (panel) {
13795
13874
  return panel.rendered;
13796
13875
  }).sort(function (panel1, panel2) {
13797
13876
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
@@ -13812,7 +13891,7 @@ version: 4.4.2
13812
13891
  }).map(function (el) {
13813
13892
  return el.idx;
13814
13893
  });
13815
- return __spreadArray(__spreadArray([], __read$1(visibleIndexes), false), __read$1(invisibleIndexes));
13894
+ return __spread$1(visibleIndexes, invisibleIndexes);
13816
13895
  };
13817
13896
 
13818
13897
  __proto.getRenderingElementsByOrder = function (flicking) {
@@ -13935,58 +14014,60 @@ version: 4.4.2
13935
14014
  horizontal = _e === void 0 ? true : _e,
13936
14015
  _f = _b.circular,
13937
14016
  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) {
14017
+ _g = _b.circularFallback,
14018
+ circularFallback = _g === void 0 ? CIRCULAR_FALLBACK.LINEAR : _g,
14019
+ _h = _b.bound,
14020
+ bound = _h === void 0 ? false : _h,
14021
+ _j = _b.adaptive,
14022
+ adaptive = _j === void 0 ? false : _j,
14023
+ _k = _b.panelsPerView,
14024
+ panelsPerView = _k === void 0 ? -1 : _k,
14025
+ _l = _b.noPanelStyleOverride,
14026
+ noPanelStyleOverride = _l === void 0 ? false : _l,
14027
+ _m = _b.resizeOnContentsReady,
14028
+ resizeOnContentsReady = _m === void 0 ? false : _m,
14029
+ _o = _b.needPanelThreshold,
14030
+ needPanelThreshold = _o === void 0 ? 0 : _o,
14031
+ _p = _b.preventEventsBeforeInit,
14032
+ preventEventsBeforeInit = _p === void 0 ? true : _p,
14033
+ _q = _b.deceleration,
14034
+ deceleration = _q === void 0 ? 0.0075 : _q,
14035
+ _r = _b.duration,
14036
+ duration = _r === void 0 ? 500 : _r,
14037
+ _s = _b.easing,
14038
+ easing = _s === void 0 ? function (x) {
13958
14039
  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;
14040
+ } : _s,
14041
+ _t = _b.inputType,
14042
+ inputType = _t === void 0 ? ["mouse", "touch"] : _t,
14043
+ _u = _b.moveType,
14044
+ moveType = _u === void 0 ? "snap" : _u,
14045
+ _v = _b.threshold,
14046
+ threshold = _v === void 0 ? 40 : _v,
14047
+ _w = _b.interruptable,
14048
+ interruptable = _w === void 0 ? true : _w,
14049
+ _x = _b.bounce,
14050
+ bounce = _x === void 0 ? "20%" : _x,
14051
+ _y = _b.iOSEdgeSwipeThreshold,
14052
+ iOSEdgeSwipeThreshold = _y === void 0 ? 30 : _y,
14053
+ _z = _b.preventClickOnDrag,
14054
+ preventClickOnDrag = _z === void 0 ? true : _z,
14055
+ _0 = _b.disableOnInit,
14056
+ disableOnInit = _0 === void 0 ? false : _0,
14057
+ _1 = _b.renderOnlyVisible,
14058
+ renderOnlyVisible = _1 === void 0 ? false : _1,
14059
+ _2 = _b.virtual,
14060
+ virtual = _2 === void 0 ? null : _2,
14061
+ _3 = _b.autoInit,
14062
+ autoInit = _3 === void 0 ? true : _3,
14063
+ _4 = _b.autoResize,
14064
+ autoResize = _4 === void 0 ? true : _4,
14065
+ _5 = _b.useResizeObserver,
14066
+ useResizeObserver = _5 === void 0 ? true : _5,
14067
+ _6 = _b.externalRenderer,
14068
+ externalRenderer = _6 === void 0 ? null : _6,
14069
+ _7 = _b.renderExternal,
14070
+ renderExternal = _7 === void 0 ? null : _7;
13990
14071
 
13991
14072
  var _this = _super.call(this) || this; // Internal states
13992
14073
 
@@ -13998,6 +14079,7 @@ version: 4.4.2
13998
14079
  _this._defaultIndex = defaultIndex;
13999
14080
  _this._horizontal = horizontal;
14000
14081
  _this._circular = circular;
14082
+ _this._circularFallback = circularFallback;
14001
14083
  _this._bound = bound;
14002
14084
  _this._adaptive = adaptive;
14003
14085
  _this._panelsPerView = panelsPerView;
@@ -14136,7 +14218,7 @@ version: 4.4.2
14136
14218
  * @readonly
14137
14219
  */
14138
14220
  get: function () {
14139
- return this._camera.controlParams.circular;
14221
+ return this._camera.circularEnabled;
14140
14222
  },
14141
14223
  enumerable: false,
14142
14224
  configurable: true
@@ -14370,6 +14452,24 @@ version: 4.4.2
14370
14452
  enumerable: false,
14371
14453
  configurable: true
14372
14454
  });
14455
+ Object.defineProperty(__proto, "circularFallback", {
14456
+ /**
14457
+ * Set panel control mode for the case when circular cannot be enabled.
14458
+ * "linear" will set the view's range from the top of the first panel to the top of the last panel.
14459
+ * "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.
14460
+ * @ko 순환 모드 사용 불가능시 사용할 패널 조작 범위 설정 방식을 변경합니다.
14461
+ * "linear" 사용시 시점이 첫번째 엘리먼트 위에서부터 마지막 엘리먼트 위까지 움직일 수 있도록 설정합니다.
14462
+ * "bound" 사용시 시점이 첫번째 엘리먼트와 마지막 엘리먼트의 끝과 끝 사이에서 움직일 수 있도록 설정합니다.
14463
+ * @see CIRCULAR_FALLBACK
14464
+ * @type {string}
14465
+ * @default "linear"
14466
+ */
14467
+ get: function () {
14468
+ return this._circularFallback;
14469
+ },
14470
+ enumerable: false,
14471
+ configurable: true
14472
+ });
14373
14473
  Object.defineProperty(__proto, "bound", {
14374
14474
  /**
14375
14475
  * 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
@@ -15330,7 +15430,7 @@ version: 4.4.2
15330
15430
  });
15331
15431
  }
15332
15432
 
15333
- (_a = this._plugins).push.apply(_a, __spreadArray([], __read$1(plugins)));
15433
+ (_a = this._plugins).push.apply(_a, __spread$1(plugins));
15334
15434
 
15335
15435
  return this;
15336
15436
  };
@@ -15577,22 +15677,14 @@ version: 4.4.2
15577
15677
  };
15578
15678
 
15579
15679
  __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);
15680
+ if (this._circular && this._bound) {
15681
+ // eslint-disable-next-line no-console
15682
+ console.warn("\"circular\" and \"bound\" option cannot be used together, ignoring bound.");
15595
15683
  }
15684
+
15685
+ return new Camera$1({
15686
+ align: this._align
15687
+ });
15596
15688
  };
15597
15689
 
15598
15690
  __proto._createRenderer = function () {
@@ -15656,7 +15748,7 @@ version: 4.4.2
15656
15748
  */
15657
15749
 
15658
15750
 
15659
- Flicking.VERSION = "4.4.2";
15751
+ Flicking.VERSION = "4.5.0";
15660
15752
  return Flicking;
15661
15753
  }(Component$1);
15662
15754
 
@@ -15712,7 +15804,7 @@ version: 4.4.2
15712
15804
  args[_i] = arguments[_i];
15713
15805
  }
15714
15806
 
15715
- return (_a = descriptor.value).call.apply(_a, __spreadArray([this[flickingName]], __read$1(args)));
15807
+ return (_a = descriptor.value).call.apply(_a, __spread$1([this[flickingName]], args));
15716
15808
  }
15717
15809
  });
15718
15810
  } else {
@@ -15736,7 +15828,7 @@ version: 4.4.2
15736
15828
  args[_i] = arguments[_i];
15737
15829
  }
15738
15830
 
15739
- return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([this[flickingName]], __read$1(args)));
15831
+ return (_a = descriptor.set) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spread$1([this[flickingName]], args));
15740
15832
  };
15741
15833
  }
15742
15834
 
@@ -15750,7 +15842,7 @@ version: 4.4.2
15750
15842
  var renderer = flicking.renderer;
15751
15843
  var panels = renderer.panels;
15752
15844
 
15753
- var prevList = __spreadArray([], __read$1(diffResult.prevList));
15845
+ var prevList = __spread$1(diffResult.prevList);
15754
15846
 
15755
15847
  if (diffResult.removed.length > 0) {
15756
15848
  var endIdx_1 = -1;
@@ -15830,13 +15922,13 @@ version: 4.4.2
15830
15922
  });
15831
15923
 
15832
15924
  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) {
15925
+ renderer.batchInsert.apply(renderer, __spread$1(diffResult.added.slice(startIdx, endIdx).map(function (index, elIdx) {
15834
15926
  return {
15835
15927
  index: index,
15836
15928
  elements: [addedElements[elIdx]],
15837
15929
  hasDOMInElements: false
15838
15930
  };
15839
- }))));
15931
+ })));
15840
15932
  };
15841
15933
 
15842
15934
  var batchRemove = function (renderer, startIdx, endIdx) {
@@ -15861,16 +15953,16 @@ version: 4.4.2
15861
15953
  map[prev] = current;
15862
15954
  return map;
15863
15955
  }, {});
15864
- return __spreadArray(__spreadArray([], __read$1(flicking.panels.filter(function (panel) {
15956
+ return __spread$1(flicking.panels.filter(function (panel) {
15865
15957
  return !removedPanels[panel.index];
15866
15958
  }) // Sort panels by position
15867
15959
  .sort(function (panel1, panel2) {
15868
15960
  return panel1.position + panel1.offset - (panel2.position + panel2.offset);
15869
15961
  }).map(function (panel) {
15870
15962
  return diffResult.list[maintainedMap[panel.index]];
15871
- })), false), __read$1(diffResult.added.map(function (idx) {
15963
+ }), diffResult.added.map(function (idx) {
15872
15964
  return diffResult.list[idx];
15873
- })));
15965
+ }));
15874
15966
  });
15875
15967
 
15876
15968
  var getDefaultCameraTransform = (function (align, horizontal, firstPanelSize) {