@egjs/flicking 4.13.1 → 4.13.2-beta.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.
package/dist/flicking.js CHANGED
@@ -4,7 +4,7 @@ name: @egjs/flicking
4
4
  license: MIT
5
5
  author: NAVER Corp.
6
6
  repository: https://github.com/naver/egjs-flicking
7
- version: 4.13.1
7
+ version: 4.13.2-beta.0
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@egjs/component'), require('@egjs/axes'), require('@egjs/imready')) :
@@ -687,9 +687,6 @@ version: 4.13.1
687
687
  };
688
688
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
689
689
  var getStyle = function (el) {
690
- if (!el) {
691
- return {};
692
- }
693
690
  return window.getComputedStyle(el) || el.currentStyle;
694
691
  };
695
692
  var setSize = function (el, _a) {
@@ -997,59 +994,13 @@ version: 4.13.1
997
994
  return Viewport;
998
995
  }();
999
996
 
1000
- /*
1001
- * Copyright (c) 2015 NAVER Corp.
1002
- * egjs projects are licensed under the MIT license
1003
- */
1004
- /**
1005
- * A component that detects size change and trigger resize method when the autoResize option is used
1006
- * @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
1007
- */
1008
997
  var AutoResizer = /*#__PURE__*/function () {
1009
998
  function AutoResizer(flicking) {
1010
999
  var _this = this;
1011
- this._onResizeWrapper = function () {
1012
- _this._onResize([]);
1013
- };
1014
- this._onResize = function (entries) {
1000
+ this._onResize = function () {
1015
1001
  var flicking = _this._flicking;
1016
1002
  var resizeDebounce = flicking.resizeDebounce;
1017
1003
  var maxResizeDebounce = flicking.maxResizeDebounce;
1018
- var resizedViewportElement = flicking.element;
1019
- // 현재 구현에서 리사이즈 옵저빙 대상은 패널과 뷰포트 2개만 존재.
1020
- // 아래는 뷰포트만 변경되었을 때 동작해야하는 로직이 있으므로 아래와 같이 조건문을 건다.
1021
- // 패널 쪽에서는 리사이즈 감지에 resizeObserver를 사용하지 않는 경우가 없으므로 이 조건은 곧 뷰포트만 리사이즈가 된 경우를 의미한다.
1022
- var isResizedViewportOnly = entries.find(function (e) {
1023
- return e.target === flicking.element;
1024
- }) && entries.length === 1;
1025
- // 참고: resizeObserver를 사용하지 않은 경우에는 entries.length가 0으로 오는데 이 경우에는 그냥 항상 리사이즈가 진행되도록 한다.
1026
- // (vw, vh 등을 사용하는 경우 이상 동작이 발생할 여지가 있기 때문이다)
1027
- if (isResizedViewportOnly) {
1028
- // resize 이벤트가 발생했으나 이전과 width, height의 변화가 없다면 이후 로직을 진행하지 않는다.
1029
- var beforeSize = {
1030
- width: flicking.viewport.width,
1031
- height: flicking.viewport.height
1032
- };
1033
- var afterSize = {
1034
- width: getElementSize({
1035
- el: resizedViewportElement,
1036
- horizontal: true,
1037
- useFractionalSize: _this._flicking.useFractionalSize,
1038
- useOffset: false,
1039
- style: getStyle(resizedViewportElement)
1040
- }),
1041
- height: getElementSize({
1042
- el: resizedViewportElement,
1043
- horizontal: false,
1044
- useFractionalSize: _this._flicking.useFractionalSize,
1045
- useOffset: false,
1046
- style: getStyle(resizedViewportElement)
1047
- })
1048
- };
1049
- if (beforeSize.height === afterSize.height && beforeSize.width === afterSize.width) {
1050
- return;
1051
- }
1052
- }
1053
1004
  if (resizeDebounce <= 0) {
1054
1005
  void flicking.resize();
1055
1006
  } else {
@@ -1075,12 +1026,12 @@ version: 4.13.1
1075
1026
  // eslint-disable-next-line @typescript-eslint/member-ordering
1076
1027
  this._skipFirstResize = function () {
1077
1028
  var isFirstResize = true;
1078
- return function (entries) {
1029
+ return function () {
1079
1030
  if (isFirstResize) {
1080
1031
  isFirstResize = false;
1081
1032
  return;
1082
1033
  }
1083
- _this._onResize(entries);
1034
+ _this._onResize();
1084
1035
  };
1085
1036
  }();
1086
1037
  this._flicking = flicking;
@@ -1106,46 +1057,14 @@ version: 4.13.1
1106
1057
  if (flicking.useResizeObserver && !!window.ResizeObserver) {
1107
1058
  var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
1108
1059
  var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
1060
+ resizeObserver.observe(flicking.viewport.element);
1109
1061
  this._resizeObserver = resizeObserver;
1110
- this.observe(flicking.viewport.element);
1111
- if (flicking.observePanelResize) {
1112
- this.observePanels();
1113
- }
1114
1062
  } else {
1115
- window.addEventListener("resize", this._onResizeWrapper);
1063
+ window.addEventListener("resize", this._onResize);
1116
1064
  }
1117
1065
  this._enabled = true;
1118
1066
  return this;
1119
1067
  };
1120
- __proto.observePanels = function () {
1121
- var _this = this;
1122
- this._flicking.panels.forEach(function (panel) {
1123
- _this.observe(panel.element);
1124
- });
1125
- return this;
1126
- };
1127
- __proto.unobservePanels = function () {
1128
- var _this = this;
1129
- this._flicking.panels.forEach(function (panel) {
1130
- _this.unobserve(panel.element);
1131
- });
1132
- return this;
1133
- };
1134
- __proto.observe = function (element) {
1135
- var resizeObserver = this._resizeObserver;
1136
- if (!resizeObserver) return this;
1137
- resizeObserver.observe(element);
1138
- return this;
1139
- };
1140
- __proto.unobserve = function (element) {
1141
- var resizeObserver = this._resizeObserver;
1142
- if (!resizeObserver) return this;
1143
- resizeObserver.unobserve(element);
1144
- if (this._flicking.observePanelResize) {
1145
- this.unobservePanels();
1146
- }
1147
- return this;
1148
- };
1149
1068
  __proto.disable = function () {
1150
1069
  if (!this._enabled) return this;
1151
1070
  var resizeObserver = this._resizeObserver;
@@ -1153,7 +1072,7 @@ version: 4.13.1
1153
1072
  resizeObserver.disconnect();
1154
1073
  this._resizeObserver = null;
1155
1074
  } else {
1156
- window.removeEventListener("resize", this._onResizeWrapper);
1075
+ window.removeEventListener("resize", this._onResize);
1157
1076
  }
1158
1077
  this._enabled = false;
1159
1078
  return this;
@@ -3044,7 +2963,11 @@ version: 4.13.1
3044
2963
  if (snapDelta >= snapThreshold && snapDelta > 0) {
3045
2964
  // Move to anchor at position
3046
2965
  targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
3047
- } else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
2966
+ // const targetPanel = targetAnchor.panel;
2967
+ // const nextPosition = this._getPosition(targetPanel, DIRECTION.NEXT);
2968
+ // const prevPosition = this._getPosition(targetPanel, DIRECTION.PREV);
2969
+ // targetPosition = Math.abs(camera.position - nextPosition) < Math.abs(camera.position - prevPosition) ? nextPosition : prevPosition;
2970
+ } else if (absPosDelta >= flicking.threshold && absPosDelta > 0 && anchorAtCamera === activeAnchor) {
3048
2971
  // Move to the adjacent panel
3049
2972
  targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
3050
2973
  } else {
@@ -3072,6 +2995,7 @@ version: 4.13.1
3072
2995
  if (!anchorAtCamera || !anchorAtPosition) {
3073
2996
  throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE);
3074
2997
  }
2998
+ // console.log("_findSnappedAnchor", anchorAtPosition);
3075
2999
  if (!isFinite(count)) {
3076
3000
  return anchorAtPosition;
3077
3001
  }
@@ -3513,10 +3437,7 @@ version: 4.13.1
3513
3437
  };
3514
3438
  __proto.findAnchorIncludePosition = function (position) {
3515
3439
  var anchors = this._flicking.camera.anchorPoints;
3516
- var anchorsIncludingPosition = anchors.filter(function (anchor) {
3517
- return anchor.panel.includePosition(position, true);
3518
- });
3519
- return anchorsIncludingPosition.reduce(function (nearest, anchor) {
3440
+ return anchors.reduce(function (nearest, anchor) {
3520
3441
  if (!nearest) return anchor;
3521
3442
  return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
3522
3443
  }, null);
@@ -4985,18 +4906,6 @@ version: 4.13.1
4985
4906
  var activePanel = control.activePanel;
4986
4907
  // Update camera & control
4987
4908
  this._updateCameraAndControl();
4988
- if (flicking.autoResize && flicking.useResizeObserver) {
4989
- panelsAdded.forEach(function (panel) {
4990
- if (panel.element) {
4991
- flicking.autoResizer.observe(panel.element);
4992
- }
4993
- });
4994
- panelsRemoved.forEach(function (panel) {
4995
- if (panel.element) {
4996
- flicking.autoResizer.unobserve(panel.element);
4997
- }
4998
- });
4999
- }
5000
4909
  void this.render();
5001
4910
  if (!flicking.animating) {
5002
4911
  if (!activePanel || activePanel.removed) {
@@ -6288,23 +6197,18 @@ version: 4.13.1
6288
6197
  useResizeObserver = _9 === void 0 ? true : _9,
6289
6198
  _10 = _b.resizeDebounce,
6290
6199
  resizeDebounce = _10 === void 0 ? 0 : _10,
6291
- _11 = _b.observePanelResize,
6292
- observePanelResize = _11 === void 0 ? false : _11,
6293
- _12 = _b.maxResizeDebounce,
6294
- maxResizeDebounce = _12 === void 0 ? 100 : _12,
6295
- _13 = _b.useFractionalSize,
6296
- useFractionalSize = _13 === void 0 ? false : _13,
6297
- _14 = _b.externalRenderer,
6298
- externalRenderer = _14 === void 0 ? null : _14,
6299
- _15 = _b.renderExternal,
6300
- renderExternal = _15 === void 0 ? null : _15,
6301
- _16 = _b.optimizeSizeUpdate,
6302
- optimizeSizeUpdate = _16 === void 0 ? false : _16;
6200
+ _11 = _b.maxResizeDebounce,
6201
+ maxResizeDebounce = _11 === void 0 ? 100 : _11,
6202
+ _12 = _b.useFractionalSize,
6203
+ useFractionalSize = _12 === void 0 ? false : _12,
6204
+ _13 = _b.externalRenderer,
6205
+ externalRenderer = _13 === void 0 ? null : _13,
6206
+ _14 = _b.renderExternal,
6207
+ renderExternal = _14 === void 0 ? null : _14;
6303
6208
  var _this = _super.call(this) || this;
6304
6209
  // Internal states
6305
6210
  _this._initialized = false;
6306
6211
  _this._plugins = [];
6307
- _this._isResizing = false;
6308
6212
  // Bind options
6309
6213
  _this._align = align;
6310
6214
  _this._defaultIndex = defaultIndex;
@@ -6340,11 +6244,9 @@ version: 4.13.1
6340
6244
  _this._useResizeObserver = useResizeObserver;
6341
6245
  _this._resizeDebounce = resizeDebounce;
6342
6246
  _this._maxResizeDebounce = maxResizeDebounce;
6343
- _this._observePanelResize = observePanelResize;
6344
6247
  _this._useFractionalSize = useFractionalSize;
6345
6248
  _this._externalRenderer = externalRenderer;
6346
6249
  _this._renderExternal = renderExternal;
6347
- _this._optimizeSizeUpdate = optimizeSizeUpdate;
6348
6250
  // Create core components
6349
6251
  _this._viewport = new Viewport(_this, getElement(root));
6350
6252
  _this._autoResizer = new AutoResizer(_this);
@@ -6425,19 +6327,6 @@ version: 4.13.1
6425
6327
  enumerable: false,
6426
6328
  configurable: true
6427
6329
  });
6428
- Object.defineProperty(__proto, "autoResizer", {
6429
- /**
6430
- * {@link AutoResizer} instance of the Flicking
6431
- * @ko 현재 Flicking에 활성화된 {@link AutoResizer} 인스턴스
6432
- * @internal
6433
- * @readonly
6434
- */
6435
- get: function () {
6436
- return this._autoResizer;
6437
- },
6438
- enumerable: false,
6439
- configurable: true
6440
- });
6441
6330
  Object.defineProperty(__proto, "initialized", {
6442
6331
  // Internal States
6443
6332
  /**
@@ -7311,9 +7200,6 @@ version: 4.13.1
7311
7200
  // OTHERS
7312
7201
  set: function (val) {
7313
7202
  this._autoResize = val;
7314
- if (!this._initialized) {
7315
- return;
7316
- }
7317
7203
  if (val) {
7318
7204
  this._autoResizer.enable();
7319
7205
  } else {
@@ -7336,38 +7222,13 @@ version: 4.13.1
7336
7222
  },
7337
7223
  set: function (val) {
7338
7224
  this._useResizeObserver = val;
7339
- if (this._initialized && this._autoResize) {
7225
+ if (this._autoResize) {
7340
7226
  this._autoResizer.enable();
7341
7227
  }
7342
7228
  },
7343
7229
  enumerable: false,
7344
7230
  configurable: true
7345
7231
  });
7346
- Object.defineProperty(__proto, "observePanelResize", {
7347
- /**
7348
- * Whether to use {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver} to observe the size of the panel element
7349
- * This is only available when `useResizeObserver` is enabled.
7350
- * This option garantees that the resize event is triggered when the size of the panel element is changed.
7351
- * @ko 이 옵션을 활성화할 경우, {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}를 사용하여 패널 엘리먼트의 크기를 추적합니다.
7352
- * 이 옵션은 `useResizeObserver` 옵션이 활성화된 경우에만 사용할 수 있습니다.
7353
- * 이 옵션은 패널 엘리먼트의 크기가 변경될 경우 resize 이벤트가 발생하도록 보장합니다.
7354
- */
7355
- get: function () {
7356
- return this._observePanelResize;
7357
- },
7358
- set: function (val) {
7359
- this._observePanelResize = val;
7360
- if (this._initialized && this._autoResize) {
7361
- if (val) {
7362
- this._autoResizer.observePanels();
7363
- } else {
7364
- this._autoResizer.unobservePanels();
7365
- }
7366
- }
7367
- },
7368
- enumerable: false,
7369
- configurable: true
7370
- });
7371
7232
  Object.defineProperty(__proto, "resizeDebounce", {
7372
7233
  /**
7373
7234
  * Delays size recalculation from `autoResize` by the given time in milisecond.
@@ -7449,30 +7310,6 @@ version: 4.13.1
7449
7310
  enumerable: false,
7450
7311
  configurable: true
7451
7312
  });
7452
- Object.defineProperty(__proto, "optimizeSizeUpdate", {
7453
- /**
7454
- * This option works only when autoResize is set to true.
7455
- * By default, autoResize listens to changes in both the viewport's width and height, updating all panel sizes accordingly.
7456
- * When optimizeSizeUpdate is enabled, the update behavior is optimized based on the flicking direction:
7457
- * If direction is "horizontal", only changes in width will trigger panel size updates.
7458
- * If direction is "vertical", only changes in height will do so.
7459
- * This option is useful when panel heights vary and unwanted flickering occurs due to frequent size recalculations during flicking. Enabling optimizeSizeUpdate prevents unnecessary updates and helps maintain visual stability.
7460
- * @ko optimizeSizeUpdate는 autoResize가 true일 때만 동작합니다.
7461
- * 기본적으로 autoResize는 뷰포트의 width와 height 변화를 모두 감지하여 패널들의 사이즈를 업데이트합니다.
7462
- * 이 옵션을 활성화하면 플리킹 방향에 따라 필요한 차원(horizontal → width, vertical → height)에 대해서만 사이즈를 업데이트합니다.
7463
- * 내부 패널의 높이가 서로 다를 때, 플리킹 중 과도한 리사이징으로 인한 깜빡임 현상을 줄이는 데 유용합니다.
7464
- * @type {boolean}
7465
- * @default false
7466
- */
7467
- get: function () {
7468
- return this._optimizeSizeUpdate;
7469
- },
7470
- set: function (val) {
7471
- this._optimizeSizeUpdate = val;
7472
- },
7473
- enumerable: false,
7474
- configurable: true
7475
- });
7476
7313
  /**
7477
7314
  * Initialize Flicking and move to the default index
7478
7315
  * This is automatically called on Flicking's constructor when `autoInit` is true(default)
@@ -7911,8 +7748,6 @@ version: 4.13.1
7911
7748
  return __generator(this, function (_a) {
7912
7749
  switch (_a.label) {
7913
7750
  case 0:
7914
- if (this._isResizing) return [2 /*return*/];
7915
- this._isResizing = true;
7916
7751
  viewport = this._viewport;
7917
7752
  renderer = this._renderer;
7918
7753
  camera = this._camera;
@@ -7927,20 +7762,9 @@ version: 4.13.1
7927
7762
  element: viewport.element
7928
7763
  }));
7929
7764
  viewport.resize();
7930
- if (!this._optimizeSizeUpdate) return [3 /*break*/, 3];
7931
- if (!(this.horizontal && viewport.width !== prevWidth || !this.horizontal && viewport.height !== prevHeight)) return [3 /*break*/, 2];
7932
7765
  return [4 /*yield*/, renderer.forceRenderAllPanels()];
7933
7766
  case 1:
7934
- _a.sent();
7935
- _a.label = 2;
7936
- case 2:
7937
- return [3 /*break*/, 5];
7938
- case 3:
7939
- return [4 /*yield*/, renderer.forceRenderAllPanels()];
7940
- case 4:
7941
7767
  _a.sent(); // Render all panel elements, to update sizes
7942
- _a.label = 5;
7943
- case 5:
7944
7768
  if (!this._initialized) {
7945
7769
  return [2 /*return*/];
7946
7770
  }
@@ -7953,7 +7777,7 @@ version: 4.13.1
7953
7777
  camera.updatePanelOrder();
7954
7778
  camera.updateOffset();
7955
7779
  return [4 /*yield*/, renderer.render()];
7956
- case 6:
7780
+ case 2:
7957
7781
  _a.sent();
7958
7782
  if (!this._initialized) {
7959
7783
  return [2 /*return*/];
@@ -7976,7 +7800,6 @@ version: 4.13.1
7976
7800
  sizeChanged: sizeChanged,
7977
7801
  element: viewport.element
7978
7802
  }));
7979
- this._isResizing = false;
7980
7803
  return [2 /*return*/];
7981
7804
  }
7982
7805
  });
@@ -8196,7 +8019,7 @@ version: 4.13.1
8196
8019
  * Flicking.VERSION; // ex) 4.0.0
8197
8020
  * ```
8198
8021
  */
8199
- Flicking.VERSION = "4.13.1";
8022
+ Flicking.VERSION = "4.13.2-beta.0";
8200
8023
  return Flicking;
8201
8024
  }(Component);
8202
8025