@egjs/flicking 4.9.2 → 4.9.3-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.9.2
7
+ version: 4.9.3-beta.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.2
2426
2426
  license: MIT
2427
2427
  author: NAVER Corp.
2428
2428
  repository: https://github.com/naver/egjs-axes
2429
- version: 3.6.0
2429
+ version: 3.8.0
2430
2430
  */
2431
2431
 
2432
2432
  /*! *****************************************************************************
@@ -2772,15 +2772,6 @@ version: 4.9.2
2772
2772
  return DIRECTION_NONE;
2773
2773
  }
2774
2774
  };
2775
- var getInitialPos = function (axis, startPos) {
2776
- return __assign$1(__assign$1({}, Object.keys(axis).reduce(function (result, key) {
2777
- var _a;
2778
-
2779
- var _b, _c;
2780
-
2781
- return Object.assign(result, (_a = {}, _a[key] = (_c = (_b = axis[key].startPos) !== null && _b !== void 0 ? _b : axis[key].range[0]) !== null && _c !== void 0 ? _c : 0, _a));
2782
- }, {})), startPos);
2783
- };
2784
2775
  var useDirection = function (checkType, direction, userDirection) {
2785
2776
  if (userDirection) {
2786
2777
  return !!(direction === DIRECTION_ALL || direction & checkType && userDirection & checkType);
@@ -3299,9 +3290,9 @@ version: 4.9.2
3299
3290
 
3300
3291
  this._complementOptions();
3301
3292
 
3302
- this._pos = Object.keys(this._axis).reduce(function (acc, v) {
3303
- acc[v] = _this._axis[v].range[0];
3304
- return acc;
3293
+ this._pos = Object.keys(this._axis).reduce(function (pos, v) {
3294
+ pos[v] = _this._axis[v].startPos;
3295
+ return pos;
3305
3296
  }, {});
3306
3297
  }
3307
3298
 
@@ -3385,6 +3376,20 @@ version: 4.9.2
3385
3376
  __proto.getAxisOptions = function (key) {
3386
3377
  return this._axis[key];
3387
3378
  };
3379
+
3380
+ __proto.setAxis = function (axis) {
3381
+ var _this = this;
3382
+
3383
+ Object.keys(axis).forEach(function (key) {
3384
+ if (!_this._axis[key]) {
3385
+ throw new Error("Axis ".concat(key, " does not exist in Axes instance"));
3386
+ }
3387
+
3388
+ _this._axis[key] = __assign$1(__assign$1({}, _this._axis[key]), axis[key]);
3389
+ });
3390
+
3391
+ this._complementOptions();
3392
+ };
3388
3393
  /**
3389
3394
  * set up 'css' expression
3390
3395
  * @private
@@ -3564,7 +3569,16 @@ version: 4.9.2
3564
3569
  return;
3565
3570
  };
3566
3571
 
3567
- __proto.getTouches = function () {
3572
+ __proto.getTouches = function (event, inputButton) {
3573
+ if (inputButton) {
3574
+ var buttonCodeMap = {
3575
+ 1: MOUSE_LEFT,
3576
+ 2: MOUSE_MIDDLE,
3577
+ 3: MOUSE_RIGHT
3578
+ };
3579
+ return this._isValidButton(buttonCodeMap[event.which], inputButton) && this.end.indexOf(event.type) === -1 ? 1 : 0;
3580
+ }
3581
+
3568
3582
  return 0;
3569
3583
  };
3570
3584
 
@@ -4629,7 +4643,7 @@ version: 4.9.2
4629
4643
  /**
4630
4644
  * @typedef {Object} AxisOption The Axis information. The key of the axis specifies the name to use as the logical virtual coordinate system.
4631
4645
  * @ko 축 정보. 축의 키는 논리적인 가상 좌표계로 사용할 이름을 지정한다.
4632
- * @param {Number[]} [range] The coordinate of range <ko>좌표 범위</ko>
4646
+ * @param {Number[]} [range] The range of coordinate <ko>좌표 범위</ko>
4633
4647
  * @param {Number} [range[0]=0] The coordinate of the minimum <ko>최소 좌표</ko>
4634
4648
  * @param {Number} [range[1]=0] The coordinate of the maximum <ko>최대 좌표</ko>
4635
4649
  * @param {Number} [startPos=range[0]] The coordinates to be moved when creating an instance <ko>인스턴스 생성시 이동할 좌표</ko>
@@ -4667,7 +4681,7 @@ version: 4.9.2
4667
4681
  *
4668
4682
  * @param {Object.<string, AxisOption>} axis Axis information managed by eg.Axes. The key of the axis specifies the name to use as the logical virtual coordinate system. <ko>eg.Axes가 관리하는 축 정보. 축의 키는 논리적인 가상 좌표계로 사용할 이름을 지정한다.</ko>
4669
4683
  * @param {AxesOption} [options={}] The option object of the eg.Axes module<ko>eg.Axes 모듈의 옵션 객체</ko>
4670
- * @param {Object.<string, number>} [startPos=null] The coordinates to be moved when creating an instance. It is applied with higher priority than startPos of axisOption.<ko>인스턴스 생성시 이동할 좌표, axisOption의 startPos보다 높은 우선순위로 적용된다.</ko>
4684
+ * @param {Object.<string, number>} [startPos={}] The coordinates to be moved when creating an instance. It is applied with higher priority than startPos of axisOption.<ko>인스턴스 생성시 이동할 좌표, axisOption의 startPos보다 높은 우선순위로 적용된다.</ko>
4671
4685
  *
4672
4686
  * @support {"ie": "10+", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "2.3+ (except 3.x)"}
4673
4687
  * @example
@@ -4749,7 +4763,7 @@ version: 4.9.2
4749
4763
  }
4750
4764
 
4751
4765
  if (startPos === void 0) {
4752
- startPos = null;
4766
+ startPos = {};
4753
4767
  }
4754
4768
 
4755
4769
  var _this = _super.call(this) || this;
@@ -4767,6 +4781,9 @@ version: 4.9.2
4767
4781
  round: null,
4768
4782
  nested: false
4769
4783
  }, options);
4784
+ Object.keys(startPos).forEach(function (key) {
4785
+ _this.axis[key].startPos = startPos[key];
4786
+ });
4770
4787
  _this.interruptManager = new InterruptManager(_this.options);
4771
4788
  _this.axisManager = new AxisManager(_this.axis);
4772
4789
  _this.eventManager = new EventManager(_this);
@@ -4775,7 +4792,7 @@ version: 4.9.2
4775
4792
 
4776
4793
  _this.eventManager.setAnimationManager(_this.animationManager);
4777
4794
 
4778
- _this.eventManager.triggerChange(getInitialPos(axis, startPos));
4795
+ _this.eventManager.triggerChange(_this.axisManager.get());
4779
4796
 
4780
4797
  return _this;
4781
4798
  }
@@ -4984,6 +5001,70 @@ version: 4.9.2
4984
5001
  this.animationManager.setBy(pos, duration);
4985
5002
  return this;
4986
5003
  };
5004
+ /**
5005
+ * Change the options of Axes instance.
5006
+ * @ko 인스턴스의 옵션을 변경한다.
5007
+ * @param {AxesOption} options Axes options to change <ko>변경할 옵션 목록</ko>
5008
+ * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
5009
+ * @example
5010
+ * ```js
5011
+ * const axes = new eg.Axes({
5012
+ * "x": {
5013
+ * range: [0, 100]
5014
+ * },
5015
+ * }, {
5016
+ * round: 10,
5017
+ * });
5018
+ *
5019
+ * axes.setTo({"x": 48});
5020
+ * axes.get(); // {"x": 50}
5021
+ *
5022
+ * axes.setOptions({
5023
+ * round: 1,
5024
+ * });
5025
+ *
5026
+ * axes.setTo({"x": 48});
5027
+ * axes.get(); // {"x": 48}
5028
+ * ```
5029
+ */
5030
+
5031
+
5032
+ __proto.setOptions = function (options) {
5033
+ this.options = __assign$1(__assign$1({}, this.options), options);
5034
+ return this;
5035
+ };
5036
+ /**
5037
+ * Change the information of an existing axis.
5038
+ * @ko 존재하는 축의 정보를 변경한다.
5039
+ * @param {Object.<string, AxisOption>} axis Axis options to change <ko>변경할 축의 정보</ko>
5040
+ * @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko>
5041
+ * @example
5042
+ * ```js
5043
+ * const axes = new eg.Axes({
5044
+ * "x": {
5045
+ * range: [0, 100]
5046
+ * },
5047
+ * });
5048
+ *
5049
+ * axes.setTo({"x": 150});
5050
+ * axes.get(); // {"x": 100}
5051
+ *
5052
+ * axes.setAxis({
5053
+ * "x": {
5054
+ * range: [0, 200]
5055
+ * },
5056
+ * });
5057
+ *
5058
+ * axes.setTo({"x": 150});
5059
+ * axes.get(); // {"x": 150}
5060
+ * ```
5061
+ */
5062
+
5063
+
5064
+ __proto.setAxis = function (axis) {
5065
+ this.axisManager.setAxis(axis);
5066
+ return this;
5067
+ };
4987
5068
  /**
4988
5069
  * Stop an animation in progress.
4989
5070
  * @ko 재생 중인 애니메이션을 정지한다.
@@ -5095,7 +5176,7 @@ version: 4.9.2
5095
5176
  */
