@egjs/flicking 4.8.0 → 4.9.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.
- package/declaration/Flicking.d.ts +4 -1
- package/declaration/core/Viewport.d.ts +3 -1
- package/declaration/core/panel/Panel.d.ts +1 -1
- package/declaration/utils.d.ts +7 -0
- package/dist/flicking.esm.js +120 -29
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +120 -28
- 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 +215 -142
- 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 +3 -3
- package/src/Flicking.ts +20 -4
- package/src/control/AxesController.ts +1 -1
- package/src/control/SnapControl.ts +15 -3
- package/src/core/Viewport.ts +23 -4
- package/src/core/panel/Panel.ts +31 -6
- package/src/renderer/Renderer.ts +2 -2
- package/src/utils.ts +42 -0
- package/TODO.md +0 -3
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.1
|
|
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.0
|
|
|
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.0
|
|
|
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.0
|
|
|
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.0
|
|
|
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.0
|
|
|
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,
|
|
@@ -2200,7 +2234,9 @@ version: 4.8.0
|
|
|
2200
2234
|
};
|
|
2201
2235
|
|
|
2202
2236
|
this._onAxesChange = function () {
|
|
2203
|
-
|
|
2237
|
+
var _a;
|
|
2238
|
+
|
|
2239
|
+
_this._dragged = !!((_a = _this._panInput) === null || _a === void 0 ? void 0 : _a.isEnabled());
|
|
2204
2240
|
};
|
|
2205
2241
|
|
|
2206
2242
|
this._preventClickWhenDragged = function (e) {
|
|
@@ -3181,10 +3217,13 @@ version: 4.8.0
|
|
|
3181
3217
|
targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
|
|
3182
3218
|
} else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
|
|
3183
3219
|
// Move to the adjacent panel
|
|
3184
|
-
targetAnchor = this._findAdjacentAnchor(posDelta, anchorAtCamera);
|
|
3220
|
+
targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
|
|
3185
3221
|
} else {
|
|
3186
3222
|
// Restore to active panel
|
|
3187
|
-
|
|
3223
|
+
return this.moveToPanel(activeAnchor.panel, {
|
|
3224
|
+
duration: duration,
|
|
3225
|
+
axesEvent: axesEvent
|
|
3226
|
+
});
|
|
3188
3227
|
}
|
|
3189
3228
|
|
|
3190
3229
|
this._triggerIndexChangeEvent(targetAnchor.panel, position, axesEvent);
|
|
@@ -3255,11 +3294,20 @@ version: 4.8.0
|
|
|
3255
3294
|
}
|
|
3256
3295
|
};
|
|
3257
3296
|
|
|
3258
|
-
__proto._findAdjacentAnchor = function (posDelta, anchorAtCamera) {
|
|
3297
|
+
__proto._findAdjacentAnchor = function (position, posDelta, anchorAtCamera) {
|
|
3259
3298
|
var _a;
|
|
3260
3299
|
|
|
3261
3300
|
var flicking = getFlickingAttached(this._flicking);
|
|
3262
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
|
+
|
|
3263
3311
|
var adjacentAnchor = (_a = posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) !== null && _a !== void 0 ? _a : anchorAtCamera;
|
|
3264
3312
|
return adjacentAnchor;
|
|
3265
3313
|
};
|
|
@@ -5514,11 +5562,13 @@ version: 4.8.0
|
|
|
5514
5562
|
} : {
|
|
5515
5563
|
height: panelSize
|
|
5516
5564
|
};
|
|
5517
|
-
|
|
5565
|
+
|
|
5566
|
+
var firstPanelSizeObj = __assign({
|
|
5518
5567
|
size: panelSize,
|
|
5519
|
-
height: referencePanel.height,
|
|
5520
5568
|
margin: referencePanel.margin
|
|
5521
|
-
}
|
|
5569
|
+
}, !flicking.horizontal && {
|
|
5570
|
+
height: referencePanel.height
|
|
5571
|
+
});
|
|
5522
5572
|
|
|
5523
5573
|
if (!flicking.noPanelStyleOverride) {
|
|
5524
5574
|
this._strategy.updatePanelSizes(flicking, panelSizeObj);
|
|
@@ -6052,17 +6102,32 @@ version: 4.8.0
|
|
|
6052
6102
|
|
|
6053
6103
|
|
|
6054
6104
|
__proto.resize = function (cached) {
|
|
6105
|
+
var _a;
|
|
6106
|
+
|
|
6055
6107
|
var el = this.element;
|
|
6056
6108
|
var flicking = this._flicking;
|
|
6057
|
-
var horizontal = flicking.horizontal
|
|
6109
|
+
var horizontal = flicking.horizontal,
|
|
6110
|
+
useFractionalSize = flicking.useFractionalSize;
|
|
6058
6111
|
|
|
6059
6112
|
if (cached) {
|
|
6060
6113
|
this._size = cached.size;
|
|
6061
6114
|
this._margin = __assign({}, cached.margin);
|
|
6062
|
-
this._height = cached.height
|
|
6115
|
+
this._height = (_a = cached.height) !== null && _a !== void 0 ? _a : getElementSize({
|
|
6116
|
+
el: el,
|
|
6117
|
+
horizontal: false,
|
|
6118
|
+
useFractionalSize: useFractionalSize,
|
|
6119
|
+
useOffset: true,
|
|
6120
|
+
style: getStyle(el)
|
|
6121
|
+
});
|
|
6063
6122
|
} else {
|
|
6064
6123
|
var elStyle = getStyle(el);
|
|
6065
|
-
this._size =
|
|
6124
|
+
this._size = getElementSize({
|
|
6125
|
+
el: el,
|
|
6126
|
+
horizontal: horizontal,
|
|
6127
|
+
useFractionalSize: useFractionalSize,
|
|
6128
|
+
useOffset: true,
|
|
6129
|
+
style: elStyle
|
|
6130
|
+
});
|
|
6066
6131
|
this._margin = horizontal ? {
|
|
6067
6132
|
prev: parseFloat(elStyle.marginLeft || "0"),
|
|
6068
6133
|
next: parseFloat(elStyle.marginRight || "0")
|
|
@@ -6070,7 +6135,13 @@ version: 4.8.0
|
|
|
6070
6135
|
prev: parseFloat(elStyle.marginTop || "0"),
|
|
6071
6136
|
next: parseFloat(elStyle.marginBottom || "0")
|
|
6072
6137
|
};
|
|
6073
|
-
this._height = horizontal ?
|
|
6138
|
+
this._height = horizontal ? getElementSize({
|
|
6139
|
+
el: el,
|
|
6140
|
+
horizontal: false,
|
|
6141
|
+
useFractionalSize: useFractionalSize,
|
|
6142
|
+
useOffset: true,
|
|
6143
|
+
style: elStyle
|
|
6144
|
+
}) : this._size;
|
|
6074
6145
|
}
|
|
6075
6146
|
|
|
6076
6147
|
this.updatePosition();
|
|
@@ -6780,10 +6851,12 @@ version: 4.8.0
|
|
|
6780
6851
|
resizeDebounce = _8 === void 0 ? 0 : _8,
|
|
6781
6852
|
_9 = _b.maxResizeDebounce,
|
|
6782
6853
|
maxResizeDebounce = _9 === void 0 ? 100 : _9,
|
|
6783
|
-
_10 = _b.
|
|
6784
|
-
|
|
6785
|
-
_11 = _b.
|
|
6786
|
-
|
|
6854
|
+
_10 = _b.useFractionalSize,
|
|
6855
|
+
useFractionalSize = _10 === void 0 ? false : _10,
|
|
6856
|
+
_11 = _b.externalRenderer,
|
|
6857
|
+
externalRenderer = _11 === void 0 ? null : _11,
|
|
6858
|
+
_12 = _b.renderExternal,
|
|
6859
|
+
renderExternal = _12 === void 0 ? null : _12;
|
|
6787
6860
|
|
|
6788
6861
|
var _this = _super.call(this) || this; // Internal states
|
|
6789
6862
|
|
|
@@ -6823,10 +6896,11 @@ version: 4.8.0
|
|
|
6823
6896
|
_this._useResizeObserver = useResizeObserver;
|
|
6824
6897
|
_this._resizeDebounce = resizeDebounce;
|
|
6825
6898
|
_this._maxResizeDebounce = maxResizeDebounce;
|
|
6899
|
+
_this._useFractionalSize = useFractionalSize;
|
|
6826
6900
|
_this._externalRenderer = externalRenderer;
|
|
6827
6901
|
_this._renderExternal = renderExternal; // Create core components
|
|
6828
6902
|
|
|
6829
|
-
_this._viewport = new Viewport(getElement(root));
|
|
6903
|
+
_this._viewport = new Viewport(_this, getElement(root));
|
|
6830
6904
|
_this._autoResizer = new AutoResizer(_this);
|
|
6831
6905
|
_this._renderer = _this._createRenderer();
|
|
6832
6906
|
_this._camera = _this._createCamera();
|
|
@@ -7739,6 +7813,23 @@ version: 4.8.0
|
|
|
7739
7813
|
enumerable: false,
|
|
7740
7814
|
configurable: true
|
|
7741
7815
|
});
|
|
7816
|
+
Object.defineProperty(__proto, "useFractionalSize", {
|
|
7817
|
+
/**
|
|
7818
|
+
* By enabling this, Flicking will calculate all internal size with CSS width computed with getComputedStyle.
|
|
7819
|
+
* This can prevent 1px offset issue in some cases where panel size has the fractional part.
|
|
7820
|
+
* 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.
|
|
7821
|
+
* @ko 이 옵션을 활성화할 경우, Flicking은 내부의 모든 크기를 {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect getBoundingClientRect}를 이용하여 계산합니다.
|
|
7822
|
+
* 이를 통해, 패널 크기에 소수점을 포함할 경우에 발생할 수 있는 일부 1px 오프셋 이슈를 해결 가능합니다.
|
|
7823
|
+
* 모든 크기는 CSS {@link https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform}이 엘리먼트에 적용되기 이전의 크기를 사용할 것입니다.
|
|
7824
|
+
* @type {boolean}
|
|
7825
|
+
* @default false
|
|
7826
|
+
*/
|
|
7827
|
+
get: function () {
|
|
7828
|
+
return this._useFractionalSize;
|
|
7829
|
+
},
|
|
7830
|
+
enumerable: false,
|
|
7831
|
+
configurable: true
|
|
7832
|
+
});
|
|
7742
7833
|
Object.defineProperty(__proto, "externalRenderer", {
|
|
7743
7834
|
/**
|
|
7744
7835
|
* This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
|
|
@@ -8487,9 +8578,10 @@ version: 4.8.0
|
|
|
8487
8578
|
var renderer = this._renderer;
|
|
8488
8579
|
var control = this._control;
|
|
8489
8580
|
var camera = this._camera;
|
|
8490
|
-
var
|
|
8491
|
-
if (!
|
|
8492
|
-
var nearestAnchor = camera.findNearestAnchor(
|
|
8581
|
+
var defaultPanel = renderer.getPanel(this._defaultIndex) || renderer.getPanel(0);
|
|
8582
|
+
if (!defaultPanel) return;
|
|
8583
|
+
var nearestAnchor = camera.findNearestAnchor(defaultPanel.position);
|
|
8584
|
+
var initialPanel = nearestAnchor && defaultPanel.index !== nearestAnchor.panel.index ? nearestAnchor.panel : defaultPanel;
|
|
8493
8585
|
control.setActive(initialPanel, null, false);
|
|
8494
8586
|
|
|
8495
8587
|
if (!nearestAnchor) {
|
|
@@ -8550,7 +8642,7 @@ version: 4.8.0
|
|
|
8550
8642
|
*/
|
|
8551
8643
|
|
|
8552
8644
|
|
|
8553
|
-
Flicking.VERSION = "4.
|
|
8645
|
+
Flicking.VERSION = "4.9.1";
|
|
8554
8646
|
return Flicking;
|
|
8555
8647
|
}(Component);
|
|
8556
8648
|
|