@egjs/flicking 4.9.3 → 4.10.1

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.1
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}의 이벤트를 처리하는 컨트롤러 컴포넌트
@@ -6616,6 +6625,7 @@ version: 4.9.3
6616
6625
  });
6617
6626
  this._panInput = new PanInput(flicking.viewport.element, {
6618
6627
  inputType: flicking.inputType,
6628
+ threshold: 1,
6619
6629
  iOSEdgeSwipeThreshold: flicking.iOSEdgeSwipeThreshold,
6620
6630
  scale: flicking.horizontal ? [-1, 0] : [0, -1],
6621
6631
  releaseOnScroll: true
@@ -6701,6 +6711,44 @@ version: 4.9.3
6701
6711
  (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.release();
6702
6712
  return this;
6703
6713
  };
6714
+ /**
6715
+ * Change the destination and duration of the animation currently playing
6716
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
6717
+ * @param {number} position A position to move<ko>이동할 좌표</ko>
6718
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
6719
+ * @chainable
6720
+ * @return {this}
6721
+ */
6722
+
6723
+
6724
+ __proto.updateAnimation = function (position, duration) {
6725
+ var _a;
6726
+
6727
+ var _b;
6728
+
6729
+ this._animatingContext = __assign$2(__assign$2({}, this._animatingContext), {
6730
+ end: position
6731
+ });
6732
+ (_b = this._axes) === null || _b === void 0 ? void 0 : _b.updateAnimation({
6733
+ destPos: (_a = {}, _a[POSITION_KEY] = position, _a),
6734
+ duration: duration
6735
+ });
6736
+ return this;
6737
+ };
6738
+ /**
6739
+ * Stops the animation currently playing
6740
+ * @ko 재생 중인 애니메이션을 중단시킵니다
6741
+ * @chainable
6742
+ * @return {this}
6743
+ */
6744
+
6745
+
6746
+ __proto.stopAnimation = function () {
6747
+ var _a;
6748
+
6749
+ (_a = this._axes) === null || _a === void 0 ? void 0 : _a.stopAnimation();
6750
+ return this;
6751
+ };
6704
6752
  /**
6705
6753
  * Update {@link https://naver.github.io/egjs-axes/ @egjs/axes}'s state
6706
6754
  * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 상태를 갱신합니다
@@ -7025,6 +7073,47 @@ version: 4.9.3
7025
7073
 
7026
7074
  return this;
7027
7075
  };
7076
+ /**
7077
+ * Change the destination and duration of the animation currently playing
7078
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
7079
+ * @param {Panel} panel The target panel to move<ko>이동할 패널</ko>
7080
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
7081
+ * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
7082
+ * @chainable
7083
+ * @throws {FlickingError}
7084
+ * {@link ERROR_CODE POSITION_NOT_REACHABLE} When the given panel is already removed or not in the Camera's {@link Camera#range range}
7085
+ * <ko>{@link ERROR_CODE POSITION_NOT_REACHABLE} 주어진 패널이 제거되었거나, Camera의 {@link Camera#range range} 밖에 있을 경우</ko>
7086
+ * @return {this}
7087
+ */
7088
+
7089
+
7090
+ __proto.updateAnimation = function (panel, duration, direction) {
7091
+ var state = this._controller.state;
7092
+
7093
+ var position = this._getPosition(panel, direction !== null && direction !== void 0 ? direction : DIRECTION.NONE);
7094
+
7095
+ state.targetPanel = panel;
7096
+
7097
+ this._controller.updateAnimation(position, duration);
7098
+
7099
+ return this;
7100
+ };
7101
+ /**
7102
+ * Stops the animation currently playing
7103
+ * @ko 재생 중인 애니메이션을 중단시킵니다
7104
+ * @chainable
7105
+ * @return {this}
7106
+ */
7107
+
7108
+
7109
+ __proto.stopAnimation = function () {
7110
+ var state = this._controller.state;
7111
+ state.targetPanel = null;
7112
+
7113
+ this._controller.stopAnimation();
7114
+
7115
+ return this;
7116
+ };
7028
7117
  /**
7029
7118
  * Update position after resizing
7030
7119
  * @ko resize 이후에 position을 업데이트합니다
@@ -7120,38 +7209,9 @@ version: 4.9.3
7120
7209
  direction = _b === void 0 ? DIRECTION.NONE : _b,
7121
7210
  axesEvent = _a.axesEvent;
7122
7211
  return __awaiter(this, void 0, void 0, function () {
7123
- var flicking, camera, position, nearestAnchor, camPos_1, camRangeDiff, possiblePositions;
7212
+ var position;
7124
7213
  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
- }
7214
+ position = this._getPosition(panel, direction);
7155
7215
 
7156
7216
  this._triggerIndexChangeEvent(panel, panel.position, axesEvent);
7157
7217
 
@@ -7268,6 +7328,45 @@ version: 4.9.3
7268
7328
  });
7269
7329
  };
7270
7330
 
7331
+ __proto._getPosition = function (panel, direction) {
7332
+ if (direction === void 0) {
7333
+ direction = DIRECTION.NONE;
7334
+ }
7335
+
7336
+ var flicking = getFlickingAttached(this._flicking);
7337
+ var camera = flicking.camera;
7338
+ var position = panel.position;
7339
+ var nearestAnchor = camera.findNearestAnchor(position);
7340
+
7341
+ if (panel.removed || !nearestAnchor) {
7342
+ throw new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(panel.position), CODE.POSITION_NOT_REACHABLE);
7343
+ }
7344
+
7345
+ if (!camera.canReach(panel)) {
7346
+ // Override position & panel if that panel is not reachable
7347
+ position = nearestAnchor.position;
7348
+ panel = nearestAnchor.panel;
7349
+ } else if (flicking.circularEnabled) {
7350
+ // Circular mode is enabled, find nearest distance to panel
7351
+ var camPos_1 = this._controller.position; // Actual position of the Axes
7352
+
7353
+ var camRangeDiff = camera.rangeDiff;
7354
+ var possiblePositions = [position, position + camRangeDiff, position - camRangeDiff].filter(function (pos) {
7355
+ if (direction === DIRECTION.NONE) return true;
7356
+ return direction === DIRECTION.PREV ? pos <= camPos_1 : pos >= camPos_1;
7357
+ });
7358
+ position = possiblePositions.reduce(function (nearestPosition, pos) {
7359
+ if (Math.abs(camPos_1 - pos) < Math.abs(camPos_1 - nearestPosition)) {
7360
+ return pos;
7361
+ } else {
7362
+ return nearestPosition;
7363
+ }
7364
+ }, Infinity);
7365
+ }
7366
+
7367
+ return position;
7368
+ };
7369
+
7271
7370
  return Control;
7272
7371
  }();
7273
7372
 
@@ -13338,6 +13437,49 @@ version: 4.9.3
13338
13437
  direction: direction
13339
13438
  });
13340
13439
  };
13440
+ /**
13441
+ * Change the destination and duration of the animation currently playing
13442
+ * @ko 재생 중인 애니메이션의 목적지와 재생 시간을 변경합니다
13443
+ * @param {number} index The index of the panel to move<ko>이동할 패널의 인덱스</ko>
13444
+ * @param {number} duration Duration of the animation (unit: ms)<ko>애니메이션 진행 시간 (단위: ms)</ko>
13445
+ * @param {DIRECTION} direction Direction to move, only available in the {@link Flicking#circular circular} mode<ko>이동할 방향. {@link Flicking#circular circular} 옵션 활성화시에만 사용 가능합니다</ko>
13446
+ * @throws {FlickingError}
13447
+ * {@link ERROR_CODE INDEX_OUT_OF_RANGE} When the root is not either string or HTMLElement
13448
+ * <ko>{@link ERROR_CODE INDEX_OUT_OF_RANGE} 해당 인덱스를 가진 패널이 존재하지 않을 경우</ko>
13449
+ * @return {void}
13450
+ */
13451
+
13452
+
13453
+ __proto.updateAnimation = function (index, duration, direction) {
13454
+ if (!this._control.animating) {
13455
+ return;
13456
+ }
13457
+
13458
+ var renderer = this._renderer;
13459
+ var panelCount = renderer.panelCount;
13460
+ var panel = renderer.getPanel(index);
13461
+
13462
+ if (!panel) {
13463
+ throw new FlickingError(MESSAGE.INDEX_OUT_OF_RANGE(index, 0, panelCount - 1), CODE.INDEX_OUT_OF_RANGE);
13464
+ }
13465
+
13466
+ this._control.updateAnimation(panel, duration, direction);
13467
+ };
13468
+ /**
13469
+ * Stops the animation currently playing
13470
+ * @ko 재생 중인 애니메이션을 중단시킵니다
13471
+ * @fires Flicking#moveEnd
13472
+ * @return {void}
13473
+ */
13474
+
13475
+
13476
+ __proto.stopAnimation = function () {
13477
+ if (!this._control.animating) {
13478
+ return;
13479
+ }
13480
+
13481
+ this._control.stopAnimation();
13482
+ };
13341
13483
  /**
13342
13484
  * Return the {@link Panel} at the given index. `null` if it doesn't exists.
13343
13485
  * @ko 주어진 인덱스에 해당하는 {@link Panel}을 반환합니다. 주어진 인덱스에 해당하는 패널이 존재하지 않을 경우 `null`을 반환합니다.
@@ -13881,7 +14023,7 @@ version: 4.9.3
13881
14023
  */
13882
14024
 
13883
14025
 
13884
- Flicking.VERSION = "4.9.3";
14026
+ Flicking.VERSION = "4.10.1";
13885
14027
  return Flicking;
13886
14028
  }(Component);
13887
14029