5096
5177
 
5097
5178
 
5098
- Axes.VERSION = "3.6.0";
5179
+ Axes.VERSION = "3.8.0";
5099
5180
  /* eslint-enable */
5100
5181
 
5101
5182
  /**
@@ -5207,6 +5288,7 @@ version: 4.9.2
5207
5288
  * @param {Number} [scale[1]=1] vertical axis scale <ko>수직축 배율</ko>
5208
5289
  * @param {Number} [thresholdAngle=45] The threshold value that determines whether user action is horizontal or vertical (0~90) <ko>사용자의 동작이 가로 방향인지 세로 방향인지 판단하는 기준 각도(0~90)</ko>
5209
5290
  * @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>
5210
5292
  * @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>
5211
5293
  * @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>
5212
5294
  **/
@@ -5243,12 +5325,24 @@ version: 4.9.2
5243
5325
  *
5244
5326
  */
5245
5327
  function PanInput(el, options) {
5328
+ var _this = this;
5329
+
5246
5330
  this.axes = [];
5247
5331
  this.element = null;
5248
5332
  this._enabled = false;
5249
5333
  this._activeEvent = null;
5250
5334
  this._atRightEdge = false;
5251
5335
  this._rightEdgeTimer = 0;
5336
+ this._dragged = false;
5337
+
5338
+ this._preventClickWhenDragged = function (e) {
5339
+ if (_this._dragged) {
5340
+ e.preventDefault();
5341
+ e.stopPropagation();
5342
+ }
5343
+
5344
+ _this._dragged = false;
5345
+ };
5252
5346
 
5253
5347
  this._voidFunction = function () {};
5254
5348
 
@@ -5259,6 +5353,7 @@ version: 4.9.2
5259
5353
  scale: [1, 1],
5260
5354
  thresholdAngle: 45,
5261
5355
  threshold: 0,
5356
+ preventClickOnDrag: false,
5262
5357
  iOSEdgeSwipeThreshold: IOS_EDGE_THRESHOLD,
5263
5358
  releaseOnScroll: false,
5264
5359
  touchAction: null
@@ -5362,15 +5457,17 @@ version: 4.9.2
5362
5457
  };
