@egjs/flicking 4.9.3 → 4.10.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.9.3
7
+ version: 4.10.0
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -2426,7 +2426,7 @@ version: 4.9.3
2426
2426
  license: MIT
2427
2427
  author: NAVER Corp.
2428
2428
  repository: https://github.com/naver/egjs-axes
2429
- version: 3.8.0
2429
+ version: 3.8.1
2430
2430
  */
2431
2431
 
2432
2432
  /*! *****************************************************************************
@@ -4548,6 +4548,8 @@ version: 4.9.3
4548
4548
  };
4549
4549
 
4550
4550
  __proto.updateAnimation = function (options) {
4551
+ var _a;
4552
+
4551
4553
  var animateParam = this._animateParam;
4552
4554
 
4553
4555
  if (!animateParam) {
@@ -4556,7 +4558,7 @@ version: 4.9.3
4556
4558
 
4557
4559
  var diffTime = new Date().getTime() - animateParam.startTime;
4558
4560
  var pos = (options === null || options === void 0 ? void 0 : options.destPos) || animateParam.destPos;
4559
- var duration = (options === null || options === void 0 ? void 0 : options.duration) || animateParam.duration;
4561
+ var duration = (_a = options === null || options === void 0 ? void 0 : options.duration) !== null && _a !== void 0 ? _a : animateParam.duration;
4560
4562
 
4561
4563
  if ((options === null || options === void 0 ? void 0 : options.restart) || duration <= diffTime) {
4562
4564
  this.setTo(pos, duration - diffTime);
@@ -5087,6 +5089,7 @@ version: 4.9.3
5087
5089
 
5088
5090
  __proto.stopAnimation = function () {
5089
5091
  this.animationManager.stopAnimation();
5092
+ this.animationManager.finish(false);
5090
5093
  return this;
5091
5094
  };
5092
5095
  /**
@@ -5176,7 +5179,7 @@ version: 4.9.3
5176
5179
  */
5177
5180
 
5178
5181
 
5179
- Axes.VERSION = "3.8.0";
5182
+ Axes.VERSION = "3.8.1";
5180
5183
  /* eslint-enable */
5181
5184
 
5182
5185
  /**
@@ -5288,7 +5291,7 @@ version: 4.9.3
5288
5291
  * @param {Number} [scale[1]=1] vertical axis scale <ko>수직축 배율</ko>
5289
5292
  * @param {Number} [thresholdAngle=45] The threshold value that determines whether user action is horizontal or vertical (0~90) <ko>사용자의 동작이 가로 방향인지 세로 방향인지 판단하는 기준 각도(0~90)</ko>
5290
5293
  * @param {Number} [threshold=0] Minimal pan distance required before recognizing <ko>사용자의 Pan 동작을 인식하기 위해산 최소한의 거리</ko>
5291
- * @param {Boolean} [preventClickOnDrag=false] Whether to cancel the {@link https://developer.mozilla.org/en/docs/Web/API/Element/click_event click} event when the user finishes dragging more than 1 pixel <ko>사용자가 1픽셀 이상 드래그를 마쳤을 때 {@link https://developer.mozilla.org/ko/docs/Web/API/Element/click_event click} 이벤트 취소 여부/ko>
5294
+ * @param {Boolean} [preventClickOnDrag=false] Whether to cancel the {@link https://developer.mozilla.org/en/docs/Web/API/Element/click_event click} event when the user finishes dragging more than 1 pixel <ko>사용자가 1픽셀 이상 드래그를 마쳤을 때 {@link https://developer.mozilla.org/ko/docs/Web/API/Element/click_event click} 이벤트 취소 여부</ko>
5292
5295
  * @param {Number} [iOSEdgeSwipeThreshold=30] Area (px) that can go to the next page when swiping the right edge in iOS safari <ko>iOS Safari에서 오른쪽 엣지를 스와이프 하는 경우 다음 페이지로 넘어갈 수 있는 영역(px)</ko>
5293
5296
  * @param {String} [touchAction=null] Value that overrides the element's "touch-action" css property. If set to null, it is automatically set to prevent scrolling in the direction of the connected axis. <ko>엘리먼트의 "touch-action" CSS 속성을 덮어쓰는 값. 만약 null로 설정된 경우, 연결된 축 방향으로의 스크롤을 방지하게끔 자동으로 설정된다.</ko>
5294
5297
  **/
@@ -5334,6 +5337,7 @@ version: 4.9.3
5334
5337
  this._atRightEdge = false;
5335
5338
  this._rightEdgeTimer = 0;
