@egjs/flicking 4.8.1 → 4.9.2

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.8.1
7
+ version: 4.9.2
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')) :
@@ -780,6 +780,29 @@ version: 4.8.1
780
780
 
781
781
  return arr;
782
782
  };
783
+ var getElementSize = function (_a) {
784
+ var el = _a.el,
785
+ horizontal = _a.horizontal,
786
+ useFractionalSize = _a.useFractionalSize,
787
+ useOffset = _a.useOffset,
788
+ style = _a.style;
789
+
790
+ if (useFractionalSize) {
791
+ var baseSize = parseFloat(horizontal ? style.width : style.height);
792
+ var isBorderBoxSizing = style.boxSizing === "border-box";
793
+ var border = horizontal ? parseFloat(style.borderLeftWidth || "0") + parseFloat(style.borderRightWidth || "0") : parseFloat(style.borderTopWidth || "0") + parseFloat(style.borderBottomWidth || "0");
794
+
795
+ if (isBorderBoxSizing) {
796
+ return useOffset ? baseSize : baseSize - border;
797
+ } else {
798
+ var padding = horizontal ? parseFloat(style.paddingLeft || "0") + parseFloat(style.paddingRight || "0") : parseFloat(style.paddingTop || "0") + parseFloat(style.paddingBottom || "0");
799
+ return useOffset ? baseSize + padding + border : baseSize + padding;
800
+ }
801
+ } else {
802
+ var sizeStr = horizontal ? "Width" : "Height";
803
+ return useOffset ? el["offset" + sizeStr] : el["client" + sizeStr];
804
+ }
805
+ };
783
806
  var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
784
807
  obj.__proto__ = proto;
785
808
  return obj;
@@ -814,6 +837,7 @@ version: 4.8.1
814
837
  isBetween: isBetween,
815
838
  circulateIndex: circulateIndex,
816
839
  range: range,
840
+ getElementSize: getElementSize,
817
841
  setPrototypeOf: setPrototypeOf
818
842
  };
819
843
 
@@ -862,10 +886,6 @@ version: 4.8.1
862
886
  return FlickingError;
863
887
  }(Error);
864
888
 
865
- /*
866
- * Copyright (c) 2015 NAVER Corp.
867
- * egjs projects are licensed under the MIT license
868
- */
869
889
  /**
870
890
  * A component that manages viewport size
871
891
  * @ko 뷰포트 크기 정보를 담당하는 컴포넌트
@@ -877,7 +897,8 @@ version: 4.8.1
877
897
  /**
878
898
  * @param el A viewport element<ko>뷰포트 엘리먼트</ko>
879
899
  */
