@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.
@@ -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() :
@@ -1094,9 +1094,6 @@ version: 4.13.1
1094
1094
  };
1095
1095
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1096
1096
  var getStyle = function (el) {
1097
- if (!el) {
1098
- return {};
1099
- }
1100
1097
  return window.getComputedStyle(el) || el.currentStyle;
1101
1098
  };
1102
1099
  var setSize = function (el, _a) {
@@ -1404,59 +1401,13 @@ version: 4.13.1
1404
1401
  return Viewport;
1405
1402
  }();
1406
1403
 
1407
- /*
1408
- * Copyright (c) 2015 NAVER Corp.
1409
- * egjs projects are licensed under the MIT license
1410
- */
1411
- /**
1412
- * A component that detects size change and trigger resize method when the autoResize option is used
1413
- * @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
1414
- */
1415
1404
  var AutoResizer = /*#__PURE__*/function () {
1416
1405
  function AutoResizer(flicking) {
1417
1406
  var _this = this;
1418
- this._onResizeWrapper = function () {
1419
- _this._onResize([]);
1420
- };
1421
- this._onResize = function (entries) {
1407
+ this._onResize = function () {
1422
1408
  var flicking = _this._flicking;
1423
1409
  var resizeDebounce = flicking.resizeDebounce;
1424
1410
  var maxResizeDebounce = flicking.maxResizeDebounce;
1425
- var resizedViewportElement = flicking.element;
1426
- // 현재 구현에서 리사이즈 옵저빙 대상은 패널과 뷰포트 2개만 존재.
1427
- // 아래는 뷰포트만 변경되었을 때 동작해야하는 로직이 있으므로 아래와 같이 조건문을 건다.
1428
- // 패널 쪽에서는 리사이즈 감지에 resizeObserver를 사용하지 않는 경우가 없으므로 이 조건은 곧 뷰포트만 리사이즈가 된 경우를 의미한다.
1429
- var isResizedViewportOnly = entries.find(function (e) {
1430
- return e.target === flicking.element;
1431
- }) && entries.length === 1;
1432
- // 참고: resizeObserver를 사용하지 않은 경우에는 entries.length가 0으로 오는데 이 경우에는 그냥 항상 리사이즈가 진행되도록 한다.
1433
- // (vw, vh 등을 사용하는 경우 이상 동작이 발생할 여지가 있기 때문이다)
1434
- if (isResizedViewportOnly) {
1435
- // resize 이벤트가 발생했으나 이전과 width, height의 변화가 없다면 이후 로직을 진행하지 않는다.
1436
- var beforeSize = {
1437
- width: flicking.viewport.width,
1438
- height: flicking.viewport.height
1439
- };
1440
- var afterSize = {
1441
- width: getElementSize({
1442
- el: resizedViewportElement,
1443
- horizontal: true,
1444
- useFractionalSize: _this._flicking.useFractionalSize,
1445
- useOffset: false,
1446
- style: getStyle(resizedViewportElement)
1447
- }),
1448
- height: getElementSize({
1449
- el: resizedViewportElement,
1450
- horizontal: false,
1451
- useFractionalSize: _this._flicking.useFractionalSize,
1452
- useOffset: false,
1453
- style: getStyle(resizedViewportElement)
1454
- })
1455
- };
1456
- if (beforeSize.height === afterSize.height && beforeSize.width === afterSize.width) {
1457
- return;
1458
- }
1459
- }
1460
1411
  if (resizeDebounce <= 0) {
1461
1412
  void flicking.resize();
1462
1413
  } else {
@@ -1482,12 +1433,12 @@ version: 4.13.1
1482
1433
  // eslint-disable-next-line @typescript-eslint/member-ordering
1483
1434
  this._skipFirstResize = function () {
1484
1435
  var isFirstResize = true;
1485
- return function (entries) {
1436
+ return function () {
1486
1437
  if (isFirstResize) {
1487
1438
  isFirstResize = false;
1488
1439
  return;
1489
1440
  }
1490
- _this._onResize(entries);
1441
+ _this._onResize();
1491
1442
  };
1492
1443
  }();
1493
1444
  this._flicking = flicking;
@@ -1513,46 +1464,14 @@ version: 4.13.1
1513
1464
  if (flicking.useResizeObserver && !!window.ResizeObserver) {
1514
1465
  var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
1515
1466
  var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
1467
+ resizeObserver.observe(flicking.viewport.element);
1516
1468
  this._resizeObserver = resizeObserver;
1517
- this.observe(flicking.viewport.element);
1518
- if (flicking.observePanelResize) {
1519
- this.observePanels();
1520
- }
1521
1469
  } else {
1522
- window.addEventListener("resize", this._onResizeWrapper);
1470
+ window.addEventListener("resize", this._onResize);
1523
1471
  }
1524
1472
  this._enabled = true;
1525
1473
  return this;
1526
1474
  };
1527
- __proto.observePanels = function () {
1528
- var _this = this;
1529
- this._flicking.panels.forEach(function (panel) {
1530
- _this.observe(panel.element);
1531
- });
1532
- return this;
1533
- };
1534
- __proto.unobservePanels = function () {
1535
- var _this = this;
1536
- this._flicking.panels.forEach(function (panel) {
1537
- _this.unobserve(panel.element);
1538
- });
1539
- return this;
1540
- };
1541
- __proto.observe = function (element) {
1542
- var resizeObserver = this._resizeObserver;
1543
- if (!resizeObserver) return this;
1544
- resizeObserver.observe(element);
1545
- return this;
1546
- };
1547
- __proto.unobserve = function (element) {
1548
- var resizeObserver = this._resizeObserver;
1549
- if (!resizeObserver) return this;
1550
- resizeObserver.unobserve(element);
1551
- if (this._flicking.observePanelResize) {
1552
- this.unobservePanels();
1553
- }
1554
- return this;
1555
- };
1556
1475
  __proto.disable = function () {
1557
1476
  if (!this._enabled) return this;
1558
1477
  var resizeObserver = this._resizeObserver;
@@ -1560,7 +1479,7 @@ version: 4.13.1
1560
1479
  resizeObserver.disconnect();
1561
1480
  this._resizeObserver = null;
1562
1481
  } else {
1563
- window.removeEventListener("resize", this._onResizeWrapper);
1482
+ window.removeEventListener("resize", this._onResize);
1564
1483
  }
1565
1484
  this._enabled = false;
1566
1485
  return this;
@@ -2779,7 +2698,7 @@ version: 4.13.1
2779
2698
  license: MIT
2780
2699
  author: NAVER Corp.
2781
2700
  repository: https://github.com/naver/egjs-axes
2782
- version: 3.9.1
2701
+ version: 3.9.2
2783
2702
  */
2784
2703
 
2785
2704
  /*! *****************************************************************************
@@ -3705,6 +3624,19 @@ version: 4.13.1
3705
3624
  var deltaTime = latestInterval ? timeStamp - latestInterval.timestamp : 0;
3706
3625
  var velocityX = prevEvent ? prevEvent.velocityX : 0;
3707
3626
  var velocityY = prevEvent ? prevEvent.velocityY : 0;
3627
+ var directionX = prevEvent ? prevEvent.directionX : 1;
3628
+ var directionY = prevEvent ? prevEvent.directionY : 1;
3629
+ // If offset is 0, it inherits the direction of the previous event.
3630
+ if (offsetX > 0) {
3631
+ directionX = 1;
3632
+ } else if (offsetX < 0) {
3633
+ directionX = -1;
3634
+ }
3635
+ if (offsetY > 0) {
3636
+ directionY = 1;
3637
+ } else if (offsetY < 0) {
3638
+ directionY = -1;
3639
+ }
3708
3640
  if (!latestInterval || deltaTime >= VELOCITY_INTERVAL) {
3709
3641
  if (latestInterval) {
3710
3642
  _a = [(deltaX - latestInterval.deltaX) / deltaTime, (deltaY - latestInterval.deltaY) / deltaTime], velocityX = _a[0], velocityY = _a[1];
@@ -3724,6 +3656,8 @@ version: 4.13.1
3724
3656
  deltaY: deltaY,
3725
3657
  offsetX: offsetX,
3726
3658
  offsetY: offsetY,
3659
+ directionX: directionX,
3660
+ directionY: directionY,
3727
3661
  velocityX: velocityX,
3728
3662
  velocityY: velocityY,
3729
3663
  preventSystemEvent: true
@@ -5187,7 +5121,7 @@ version: 4.13.1
5187
5121
  * eg.Axes.VERSION; // ex) 3.3.3
5188
5122
  * ```
5189
5123
  */
5190
- Axes.VERSION = "3.9.1";
5124
+ Axes.VERSION = "3.9.2";
5191
5125
  /* eslint-enable */
5192
5126
  /**
5193
5127
  * @name TRANSFORM
@@ -5538,7 +5472,7 @@ version: 4.13.1
5538
5472
  this._detachWindowEvent(activeEvent);
5539
5473
  clearTimeout(this._rightEdgeTimer);
5540
5474
  var prevEvent = activeEvent.prevEvent;
5541
- var velocity = this._isOverThreshold ? this._getOffset([Math.abs(prevEvent.velocityX) * (prevEvent.offsetX < 0 ? -1 : 1), Math.abs(prevEvent.velocityY) * (prevEvent.offsetY < 0 ? -1 : 1)], [useDirection(DIRECTION_HORIZONTAL, this._direction), useDirection(DIRECTION_VERTICAL, this._direction)]) : [0, 0];
5475
+ var velocity = this._isOverThreshold ? this._getOffset([Math.abs(prevEvent.velocityX) * prevEvent.directionX, Math.abs(prevEvent.velocityY) * prevEvent.directionY], [useDirection(DIRECTION_HORIZONTAL, this._direction), useDirection(DIRECTION_VERTICAL, this._direction)]) : [0, 0];
5542
5476
  activeEvent.onRelease();
5543
5477
  this._observer.release(this, prevEvent, velocity);
5544
5478
  };
@@ -7209,7 +7143,11 @@ version: 4.13.1
7209
7143
  if (snapDelta >= snapThreshold && snapDelta > 0) {
7210
7144
  // Move to anchor at position
7211
7145
  targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
7212
- } else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
7146
+ // const targetPanel = targetAnchor.panel;
7147
+ // const nextPosition = this._getPosition(targetPanel, DIRECTION.NEXT);
7148
+ // const prevPosition = this._getPosition(targetPanel, DIRECTION.PREV);
7149
+ // targetPosition = Math.abs(camera.position - nextPosition) < Math.abs(camera.position - prevPosition) ? nextPosition : prevPosition;
7150
+ } else if (absPosDelta >= flicking.threshold && absPosDelta > 0 && anchorAtCamera === activeAnchor) {
7213
7151
  // Move to the adjacent panel
7214
7152
  targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
7215
7153
  } else {
@@ -7237,6 +7175,7 @@ version: 4.13.1
7237
7175
  if (!anchorAtCamera || !anchorAtPosition) {
7238
7176
  throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE);
7239
7177
  }
7178
+ // console.log("_findSnappedAnchor", anchorAtPosition);
7240
7179
  if (!isFinite(count)) {
7241
7180
  return anchorAtPosition;
7242
7181
  }
@@ -7678,10 +7617,7 @@ version: 4.13.1
7678
7617
  };
7679
7618
  __proto.findAnchorIncludePosition = function (position) {
7680
7619
  var anchors = this._flicking.camera.anchorPoints;
7681
- var anchorsIncludingPosition = anchors.filter(function (anchor) {
7682
- return anchor.panel.includePosition(position, true);
7683
- });
7684
- return anchorsIncludingPosition.reduce(function (nearest, anchor) {
7620
+ return anchors.reduce(function (nearest, anchor) {
7685
7621
  if (!nearest) return anchor;
7686
7622
  return Math.abs(nearest.position - position) < Math.abs(anchor.position - position) ? nearest : anchor;
7687
7623
  }, null);
@@ -10020,18 +9956,6 @@ version: 4.13.1
10020
9956
  var activePanel = control.activePanel;
10021
9957
  // Update camera & control
10022
9958
  this._updateCameraAndControl();
10023
- if (flicking.autoResize && flicking.useResizeObserver) {
10024
- panelsAdded.forEach(function (panel) {
10025
- if (panel.element) {
10026
- flicking.autoResizer.observe(panel.element);
10027
- }
10028
- });
10029
- panelsRemoved.forEach(function (panel) {
10030
- if (panel.element) {
10031
- flicking.autoResizer.unobserve(panel.element);
10032
- }
10033
- });
10034
- }
10035
9959
  void this.render();
10036
9960
  if (!flicking.animating) {
10037
9961
  if (!activePanel || activePanel.removed) {
@@ -11323,23 +11247,18 @@ version: 4.13.1
11323
11247
  useResizeObserver = _9 === void 0 ? true : _9,
11324
11248
  _10 = _b.resizeDebounce,
11325
11249
  resizeDebounce = _10 === void 0 ? 0 : _10,
11326
- _11 = _b.observePanelResize,
11327
- observePanelResize = _11 === void 0 ? false : _11,
11328
- _12 = _b.maxResizeDebounce,
11329
- maxResizeDebounce = _12 === void 0 ? 100 : _12,
11330
- _13 = _b.useFractionalSize,
11331
- useFractionalSize = _13 === void 0 ? false : _13,
11332
- _14 = _b.externalRenderer,
11333
- externalRenderer = _14 === void 0 ? null : _14,
11334
- _15 = _b.renderExternal,
11335
- renderExternal = _15 === void 0 ? null : _15,
11336
- _16 = _b.optimizeSizeUpdate,
11337
- optimizeSizeUpdate = _16 === void 0 ? false : _16;
11250
+ _11 = _b.maxResizeDebounce,
11251
+ maxResizeDebounce = _11 === void 0 ? 100 : _11,
11252
+ _12 = _b.useFractionalSize,
11253
+ useFractionalSize = _12 === void 0 ? false : _12,
11254
+ _13 = _b.externalRenderer,
11255
+ externalRenderer = _13 === void 0 ? null : _13,
11256
+ _14 = _b.renderExternal,
11257
+ renderExternal = _14 === void 0 ? null : _14;
11338
11258
  var _this = _super.call(this) || this;
11339
11259
  // Internal states
11340
11260
  _this._initialized = false;
11341
11261
  _this._plugins = [];
11342
- _this._isResizing = false;
11343
11262
  // Bind options
11344
11263
  _this._align = align;
11345
11264
  _this._defaultIndex = defaultIndex;
@@ -11375,11 +11294,9 @@ version: 4.13.1
11375
11294
  _this._useResizeObserver = useResizeObserver;
11376
11295
  _this._resizeDebounce = resizeDebounce;
11377
11296
  _this._maxResizeDebounce = maxResizeDebounce;
11378
- _this._observePanelResize = observePanelResize;
11379
11297
  _this._useFractionalSize = useFractionalSize;
11380
11298
  _this._externalRenderer = externalRenderer;
11381
11299
  _this._renderExternal = renderExternal;
11382
- _this._optimizeSizeUpdate = optimizeSizeUpdate;
11383
11300
  // Create core components
11384
11301
  _this._viewport = new Viewport(_this, getElement(root));
11385
11302
  _this._autoResizer = new AutoResizer(_this);
@@ -11460,19 +11377,6 @@ version: 4.13.1
11460
11377
  enumerable: false,
11461
11378
  configurable: true
11462
11379
  });
11463
- Object.defineProperty(__proto, "autoResizer", {
11464
- /**
11465
- * {@link AutoResizer} instance of the Flicking
11466
- * @ko 현재 Flicking에 활성화된 {@link AutoResizer} 인스턴스
11467
- * @internal
11468
- * @readonly
11469
- */
11470
- get: function () {
11471
- return this._autoResizer;
11472
- },
11473
- enumerable: false,
11474
- configurable: true
11475
- });
11476
11380
  Object.defineProperty(__proto, "initialized", {
11477
11381
  // Internal States
11478
11382
  /**
@@ -12346,9 +12250,6 @@ version: 4.13.1
12346
12250
  // OTHERS
12347
12251
  set: function (val) {
12348
12252
  this._autoResize = val;
12349
- if (!this._initialized) {
12350
- return;
12351
- }
12352
12253
  if (val) {
12353
12254
  this._autoResizer.enable();
12354
12255
  } else {
@@ -12371,38 +12272,13 @@ version: 4.13.1
12371
12272
  },
12372
12273
  set: function (val) {
12373
12274
  this._useResizeObserver = val;
12374
- if (this._initialized && this._autoResize) {
12275
+ if (this._autoResize) {
12375
12276
  this._autoResizer.enable();
12376
12277
  }
12377
12278
  },
12378
12279
  enumerable: false,
12379
12280
  configurable: true
12380
12281
  });
12381
- Object.defineProperty(__proto, "observePanelResize", {
12382
- /**
12383
- * Whether to use {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver} to observe the size of the panel element
12384
- * This is only available when `useResizeObserver` is enabled.
12385
- * This option garantees that the resize event is triggered when the size of the panel element is changed.
12386
- * @ko 이 옵션을 활성화할 경우, {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}를 사용하여 패널 엘리먼트의 크기를 추적합니다.
12387
- * 이 옵션은 `useResizeObserver` 옵션이 활성화된 경우에만 사용할 수 있습니다.
12388
- * 이 옵션은 패널 엘리먼트의 크기가 변경될 경우 resize 이벤트가 발생하도록 보장합니다.
12389
- */
12390
- get: function () {
12391
- return this._observePanelResize;
12392
- },
12393
- set: function (val) {
12394
- this._observePanelResize = val;
12395
- if (this._initialized && this._autoResize) {
12396
- if (val) {
12397
- this._autoResizer.observePanels();
12398
- } else {
12399
- this._autoResizer.unobservePanels();
12400
- }
12401
- }
12402
- },
12403
- enumerable: false,
12404
- configurable: true
12405
- });
12406
12282
  Object.defineProperty(__proto, "resizeDebounce", {
12407
12283
  /**
12408
12284
  * Delays size recalculation from `autoResize` by the given time in milisecond.
@@ -12484,30 +12360,6 @@ version: 4.13.1
12484
12360
  enumerable: false,
12485
12361
  configurable: true
12486
12362
  });
12487
- Object.defineProperty(__proto, "optimizeSizeUpdate", {
12488
- /**
12489
- * This option works only when autoResize is set to true.
12490
- * By default, autoResize listens to changes in both the viewport's width and height, updating all panel sizes accordingly.
12491
- * When optimizeSizeUpdate is enabled, the update behavior is optimized based on the flicking direction:
12492
- * If direction is "horizontal", only changes in width will trigger panel size updates.
12493
- * If direction is "vertical", only changes in height will do so.
12494
- * 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.
12495
- * @ko optimizeSizeUpdate는 autoResize가 true일 때만 동작합니다.
12496
- * 기본적으로 autoResize는 뷰포트의 width와 height 변화를 모두 감지하여 패널들의 사이즈를 업데이트합니다.
12497
- * 이 옵션을 활성화하면 플리킹 방향에 따라 필요한 차원(horizontal → width, vertical → height)에 대해서만 사이즈를 업데이트합니다.
12498
- * 내부 패널의 높이가 서로 다를 때, 플리킹 중 과도한 리사이징으로 인한 깜빡임 현상을 줄이는 데 유용합니다.
12499
- * @type {boolean}
12500
- * @default false
12501
- */
12502
- get: function () {
12503
- return this._optimizeSizeUpdate;
12504
- },
12505
- set: function (val) {
12506
- this._optimizeSizeUpdate = val;
12507
- },
12508
- enumerable: false,
12509
- configurable: true
12510
- });
12511
12363
  /**
12512
12364
  * Initialize Flicking and move to the default index
12513
12365
  * This is automatically called on Flicking's constructor when `autoInit` is true(default)
@@ -12946,8 +12798,6 @@ version: 4.13.1
12946
12798
  return __generator(this, function (_a) {
12947
12799
  switch (_a.label) {
12948
12800
  case 0:
12949
- if (this._isResizing) return [2 /*return*/];
12950
- this._isResizing = true;
12951
12801
  viewport = this._viewport;
12952
12802
  renderer = this._renderer;
12953
12803
  camera = this._camera;
@@ -12962,20 +12812,9 @@ version: 4.13.1
12962
12812
  element: viewport.element
12963
12813
  }));