5336
5339
  this._dragged = false;
5340
+ this._isOverThreshold = false;
5337
5341
 
5338
5342
  this._preventClickWhenDragged = function (e) {
5339
5343
  if (_this._dragged) {
@@ -5468,6 +5472,7 @@ version: 4.9.3
5468
5472
  if (panEvent.srcEvent.cancelable !== false) {
5469
5473
  var edgeThreshold = this.options.iOSEdgeSwipeThreshold;
5470
5474
  this._dragged = false;
5475
+ this._isOverThreshold = false;
5471
5476
 
5472
5477
  this._observer.hold(this, panEvent);
5473
5478
 
@@ -5486,6 +5491,7 @@ version: 4.9.3
5486
5491
  iOSEdgeSwipeThreshold = _a.iOSEdgeSwipeThreshold,
5487
5492
  releaseOnScroll = _a.releaseOnScroll,
5488
5493
  inputButton = _a.inputButton,
5494
+ threshold = _a.threshold,
5489
5495
  thresholdAngle = _a.thresholdAngle;
5490
5496
  var activeEvent = this._activeEvent;
5491
5497
  var panEvent = activeEvent.onEventMove(event, inputButton);
@@ -5502,6 +5508,8 @@ version: 4.9.3
5502
5508
  }
5503
5509
 
5504
5510
  var userDirection = getDirectionByAngle(panEvent.angle, thresholdAngle);
5511
+ var useHorizontal = useDirection(DIRECTION_HORIZONTAL, this._direction, userDirection);
5512
+ var useVertical = useDirection(DIRECTION_VERTICAL, this._direction, userDirection);
5505
5513
 
5506
5514
  if (activeEvent.prevEvent && IS_IOS_SAFARI) {
5507
5515
  var swipeLeftToRight = panEvent.center.x < 0;
@@ -5526,7 +5534,9 @@ version: 4.9.3
5526
5534
  }
5527
5535
  }
5528
5536
 
5529
- var offset = this._getOffset([panEvent.offsetX, panEvent.offsetY], [useDirection(DIRECTION_HORIZONTAL, this._direction, userDirection), useDirection(DIRECTION_VERTICAL, this._direction, userDirection)]);
5537
+ var distance = this._getDistance([panEvent.deltaX, panEvent.deltaY], [useHorizontal, useVertical]);
5538
+
5539
+ var offset = this._getOffset([panEvent.offsetX, panEvent.offsetY], [useHorizontal, useVertical]);
5530
5540
 
5531
5541
  var prevent = offset.some(function (v) {
5532
5542
  return v !== 0;
@@ -5542,8 +5552,9 @@ version: 4.9.3
5542
5552
 
5543
5553
  panEvent.preventSystemEvent = prevent;
5544
5554
 
5545
- if (prevent) {
5555
+ if (prevent && (this._isOverThreshold || distance >= threshold)) {
5546
5556
  this._dragged = true;
5557
+ this._isOverThreshold = true;
5547
5558
 
5548
5559
  this._observer.change(this, panEvent, toAxis(this.axes, offset));
5549
5560
  }
@@ -5564,9 +5575,7 @@ version: 4.9.3
5564
5575
 
5565
5576
  clearTimeout(this._rightEdgeTimer);
5566
5577
  var prevEvent = activeEvent.prevEvent;
5567
-
5568
- var velocity = 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)]);
5569
-
5578
+ 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];
5570
5579
  activeEvent.onRelease();
5571
5580
 
5572
5581
  this._observer.release(this, prevEvent, velocity);
@@ -5603,6 +5612,10 @@ version: 4.9.3
5603
5612
  return [direction[0] ? properties[0] * scale[0] : 0, direction[1] ? properties[1] * scale[1] : 0];
5604
5613
  };
5605
5614
 
5615
+ __proto._getDistance = function (delta, direction) {
5616
+ return Math.sqrt(Number(direction[0]) * Math.pow(delta[0], 2) + Number(direction[1]) * Math.pow(delta[1], 2));
5617
+ };
5618
+
5606
5619
  __proto._attachElementEvent = function (observer) {
5607
5620
  var _this = this;
5608
5621
 
@@ -6403,10 +6416,6 @@ version: 4.9.3
6403
6416
  return StateMachine;
6404
6417
  }();
6405
6418
 