880
- function Viewport(el) {
900
+ function Viewport(flicking, el) {
901
+ this._flicking = flicking;
881
902
  this._el = el;
882
903
  this._width = 0;
883
904
  this._height = 0;
@@ -993,8 +1014,21 @@ version: 4.8.1
993
1014
  __proto.resize = function () {
994
1015
  var el = this._el;
995
1016
  var elStyle = getStyle(el);
996
- this._width = el.clientWidth;
997
- this._height = el.clientHeight;
1017
+ var useFractionalSize = this._flicking.useFractionalSize;
1018
+ this._width = getElementSize({
1019
+ el: el,
1020
+ horizontal: true,
1021
+ useFractionalSize: useFractionalSize,
1022
+ useOffset: false,
1023
+ style: elStyle
1024
+ });
1025
+ this._height = getElementSize({
1026
+ el: el,
1027
+ horizontal: false,
1028
+ useFractionalSize: useFractionalSize,
1029
+ useOffset: false,
1030
+ style: elStyle
1031
+ });
998
1032
  this._padding = {
999
1033
  left: elStyle.paddingLeft ? parseFloat(elStyle.paddingLeft) : 0,
1000
1034
  right: elStyle.paddingRight ? parseFloat(elStyle.paddingRight) : 0,
@@ -2462,6 +2496,20 @@ version: 4.8.1
2462
2496
  (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.disable();
2463
2497
  return this;
2464
2498
  };
2499
+ /**
2500
+ * Releases ongoing user input (mouse/touch)
2501
+ * @ko 사용자의 현재 입력(마우스/터치)를 중단시킵니다
2502
+ * @chainable
2503
+ * @return {this}
2504
+ */
2505
+
2506
+
2507
+ __proto.release = function () {
2508
+ var _a;
2509
+
2510
+ (_a = this._panInput) === null || _a === void 0 ? void 0 : _a.release();
2511
+ return this;
2512
+ };
2465
2513
  /**
2466
2514
  * Update {@link https://naver.github.io/egjs-axes/ @egjs/axes}'s state
2467
2515
  * @ko {@link https://naver.github.io/egjs-axes/ @egjs/axes}의 상태를 갱신합니다
@@ -2773,6 +2821,19 @@ version: 4.8.1
2773
2821
 
2774
2822
  return this;
2775
2823
  };
2824
+ /**
2825
+ * Releases ongoing user input (mouse/touch)
2826
+ * @ko 사용자의 현재 입력(마우스/터치)를 중단시킵니다
2827
+ * @chainable
2828
+ * @return {this}
2829
+ */
2830
+
2831
+
2832
+ __proto.release = function () {
2833
+ this._controller.release();
2834
+
2835
+ return this;
2836
+ };
2776
2837
  /**
2777
2838
  * Update position after resizing
2778
2839
  * @ko resize 이후에 position을 업데이트합니다
@@ -5528,11 +5589,13 @@ version: 4.8.1
5528
5589
  } : {
5529
5590
  height: panelSize
5530
5591
  };
5531
- var firstPanelSizeObj = {
5592
+
5593
+ var firstPanelSizeObj = __assign({
5532
5594
  size: panelSize,
5533
- height: referencePanel.height,
5534
5595
  margin: referencePanel.margin
5535
- };
5596
+ }, !flicking.horizontal && {
5597
+ height: referencePanel.height
5598
+ });
5536
5599
 
5537
5600
  if (!flicking.noPanelStyleOverride) {
5538
5601
  this._strategy.updatePanelSizes(flicking, panelSizeObj);
@@ -6066,17 +6129,32 @@ version: 4.8.1
6066
6129
 
6067
6130
 
6068
6131
  __proto.resize = function (cached) {
6132
+ var _a;
6133
+
6069
6134
  var el = this.element;
6070
6135
  var flicking = this._flicking;
6071
- var horizontal = flicking.horizontal;
6136
+ var horizontal = flicking.horizontal,
6137
+ useFractionalSize = flicking.useFractionalSize;
6072
6138
 
6073
6139
  if (cached) {
6074
6140
  this._size = cached.size;
6075
6141
  this._margin = __assign({}, cached.margin);
6076
- this._height = cached.height;
6142
+ this._height = (_a = cached.height) !== null && _a !== void 0 ? _a : getElementSize({
6143
+ el: el,
6144
+ horizontal: false,
6145
+ useFractionalSize: useFractionalSize,
6146
+ useOffset: true,
6147
+ style: getStyle(el)
6148
+ });
6077
6149
  } else {
6078
6150
  var elStyle = getStyle(el);
6079
- this._size = horizontal ? el.offsetWidth : el.offsetHeight;
6151
+ this._size = getElementSize({
6152
+ el: el,
6153
+ horizontal: horizontal,
6154
+ useFractionalSize: useFractionalSize,
6155
+ useOffset: true,
6156
+ style: elStyle
6157
+ });
6080
6158
  this._margin = horizontal ? {
6081
6159
  prev: parseFloat(elStyle.marginLeft || "0"),
6082
6160
  next: parseFloat(elStyle.marginRight || "0")
@@ -6084,7 +6162,13 @@ version: 4.8.1
6084
6162
  prev: parseFloat(elStyle.marginTop || "0"),
6085
6163
  next: parseFloat(elStyle.marginBottom || "0")
6086
6164
  };
6087
- this._height = horizontal ? el.offsetHeight : this._size;
6165
+ this._height = horizontal ? getElementSize({
6166
+ el: el,
6167
+ horizontal: false,
6168
+ useFractionalSize: useFractionalSize,
6169
+ useOffset: true,
6170
+ style: elStyle
6171
+ }) : this._size;
6088
6172
  }
6089
6173
 
6090
6174
  this.updatePosition();
@@ -6794,10 +6878,12 @@ version: 4.8.1
6794
6878
  resizeDebounce = _8 === void 0 ? 0 : _8,
6795
6879
  _9 = _b.maxResizeDebounce,
6796
6880
  maxResizeDebounce = _9 === void 0 ? 100 : _9,
6797
- _10 = _b.externalRenderer,
6798
- externalRenderer = _10 === void 0 ? null : _10,
6799
- _11 = _b.renderExternal,
6800
- renderExternal = _11 === void 0 ? null : _11;
6881
+ _10 = _b.useFractionalSize,
6882
+ useFractionalSize = _10 === void 0 ? false : _10,
6883
+ _11 = _b.externalRenderer,
6884
+ externalRenderer = _11 === void 0 ? null : _11,
6885
+ _12 = _b.renderExternal,
6886
+ renderExternal = _12 === void 0 ? null : _12;
6801
6887
 
6802
6888
  var _this = _super.call(this) || this; // Internal states
6803
6889
 
@@ -6837,10 +6923,11 @@ version: 4.8.1
6837
6923
  _this._useResizeObserver = useResizeObserver;
6838
6924
  _this._resizeDebounce = resizeDebounce;
6839
6925
  _this._maxResizeDebounce = maxResizeDebounce;
6926
+ _this._useFractionalSize = useFractionalSize;
6840
6927
  _this._externalRenderer = externalRenderer;
6841
6928
  _this._renderExternal = renderExternal; // Create core components
6842
6929
 
6843
- _this._viewport = new Viewport(getElement(root));
6930
+ _this._viewport = new Viewport(_this, getElement(root));
6844
6931
  _this._autoResizer = new AutoResizer(_this);
6845
6932
  _this._renderer = _this._createRenderer();
6846
6933
  _this._camera = _this._createCamera();
@@ -7753,6 +7840,23 @@ version: 4.8.1
7753
7840
  enumerable: false,
7754
7841
  configurable: true
7755
7842
  });
7843
+ Object.defineProperty(__proto, "useFractionalSize", {
7844
+ /**
7845
+ * By enabling this, Flicking will calculate all internal size with CSS width computed with getComputedStyle.
7846
+ * This can prevent 1px offset issue in some cases where panel size has the fractional part.
7847
+ * All sizes will have the original size before CSS {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform} is applied on the element.
7848
+ * @ko 이 옵션을 활성화할 경우, Flicking은 내부의 모든 크기를 {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect getBoundingClientRect}를 이용하여 계산합니다.
7849
+ * 이를 통해, 패널 크기에 소수점을 포함할 경우에 발생할 수 있는 일부 1px 오프셋 이슈를 해결 가능합니다.
7850
+ * 모든 크기는 CSS {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform}이 엘리먼트에 적용되기 이전의 크기를 사용할 것입니다.
7851
+ * @type {boolean}
7852
+ * @default false
7853
+ */
7854
+ get: function () {
7855
+ return this._useFractionalSize;
7856
+ },
7857
+ enumerable: false,
7858
+ configurable: true
7859
+ });
7756
7860
  Object.defineProperty(__proto, "externalRenderer", {
7757
7861
  /**
7758
7862
  * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
@@ -8017,6 +8121,10 @@ version: 4.8.1
8017
8121
  return Promise.reject(new FlickingError(MESSAGE.ANIMATION_ALREADY_PLAYING, CODE.ANIMATION_ALREADY_PLAYING));
8018
8122
  }
8019
8123
 
8124
+ if (this._control.holding) {
8125
+ this._control.controller.release();
8126
+ }
8127
+
8020
8128
  return this._control.moveToPanel(panel, {
8021
8129
  duration: duration,
8022
8130
  direction: direction
@@ -8501,9 +8609,10 @@ version: 4.8.1
8501
8609
  var renderer = this._renderer;
8502
8610
  var control = this._control;
8503
8611
  var camera = this._camera;
8504
- var initialPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
8505
- if (!initialPanel) return;
8506
- var nearestAnchor = camera.findNearestAnchor(initialPanel.position);
8612
+ var defaultPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
8613
+ if (!defaultPanel) return;
8614
+ var nearestAnchor = camera.findNearestAnchor(defaultPanel.position);
8615
+ var initialPanel = nearestAnchor && defaultPanel.index !== nearestAnchor.panel.index ? nearestAnchor.panel : defaultPanel;
8507
8616
  control.setActive(initialPanel, null, false);
8508
8617
 
8509
8618
  if (!nearestAnchor) {
@@ -8564,7 +8673,7 @@ version: 4.8.1
8564
8673
  */
8565
8674
 
8566
8675
 
8567
- Flicking.VERSION = "4.8.1";
8676
+ Flicking.VERSION = "4.9.2";
8568
8677
  return Flicking;
8569
8678
  }(Component);
8570
8679