5363
5458
 
5364
5459
  __proto._onPanstart = function (event) {
5460
+ var inputButton = this.options.inputButton;
5365
5461
  var activeEvent = this._activeEvent;
5366
- var panEvent = activeEvent.onEventStart(event, this.options.inputButton);
5462
+ var panEvent = activeEvent.onEventStart(event, inputButton);
5367
5463
 
5368
- if (!panEvent || !this._enabled || activeEvent.getTouches(event) > 1) {
5464
+ if (!panEvent || !this._enabled || activeEvent.getTouches(event, inputButton) > 1) {
5369
5465
  return;
5370
5466
  }
5371
5467
 
5372
5468
  if (panEvent.srcEvent.cancelable !== false) {
5373
5469
  var edgeThreshold = this.options.iOSEdgeSwipeThreshold;
5470
+ this._dragged = false;
5374
5471
 
5375
5472
  this._observer.hold(this, panEvent);
5376
5473
 
@@ -5385,24 +5482,27 @@ version: 4.9.2
5385
5482
  __proto._onPanmove = function (event) {
5386
5483
  var _this = this;
5387
5484
 
5388
- var activeEvent = this._activeEvent;
5389
- var panEvent = activeEvent.onEventMove(event, this.options.inputButton);
5390
-
5391
- if (!panEvent || !this._enabled || activeEvent.getTouches(event) > 1) {
5392
- return;
5393
- }
5394
-
5395
5485
  var _a = this.options,
5396
5486
  iOSEdgeSwipeThreshold = _a.iOSEdgeSwipeThreshold,
5397
- releaseOnScroll = _a.releaseOnScroll;
5398
- var userDirection = getDirectionByAngle(panEvent.angle, this.options.thresholdAngle);
5487
+ releaseOnScroll = _a.releaseOnScroll,
5488
+ inputButton = _a.inputButton,
5489
+ thresholdAngle = _a.thresholdAngle;
5490
+ var activeEvent = this._activeEvent;
5491
+ var panEvent = activeEvent.onEventMove(event, inputButton);
5492
+ var touches = activeEvent.getTouches(event, inputButton);
5399
5493
 
5400
- if (releaseOnScroll && !panEvent.srcEvent.cancelable) {
5494
+ if (touches === 0 || releaseOnScroll && panEvent && !panEvent.srcEvent.cancelable) {
5401
5495
  this._onPanend(event);
5402
5496
 
5403
5497
  return;
5404
5498
  }
5405
5499
 
5500
+ if (!panEvent || !this._enabled || touches > 1) {
5501
+ return;
5502
+ }
5503
+
5504
+ var userDirection = getDirectionByAngle(panEvent.angle, thresholdAngle);
5505
+
5406
5506
  if (activeEvent.prevEvent && IS_IOS_SAFARI) {
5407
5507
  var swipeLeftToRight = panEvent.center.x < 0;
5408
5508
 
@@ -5443,6 +5543,8 @@ version: 4.9.2
5443
5543
  panEvent.preventSystemEvent = prevent;
5444
5544
 
5445
5545
  if (prevent) {
5546
+ this._dragged = true;
5547
+
5446
5548
  this._observer.change(this, panEvent, toAxis(this.axes, offset));
5447
5549
  }
5448
5550
 
@@ -5450,10 +5552,11 @@ version: 4.9.2
5450
5552
  };
5451
5553
 
5452
5554
  __proto._onPanend = function (event) {
5555
+ var inputButton = this.options.inputButton;
5453
5556
  var activeEvent = this._activeEvent;
5454
5557
  activeEvent.onEventEnd(event);
5455
5558
 
5456
- if (!this._enabled || activeEvent.getTouches(event) !== 0) {
5559
+ if (!this._enabled || activeEvent.getTouches(event, inputButton) !== 0) {
5457
5560
  return;
5458
5561
  }
5459
5562
 
@@ -5504,24 +5607,30 @@ version: 4.9.2
5504
5607
  var _this = this;
5505
5608
 
5506
5609
  var activeEvent = convertInputType(this.options.inputType);
5610
+ var element = this.element;
5507
5611
 
5508
5612
  if (!activeEvent) {
5509
5613
  return;
5510
5614
  }
5511
5615
 
5616
+ if (!element) {
5617
+ throw new Error("Element to connect input does not exist.");
5618
+ }
5619
+
5512
5620
  this._observer = observer;
5513
5621
  this._enabled = true;
5514
5622
  this._activeEvent = activeEvent;
5515
- activeEvent.start.forEach(function (event) {
5516
- var _a;
5517
5623
 
5518
- (_a = _this.element) === null || _a === void 0 ? void 0 : _a.addEventListener(event, _this._onPanstart);
5624
+ if (this.options.preventClickOnDrag) {
5625
+ element.addEventListener("click", this._preventClickWhenDragged, true);
5626
+ }
5627
+
5628
+ activeEvent.start.forEach(function (event) {
5629
+ element.addEventListener(event, _this._onPanstart);
5519
5630
  }); // adding event listener to element prevents invalid behavior in iOS Safari
5520
5631
 
5521
5632
  activeEvent.move.forEach(function (event) {
5522
- var _a;
5523
-
5524
- (_a = _this.element) === null || _a === void 0 ? void 0 : _a.addEventListener(event, _this._voidFunction);
5633
+ element.addEventListener(event, _this._voidFunction);
5525
5634
  });
5526
5635
  };
5527
5636
 
@@ -5529,16 +5638,21 @@ version: 4.9.2
5529
5638
  var _this = this;
5530
5639
 
5531
5640
  var activeEvent = this._activeEvent;
5532
- activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.start.forEach(function (event) {
5533
- var _a;
5641
+ var element = this.element;
5534
5642
 
5535
- (_a = _this.element) === null || _a === void 0 ? void 0 : _a.removeEventListener(event, _this._onPanstart);
5536
- });
5537
- activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.move.forEach(function (event) {
5538
- var _a;
5643
+ if (element) {
5644
+ if (this.options.preventClickOnDrag) {
5645
+ element.removeEventListener("click", this._preventClickWhenDragged, true);
5646
+ }
5647
+
5648
+ activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.start.forEach(function (event) {
5649
+ element.removeEventListener(event, _this._onPanstart);
5650
+ });
5651
+ activeEvent === null || activeEvent === void 0 ? void 0 : activeEvent.move.forEach(function (event) {
5652
+ element.removeEventListener(event, _this._voidFunction);
5653
+ });
5654
+ }
5539
5655
 
5540
- (_a = _this.element) === null || _a === void 0 ? void 0 : _a.removeEventListener(event, _this._voidFunction);
5541
- });
5542
5656
  this._enabled = false;
5543
5657
  this._observer = null;
5544
5658
  };
@@ -13767,7 +13881,7 @@ version: 4.9.2
13767
13881
  */
13768
13882
 
13769
13883
 
13770
- Flicking.VERSION = "4.9.2";
13884
+ Flicking.VERSION = "4.9.3-beta.0";
13771
13885
  return Flicking;
13772
13886
  }(Component);
13773
13887