6406
- /*
6407
- * Copyright (c) 2015 NAVER Corp.
6408
- * egjs projects are licensed under the MIT license
6409
- */
6410
6419
  /**
6411
6420
  * A controller that handles the {@link https://naver.github.io/egjs-axes/ @egjs/axes} events
6412
6421
  * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 이벤트를 처리하는 컨트롤러 컴포넌트
@@ -6701,6 +6710,44 @@ version: 4.9.3
6701
6710
  (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.release();
6702
6711
  return this;
6703
6712
  };
6713
+ /**
6714
+ * Change the destination and duration of the animation currently playing
6715
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
6716
+ * @param {number} position A position to move<ko>이동할 좌표</ko>
6717
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
6718
+ * @chainable
6719
+ * @return {this}
6720
+ */
6721
+
6722
+
6723
+ __proto.updateAnimation = function (position, duration) {
6724
+ var _a;
6725
+
6726
+ var _b;
6727
+
6728
+ this._animatingContext = __assign$2(__assign$2({}, this._animatingContext), {
6729
+ end: position
6730
+ });
6731
+ (_b = this._axes) === null || _b === void 0 ? void 0 : _b.updateAnimation({
6732
+ destPos: (_a = {}, _a[POSITION_KEY] = position, _a),
6733
+ duration: duration
6734
+ });
6735
+ return this;
6736
+ };
6737
+ /**
6738
+ * Stops the animation currently playing
6739
+ * @ko 재생 중인 애니메이션을 중단시킵니다
6740
+ * @chainable
6741
+ * @return {this}
6742
+ */
6743
+
6744
+
6745
+ __proto.stopAnimation = function () {
6746
+ var _a;
6747
+
6748
+ (_a = this._axes) === null || _a === void 0 ? void 0 : _a.stopAnimation();
6749
+ return this;
6750
+ };
6704
6751
  /**
6705
6752
  * Update {@link https://naver.github.io/egjs-axes/ @egjs/axes}'s state
6706
6753
  * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 상태를 갱신합니다
@@ -7025,6 +7072,47 @@ version: 4.9.3
7025
7072
 
7026
7073
  return this;
7027
7074
  };
7075
+ /**
7076
+ * Change the destination and duration of the animation currently playing
7077
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
7078
+ * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
7079
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
7080
+ * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
7081
+ * @chainable
7082
+ * @throws {FlickingError}
7083
+ * {@link ERROR_CODE POSITION_NOT_REACHABLE} When the given panel is already removed or not in the Camera's {@link Camera#range range}
7084
+ * <ko>{@link ERROR_CODE POSITION_NOT_REACHABLE} 주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우</ko>
7085
+ * @return {this}
7086
+ */
7087
+
7088
+
7089
+ __proto.updateAnimation = function (panel, duration, direction) {
7090
+ var state = this._controller.state;
7091
+
7092
+ var position = this._getPosition(panel, direction !== null && direction !== void 0 ? direction : DIRECTION.NONE);
7093
+
7094
+ state.targetPanel = panel;
7095
+
7096
+ this._controller.updateAnimation(position, duration);
7097
+
7098
+ return this;
7099
+ };
7100
+ /**
7101
+ * Stops the animation currently playing
7102
+ * @ko 재생 중인 애니메이션을 중단시킵니다
7103
+ * @chainable
7104
+ * @return {this}
7105
+ */
7106
+
7107
+
7108
+ __proto.stopAnimation = function () {
7109
+ var state = this._controller.state;
7110
+ state.targetPanel = null;
7111
+
7112
+ this._controller.stopAnimation();
7113
+
7114
+ return this;
7115
+ };
7028
7116
  /**
7029
7117
  * Update position after resizing
7030
7118
  * @ko resize 이후에 position을 업데이트합니다
@@ -7120,38 +7208,9 @@ version: 4.9.3
7120
7208
  direction = _b === void 0 ? DIRECTION.NONE : _b,
7121
7209
  axesEvent = _a.axesEvent;
7122
7210
  return __awaiter(this, void 0, void 0, function () {
7123
- var flicking, camera, position, nearestAnchor, camPos_1, camRangeDiff, possiblePositions;
7211
+ var position;
7124
7212
  return __generator(this, function (_c) {
7125
- flicking = getFlickingAttached(this._flicking);
7126
- camera = flicking.camera;
7127
- position = panel.position;
7128
- nearestAnchor = camera.findNearestAnchor(position);
7129
-
7130
- if (panel.removed || !nearestAnchor) {
7131
- return [2
7132
- /*return*/
7133
- , Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE))];
7134
- }
7135
-
7136
- if (!camera.canReach(panel)) {
7137
- // Override position & panel if that panel is not reachable
7138
- position = nearestAnchor.position;
7139
- panel = nearestAnchor.panel;
7140
- } else if (flicking.circularEnabled) {
7141
- camPos_1 = this._controller.position;
7142
- camRangeDiff = camera.rangeDiff;
7143
- possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
7144
- if (direction === DIRECTION.NONE) return true;
7145
- return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
7146
- });
7147
- position = possiblePositions.reduce(function (nearestPosition, pos) {
7148
- if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
7149
- return pos;
7150
- } else {
7151
- return nearestPosition;
7152
- }
7153
- }, Infinity);
7154
- }
7213
+ position = this._getPosition(panel, direction);
7155
7214
 
