@egjs/flicking 4.7.3 → 4.9.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.
- package/TODO.md +3 -0
- package/declaration/Flicking.d.ts +8 -1
- package/declaration/core/Viewport.d.ts +3 -1
- package/declaration/utils.d.ts +7 -0
- package/dist/flicking.esm.js +151 -39
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +151 -38
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +265 -133
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +2 -2
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/package.json +2 -2
- package/src/Flicking.ts +32 -1
- package/src/control/AxesController.ts +1 -1
- package/src/control/SnapControl.ts +16 -4
- package/src/control/StrictControl.ts +5 -1
- package/src/control/states/AnimatingState.ts +6 -0
- package/src/core/FlickingError.ts +1 -1
- package/src/core/Viewport.ts +23 -4
- package/src/core/panel/Panel.ts +23 -4
- package/src/utils.ts +42 -0
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.
|
|
7
|
+
version: 4.9.0
|
|
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.7.3
|
|
|
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.7.3
|
|
|
814
837
|
isBetween: isBetween,
|
|
815
838
|
circulateIndex: circulateIndex,
|
|
816
839
|
range: range,
|
|
840
|
+
getElementSize: getElementSize,
|
|
817
841
|
setPrototypeOf: setPrototypeOf
|
|
818
842
|
};
|
|
819
843
|
|
|
@@ -826,7 +850,7 @@ version: 4.7.3
|
|
|
826
850
|
* @ko Flicking 내부에서 알려진 오류 발생시 throw되는 에러
|
|
827
851
|
* @property {number} code Error code<ko>에러 코드</ko>
|
|
828
852
|
* @property {string} message Error message<ko>에러 메시지</ko>
|
|
829
|
-
* @see {@link
|
|
853
|
+
* @see {@link ERROR_CODE ERROR_CODE}
|
|
830
854
|
* @example
|
|
831
855
|
* ```ts
|
|
832
856
|
* import Flicking, { FlickingError, ERROR_CODES } from "@egjs/flicking";
|
|
@@ -862,10 +886,6 @@ version: 4.7.3
|
|
|
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.7.3
|
|
|
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.7.3
|
|
|
993
1014
|
__proto.resize = function () {
|
|
994
1015
|
var el = this._el;
|
|
995
1016
|
var elStyle = getStyle(el);
|
|
996
|
-
|
|
997
|
-
this.
|
|
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,
|
|
@@ -1985,8 +2019,15 @@ version: 4.7.3
|
|
|
1985
2019
|
var flicking = ctx.flicking,
|
|
1986
2020
|
axesEvent = ctx.axesEvent,
|
|
1987
2021
|
transitTo = ctx.transitTo;
|
|
2022
|
+
var targetPanel = this._targetPanel;
|
|
2023
|
+
var control = flicking.control;
|
|
1988
2024
|
this._delta = 0;
|
|
1989
2025
|
flicking.control.updateInput();
|
|
2026
|
+
|
|
2027
|
+
if (flicking.changeOnHold && targetPanel) {
|
|
2028
|
+
control.setActive(targetPanel, control.activePanel, axesEvent.isTrusted);
|
|
2029
|
+
}
|
|
2030
|
+
|
|
1990
2031
|
var holdStartEvent = new Component.ComponentEvent(EVENTS.HOLD_START, {
|
|
1991
2032
|
axesEvent: axesEvent
|
|
1992
2033
|
});
|
|
@@ -2193,7 +2234,9 @@ version: 4.7.3
|
|
|
2193
2234
|
};
|
|
2194
2235
|
|
|
2195
2236
|
this._onAxesChange = function () {
|
|
2196
|
-
|
|
2237
|
+
var _a;
|
|
2238
|
+
|
|
2239
|
+
_this._dragged = !!((_a = _this._panInput) === null || _a === void 0 ? void 0 : _a.isEnabled());
|
|
2197
2240
|
};
|
|
2198
2241
|
|
|
2199
2242
|
this._preventClickWhenDragged = function (e) {
|
|
@@ -3156,7 +3199,7 @@ version: 4.7.3
|
|
|
3156
3199
|
var camera = flicking.camera;
|
|
3157
3200
|
var activeAnchor = camera.findActiveAnchor();
|
|
3158
3201
|
var anchorAtCamera = camera.findNearestAnchor(camera.position);
|
|
3159
|
-
var state =
|
|
3202
|
+
var state = this._controller.state;
|
|
3160
3203
|
|
|
3161
3204
|
if (!activeAnchor || !anchorAtCamera) {
|
|
3162
3205
|
return Promise.reject(new FlickingError(MESSAGE.POSITION_NOT_REACHABLE(position), CODE.POSITION_NOT_REACHABLE));
|
|
@@ -3174,10 +3217,13 @@ version: 4.7.3
|
|
|
3174
3217
|
targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
|
|
3175
3218
|
} else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
|
|
3176
3219
|
// Move to the adjacent panel
|
|
3177
|
-
targetAnchor = this._findAdjacentAnchor(posDelta, anchorAtCamera);
|
|
3220
|
+
targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
|
|
3178
3221
|
} else {
|
|
3179
3222
|
// Restore to active panel
|
|
3180
|
-
|
|
3223
|
+
return this.moveToPanel(activeAnchor.panel, {
|
|
3224
|
+
duration: duration,
|
|
3225
|
+
axesEvent: axesEvent
|
|
3226
|
+
});
|
|
3181
3227
|
}
|
|
3182
3228
|
|
|
3183
3229
|
this._triggerIndexChangeEvent(targetAnchor.panel, position, axesEvent);
|
|
@@ -3248,11 +3294,20 @@ version: 4.7.3
|
|
|
3248
3294
|
}
|
|
3249
3295
|
};
|
|
3250
3296
|
|
|
3251
|
-
__proto._findAdjacentAnchor = function (posDelta, anchorAtCamera) {
|
|
3297
|
+
__proto._findAdjacentAnchor = function (position, posDelta, anchorAtCamera) {
|
|
3252
3298
|
var _a;
|
|
3253
3299
|
|
|
3254
3300
|
var flicking = getFlickingAttached(this._flicking);
|
|
3255
3301
|
var camera = flicking.camera;
|
|
3302
|
+
|
|
3303
|
+
if (camera.circularEnabled) {
|
|
3304
|
+
var anchorIncludePosition = camera.findAnchorIncludePosition(position);
|
|
3305
|
+
|
|
3306
|
+
if (anchorIncludePosition && anchorIncludePosition.position !== anchorAtCamera.position) {
|
|
3307
|
+
return anchorIncludePosition;
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
|
|
3256
3311
|
var adjacentAnchor = (_a = posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) !== null && _a !== void 0 ? _a : anchorAtCamera;
|
|
3257
3312
|
return adjacentAnchor;
|
|
3258
3313
|
};
|
|
@@ -3598,6 +3653,7 @@ version: 4.7.3
|
|
|
3598
3653
|
var axesRange = this._controller.range;
|
|
3599
3654
|
var indexRange = this._indexRange;
|
|
3600
3655
|
var cameraRange = camera.range;
|
|
3656
|
+
var state = this._controller.state;
|
|
3601
3657
|
var clampedPosition = clamp(camera.clampToReachablePosition(position), axesRange[0], axesRange[1]);
|
|
3602
3658
|
var anchorAtPosition = camera.findAnchorIncludePosition(clampedPosition);
|
|
3603
3659
|
|
|
@@ -3606,7 +3662,8 @@ version: 4.7.3
|
|
|
3606
3662
|
}
|
|
3607
3663
|
|
|
3608
3664
|
var prevPos = activePanel.position;
|
|
3609
|
-
var
|
|
3665
|
+
var posDelta = flicking.animating ? state.delta : position - camera.position;
|
|
3666
|
+
var isOverThreshold = Math.abs(posDelta) >= flicking.threshold;
|
|
3610
3667
|
var adjacentAnchor = position > prevPos ? camera.getNextAnchor(anchorAtPosition) : camera.getPrevAnchor(anchorAtPosition);
|
|
3611
3668
|
var targetPos;
|
|
3612
3669
|
var targetPanel;
|
|
@@ -6045,7 +6102,8 @@ version: 4.7.3
|
|
|
6045
6102
|
__proto.resize = function (cached) {
|
|
6046
6103
|
var el = this.element;
|
|
6047
6104
|
var flicking = this._flicking;
|
|
6048
|
-
var horizontal = flicking.horizontal
|
|
6105
|
+
var horizontal = flicking.horizontal,
|
|
6106
|
+
useFractionalSize = flicking.useFractionalSize;
|
|
6049
6107
|
|
|
6050
6108
|
if (cached) {
|
|
6051
6109
|
this._size = cached.size;
|
|
@@ -6053,7 +6111,13 @@ version: 4.7.3
|
|
|
6053
6111
|
this._height = cached.height;
|
|
6054
6112
|
} else {
|
|
6055
6113
|
var elStyle = getStyle(el);
|
|
6056
|
-
this._size =
|
|
6114
|
+
this._size = getElementSize({
|
|
6115
|
+
el: el,
|
|
6116
|
+
horizontal: horizontal,
|
|
6117
|
+
useFractionalSize: useFractionalSize,
|
|
6118
|
+
useOffset: true,
|
|
6119
|
+
style: elStyle
|
|
6120
|
+
});
|
|
6057
6121
|
this._margin = horizontal ? {
|
|
6058
6122
|
prev: parseFloat(elStyle.marginLeft || "0"),
|
|
6059
6123
|
next: parseFloat(elStyle.marginRight || "0")
|
|
@@ -6061,7 +6125,13 @@ version: 4.7.3
|
|
|
6061
6125
|
prev: parseFloat(elStyle.marginTop || "0"),
|
|
6062
6126
|
next: parseFloat(elStyle.marginBottom || "0")
|
|
6063
6127
|
};
|
|
6064
|
-
this._height = horizontal ?
|
|
6128
|
+
this._height = horizontal ? getElementSize({
|
|
6129
|
+
el: el,
|
|
6130
|
+
horizontal: false,
|
|
6131
|
+
useFractionalSize: useFractionalSize,
|
|
6132
|
+
useOffset: true,
|
|
6133
|
+
style: elStyle
|
|
6134
|
+
}) : this._size;
|
|
6065
6135
|
}
|
|
6066
6136
|
|
|
6067
6137
|
this.updatePosition();
|
|
@@ -6755,24 +6825,28 @@ version: 4.7.3
|
|
|
6755
6825
|
preventClickOnDrag = _0 === void 0 ? true : _0,
|
|
6756
6826
|
_1 = _b.disableOnInit,
|
|
6757
6827
|
disableOnInit = _1 === void 0 ? false : _1,
|
|
6758
|
-
_2 = _b.
|
|
6759
|
-
|
|
6760
|
-
_3 = _b.
|
|
6761
|
-
|
|
6762
|
-
_4 = _b.
|
|
6763
|
-
|
|
6764
|
-
_5 = _b.
|
|
6765
|
-
|
|
6766
|
-
_6 = _b.
|
|
6767
|
-
|
|
6768
|
-
_7 = _b.
|
|
6769
|
-
|
|
6770
|
-
_8 = _b.
|
|
6771
|
-
|
|
6772
|
-
_9 = _b.
|
|
6773
|
-
|
|
6774
|
-
_10 = _b.
|
|
6775
|
-
|
|
6828
|
+
_2 = _b.changeOnHold,
|
|
6829
|
+
changeOnHold = _2 === void 0 ? false : _2,
|
|
6830
|
+
_3 = _b.renderOnlyVisible,
|
|
6831
|
+
renderOnlyVisible = _3 === void 0 ? false : _3,
|
|
6832
|
+
_4 = _b.virtual,
|
|
6833
|
+
virtual = _4 === void 0 ? null : _4,
|
|
6834
|
+
_5 = _b.autoInit,
|
|
6835
|
+
autoInit = _5 === void 0 ? true : _5,
|
|
6836
|
+
_6 = _b.autoResize,
|
|
6837
|
+
autoResize = _6 === void 0 ? true : _6,
|
|
6838
|
+
_7 = _b.useResizeObserver,
|
|
6839
|
+
useResizeObserver = _7 === void 0 ? true : _7,
|
|
6840
|
+
_8 = _b.resizeDebounce,
|
|
6841
|
+
resizeDebounce = _8 === void 0 ? 0 : _8,
|
|
6842
|
+
_9 = _b.maxResizeDebounce,
|
|
6843
|
+
maxResizeDebounce = _9 === void 0 ? 100 : _9,
|
|
6844
|
+
_10 = _b.useFractionalSize,
|
|
6845
|
+
useFractionalSize = _10 === void 0 ? false : _10,
|
|
6846
|
+
_11 = _b.externalRenderer,
|
|
6847
|
+
externalRenderer = _11 === void 0 ? null : _11,
|
|
6848
|
+
_12 = _b.renderExternal,
|
|
6849
|
+
renderExternal = _12 === void 0 ? null : _12;
|
|
6776
6850
|
|
|
6777
6851
|
var _this = _super.call(this) || this; // Internal states
|
|
6778
6852
|
|
|
@@ -6805,16 +6879,18 @@ version: 4.7.3
|
|
|
6805
6879
|
_this._iOSEdgeSwipeThreshold = iOSEdgeSwipeThreshold;
|
|
6806
6880
|
_this._preventClickOnDrag = preventClickOnDrag;
|
|
6807
6881
|
_this._disableOnInit = disableOnInit;
|
|
6882
|
+
_this._changeOnHold = changeOnHold;
|
|
6808
6883
|
_this._renderOnlyVisible = renderOnlyVisible;
|
|
6809
6884
|
_this._autoInit = autoInit;
|
|
6810
6885
|
_this._autoResize = autoResize;
|
|
6811
6886
|
_this._useResizeObserver = useResizeObserver;
|
|
6812
6887
|
_this._resizeDebounce = resizeDebounce;
|
|
6813
6888
|
_this._maxResizeDebounce = maxResizeDebounce;
|
|
6889
|
+
_this._useFractionalSize = useFractionalSize;
|
|
6814
6890
|
_this._externalRenderer = externalRenderer;
|
|
6815
6891
|
_this._renderExternal = renderExternal; // Create core components
|
|
6816
6892
|
|
|
6817
|
-
_this._viewport = new Viewport(getElement(root));
|
|
6893
|
+
_this._viewport = new Viewport(_this, getElement(root));
|
|
6818
6894
|
_this._autoResizer = new AutoResizer(_this);
|
|
6819
6895
|
_this._renderer = _this._createRenderer();
|
|
6820
6896
|
_this._camera = _this._createCamera();
|
|
@@ -7561,6 +7637,24 @@ version: 4.7.3
|
|
|
7561
7637
|
enumerable: false,
|
|
7562
7638
|
configurable: true
|
|
7563
7639
|
});
|
|
7640
|
+
Object.defineProperty(__proto, "changeOnHold", {
|
|
7641
|
+
/**
|
|
7642
|
+
* Change active panel index on mouse/touch hold while animating.
|
|
7643
|
+
* `index` of the `willChange`/`willRestore` event will be used as new index.
|
|
7644
|
+
* @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
|
|
7645
|
+
* `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
|
|
7646
|
+
* @type {boolean}
|
|
7647
|
+
* @default false
|
|
7648
|
+
*/
|
|
7649
|
+
get: function () {
|
|
7650
|
+
return this._changeOnHold;
|
|
7651
|
+
},
|
|
7652
|
+
set: function (val) {
|
|
7653
|
+
this._changeOnHold = val;
|
|
7654
|
+
},
|
|
7655
|
+
enumerable: false,
|
|
7656
|
+
configurable: true
|
|
7657
|
+
});
|
|
7564
7658
|
Object.defineProperty(__proto, "renderOnlyVisible", {
|
|
7565
7659
|
// PERFORMANCE
|
|
7566
7660
|
|
|
@@ -7709,6 +7803,23 @@ version: 4.7.3
|
|
|
7709
7803
|
enumerable: false,
|
|
7710
7804
|
configurable: true
|
|
7711
7805
|
});
|
|
7806
|
+
Object.defineProperty(__proto, "useFractionalSize", {
|
|
7807
|
+
/**
|
|
7808
|
+
* By enabling this, Flicking will calculate all internal size with CSS width computed with getComputedStyle.
|
|
7809
|
+
* This can prevent 1px offset issue in some cases where panel size has the fractional part.
|
|
7810
|
+
* 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.
|
|
7811
|
+
* @ko 이 옵션을 활성화할 경우, Flicking은 내부의 모든 크기를 {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect getBoundingClientRect}를 이용하여 계산합니다.
|
|
7812
|
+
* 이를 통해, 패널 크기에 소수점을 포함할 경우에 발생할 수 있는 일부 1px 오프셋 이슈를 해결 가능합니다.
|
|
7813
|
+
* 모든 크기는 CSS {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform}이 엘리먼트에 적용되기 이전의 크기를 사용할 것입니다.
|
|
7814
|
+
* @type {boolean}
|
|
7815
|
+
* @default false
|
|
7816
|
+
*/
|
|
7817
|
+
get: function () {
|
|
7818
|
+
return this._useFractionalSize;
|
|
7819
|
+
},
|
|
7820
|
+
enumerable: false,
|
|
7821
|
+
configurable: true
|
|
7822
|
+
});
|
|
7712
7823
|
Object.defineProperty(__proto, "externalRenderer", {
|
|
7713
7824
|
/**
|
|
7714
7825
|
* This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
|
|
@@ -8241,6 +8352,8 @@ version: 4.7.3
|
|
|
8241
8352
|
camera.updateAlignPos();
|
|
8242
8353
|
camera.updateRange();
|
|
8243
8354
|
camera.updateAnchors();
|
|
8355
|
+
camera.updateAdaptiveHeight();
|
|
8356
|
+
camera.updateOffset();
|
|
8244
8357
|
return [4
|
|
8245
8358
|
/*yield*/
|
|
8246
8359
|
, renderer.render()];
|
|
@@ -8518,7 +8631,7 @@ version: 4.7.3
|
|
|
8518
8631
|
*/
|
|
8519
8632
|
|
|
8520
8633
|
|
|
8521
|
-
Flicking.VERSION = "4.
|
|
8634
|
+
Flicking.VERSION = "4.9.0";
|
|
8522
8635
|
return Flicking;
|
|
8523
8636
|
}(Component);
|
|
8524
8637
|
|