12964
12814
  viewport.resize();
12965
- if (!this._optimizeSizeUpdate) return [3 /*break*/, 3];
12966
- if (!(this.horizontal && viewport.width !== prevWidth || !this.horizontal && viewport.height !== prevHeight)) return [3 /*break*/, 2];
12967
12815
  return [4 /*yield*/, renderer.forceRenderAllPanels()];
12968
12816
  case 1:
12969
- _a.sent();
12970
- _a.label = 2;
12971
- case 2:
12972
- return [3 /*break*/, 5];
12973
- case 3:
12974
- return [4 /*yield*/, renderer.forceRenderAllPanels()];
12975
- case 4:
12976
12817
  _a.sent(); // Render all panel elements, to update sizes
12977
- _a.label = 5;
12978
- case 5:
12979
12818
  if (!this._initialized) {
12980
12819
  return [2 /*return*/];
12981
12820
  }
@@ -12988,7 +12827,7 @@ version: 4.13.1
12988
12827
  camera.updatePanelOrder();
12989
12828
  camera.updateOffset();
12990
12829
  return [4 /*yield*/, renderer.render()];
12991
- case 6:
12830
+ case 2:
12992
12831
  _a.sent();
12993
12832
  if (!this._initialized) {
12994
12833
  return [2 /*return*/];
@@ -13011,7 +12850,6 @@ version: 4.13.1
13011
12850
  sizeChanged: sizeChanged,
13012
12851
  element: viewport.element
13013
12852
  }));
13014
- this._isResizing = false;
13015
12853
  return [2 /*return*/];
13016
12854
  }
13017
12855
  });
@@ -13231,7 +13069,7 @@ version: 4.13.1
13231
13069
  * Flicking.VERSION; // ex) 4.0.0
13232
13070
  * ```
13233
13071
  */
13234
- Flicking.VERSION = "4.13.1";
13072
+ Flicking.VERSION = "4.13.2-beta.0";
13235
13073
  return Flicking;
13236
13074
  }(Component);
13237
13075