7156
7215
  this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
7157
7216
 
@@ -7268,6 +7327,45 @@ version: 4.9.3
7268
7327
  });
7269
7328
  };
7270
7329
 
7330
+ __proto._getPosition = function (panel, direction) {
7331
+ if (direction === void 0) {
7332
+ direction = DIRECTION.NONE;
7333
+ }
7334
+
7335
+ var flicking = getFlickingAttached(this._flicking);
7336
+ var camera = flicking.camera;
7337
+ var position = panel.position;
7338
+ var nearestAnchor = camera.findNearestAnchor(position);
7339
+
7340
+ if (panel.removed || !nearestAnchor) {
7341
+ throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE);
7342
+ }
7343
+
7344
+ if (!camera.canReach(panel)) {
7345
+ // Override position & panel if that panel is not reachable
7346
+ position = nearestAnchor.position;
7347
+ panel = nearestAnchor.panel;
7348
+ } else if (flicking.circularEnabled) {
7349
+ // Circular mode is enabled, find nearest distance to panel
7350
+ var camPos_1 = this._controller.position; // Actual position of the Axes
7351
+
7352
+ var camRangeDiff = camera.rangeDiff;
7353
+ var possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
7354
+ if (direction === DIRECTION.NONE) return true;
7355
+ return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
7356
+ });
7357
+ position = possiblePositions.reduce(function (nearestPosition, pos) {
7358
+ if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
7359
+ return pos;
7360
+ } else {
7361
+ return nearestPosition;
7362
+ }
7363
+ }, Infinity);
7364
+ }
7365
+
7366
+ return position;
7367
+ };
7368
+
7271
7369
  return Control;
7272
7370
  }();
7273
7371
 
@@ -13338,6 +13436,49 @@ version: 4.9.3
13338
13436
  direction: direction
13339
13437
  });
13340
13438
  };
13439
+ /**
13440
+ * Change the destination and duration of the animation currently playing
13441
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
13442
+ * @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
13443
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
13444
+ * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
13445
+ * @throws {FlickingError}
13446
+ * {@link ERROR_CODE INDEX_OUT_OF_RANGE} When the root is not either string or HTMLElement
13447
+ * <ko>{@link ERROR_CODE INDEX_OUT_OF_RANGE} 해당 인덱스를 가진 패널이 존재하지 않을 경우</ko>
13448
+ * @return {void}
13449
+ */
13450
+
13451
+
13452
+ __proto.updateAnimation = function (index, duration, direction) {
13453
+ if (!this._control.animating) {
13454
+ return;
13455
+ }
13456
+
13457
+ var renderer = this._renderer;
13458
+ var panelCount = renderer.panelCount;
13459
+ var panel = renderer.getPanel(index);
13460
+
13461
+ if (!panel) {
13462
+ throw new FlickingError(MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), CODE.INDEX_OUT_OF_RANGE);
13463
+ }
13464
+
13465
+ this._control.updateAnimation(panel, duration, direction);
13466
+ };
13467
+ /**
13468
+ * Stops the animation currently playing
13469
+ * @ko 재생 중인 애니메이션을 중단시킵니다
13470
+ * @fires Flicking#moveEnd
13471
+ * @return {void}
13472
+ */
13473
+
13474
+
13475
+ __proto.stopAnimation = function () {
13476
+ if (!this._control.animating) {
13477
+ return;
13478
+ }
13479
+
13480
+ this._control.stopAnimation();
13481
+ };
13341
13482
  /**
13342
13483
  * Return the {@link Panel} at the given index. `null` if it doesn't exists.
13343
13484
  * @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
@@ -13881,7 +14022,7 @@ version: 4.9.3
13881
14022
  */
13882
14023
 
13883
14024
 
13884
- Flicking.VERSION = "4.9.3";
14025
+ Flicking.VERSION = "4.10.0";
13885
14026
  return Flicking;
13886
14027
  }(Component);
13887
14028