@egjs/flicking 4.14.2-beta.0 → 4.14.2-beta.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/declaration/Flicking.d.ts +10 -1
- package/declaration/renderer/Renderer.d.ts +1 -0
- package/dist/flicking.cjs.js +114 -18
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +114 -18
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +114 -18
- 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 +165 -69
- 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 +1 -1
- package/src/Flicking.ts +60 -6
- package/src/cfc/getRenderingPanels.ts +9 -5
- package/src/control/AxesController.ts +2 -2
- package/src/control/Control.ts +1 -1
- package/src/renderer/Renderer.ts +20 -0
- package/src/renderer/VanillaRenderer.ts +11 -3
package/package.json
CHANGED
package/src/Flicking.ts
CHANGED
|
@@ -118,6 +118,8 @@ export interface FlickingOptions {
|
|
|
118
118
|
| MoveTypeOptions<ValueOf<typeof MOVE_TYPE>>;
|
|
119
119
|
threshold: number;
|
|
120
120
|
dragThreshold: number;
|
|
121
|
+
animationThreshold: number;
|
|
122
|
+
useCSSOrder: boolean;
|
|
121
123
|
interruptable: boolean;
|
|
122
124
|
bounce: number | string | [number | string, number | string];
|
|
123
125
|
iOSEdgeSwipeThreshold: number;
|
|
@@ -200,6 +202,9 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
200
202
|
private _moveType: FlickingOptions["moveType"];
|
|
201
203
|
private _threshold: FlickingOptions["threshold"];
|
|
202
204
|
private _dragThreshold: FlickingOptions["dragThreshold"];
|
|
205
|
+
private _animationThreshold: FlickingOptions["animationThreshold"];
|
|
206
|
+
private _useCSSOrder: FlickingOptions["useCSSOrder"];
|
|
207
|
+
|
|
203
208
|
private _interruptable: FlickingOptions["interruptable"];
|
|
204
209
|
private _bounce: FlickingOptions["bounce"];
|
|
205
210
|
private _iOSEdgeSwipeThreshold: FlickingOptions["iOSEdgeSwipeThreshold"];
|
|
@@ -225,6 +230,7 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
225
230
|
private _initialized: boolean;
|
|
226
231
|
private _plugins: Plugin[];
|
|
227
232
|
private _isResizing: boolean;
|
|
233
|
+
private _scheduleResize = false;
|
|
228
234
|
|
|
229
235
|
// Components
|
|
230
236
|
/**
|
|
@@ -703,6 +709,30 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
703
709
|
public get dragThreshold() {
|
|
704
710
|
return this._dragThreshold;
|
|
705
711
|
}
|
|
712
|
+
/**
|
|
713
|
+
* The minimum distance for animation to proceed. If the distance to be moved is less than `animationThreshold`, the movement proceeds immediately without animation (duration: 0).
|
|
714
|
+
* @ko animation이 진행되기 위한 최소한의 거리. 이동하려는 거리가 `animationThreshold`보다 적으면 애니메이션 없이(duration: 0) 즉시 이동한다.
|
|
715
|
+
* @type {number}
|
|
716
|
+
* @default 0.5
|
|
717
|
+
* @see {@link https://naver.github.io/egjs-flicking/Options#animationThreshold animationThreshold ( Options )}
|
|
718
|
+
*/
|
|
719
|
+
public get animationThreshold() {
|
|
720
|
+
return this._animationThreshold;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Using `useCSSOrder` does not change the DOM order, but the `order` CSS property changes the order on the screen. (When `circular` is used, the DOM order changes depending on the position.)
|
|
724
|
+
* When using `iframe`, you can prevent reloading when the DOM order changes.
|
|
725
|
+
* In svelte, CSS order is always used.
|
|
726
|
+
* @ko `useCSSOrder`를 사용하면 DOM의 순서는 변경되지 않지만 `order` css가 설정되면서 화면상 순서가 바뀐다. (`circular`를 사용한 경우 위치에 따라 DOM의 순서가 변경된다.)
|
|
727
|
+
* `iframe`을 사용하는 경우 DOM의 순서가 변경되면서 reload가 되는 것을 막을 수 있다.
|
|
728
|
+
* svelte에서는 css order를 무조건 사용한다.
|
|
729
|
+
* @type {boolean}
|
|
730
|
+
* @default false
|
|
731
|
+
* @see {@link https://naver.github.io/egjs-flicking/Options#useCSSOrder useCSSOrder ( Options )}
|
|
732
|
+
*/
|
|
733
|
+
public get useCSSOrder() {
|
|
734
|
+
return this._useCSSOrder;
|
|
735
|
+
}
|
|
706
736
|
|
|
707
737
|
/**
|
|
708
738
|
* Set animation to be interruptable by click/touch.
|
|
@@ -1117,6 +1147,12 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1117
1147
|
panInput.options.threshold = val;
|
|
1118
1148
|
}
|
|
1119
1149
|
}
|
|
1150
|
+
public set animationThreshold(val: FlickingOptions["animationThreshold"]) {
|
|
1151
|
+
this._animationThreshold = val;
|
|
1152
|
+
}
|
|
1153
|
+
public set useCSSOrder(val: FlickingOptions["useCSSOrder"]) {
|
|
1154
|
+
this._useCSSOrder = val;
|
|
1155
|
+
}
|
|
1120
1156
|
|
|
1121
1157
|
public set interruptable(val: FlickingOptions["interruptable"]) {
|
|
1122
1158
|
this._interruptable = val;
|
|
@@ -1291,7 +1327,9 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1291
1327
|
useFractionalSize = false,
|
|
1292
1328
|
externalRenderer = null,
|
|
1293
1329
|
renderExternal = null,
|
|
1294
|
-
optimizeSizeUpdate = false
|
|
1330
|
+
optimizeSizeUpdate = false,
|
|
1331
|
+
animationThreshold = 0.5,
|
|
1332
|
+
useCSSOrder = false,
|
|
1295
1333
|
}: Partial<FlickingOptions> = {}) {
|
|
1296
1334
|
super();
|
|
1297
1335
|
|
|
@@ -1340,6 +1378,8 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1340
1378
|
this._externalRenderer = externalRenderer;
|
|
1341
1379
|
this._renderExternal = renderExternal;
|
|
1342
1380
|
this._optimizeSizeUpdate = optimizeSizeUpdate;
|
|
1381
|
+
this._animationThreshold = animationThreshold;
|
|
1382
|
+
this._useCSSOrder = useCSSOrder;
|
|
1343
1383
|
|
|
1344
1384
|
// Create core components
|
|
1345
1385
|
this._viewport = new Viewport(this, getElement(root));
|
|
@@ -1423,7 +1463,9 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1423
1463
|
|
|
1424
1464
|
this._plugins.forEach((plugin) => plugin.destroy());
|
|
1425
1465
|
|
|
1466
|
+
this._scheduleResize = false;
|
|
1426
1467
|
this._initialized = false;
|
|
1468
|
+
this._isResizing = false;
|
|
1427
1469
|
}
|
|
1428
1470
|
|
|
1429
1471
|
/**
|
|
@@ -1821,11 +1863,17 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1821
1863
|
* @method
|
|
1822
1864
|
* @fires Flicking#beforeResize
|
|
1823
1865
|
* @fires Flicking#afterResize
|
|
1824
|
-
* @return {
|
|
1866
|
+
* @return {boolean}
|
|
1825
1867
|
*/
|
|
1826
1868
|
public async resize(): Promise<void> {
|
|
1827
|
-
if (this.
|
|
1828
|
-
|
|
1869
|
+
if (!this._initialized) {
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
if (this._isResizing) {
|
|
1873
|
+
this._scheduleResize = true;
|
|
1874
|
+
return;
|
|
1875
|
+
}
|
|
1876
|
+
this._scheduleResize = false;
|
|
1829
1877
|
this._isResizing = true;
|
|
1830
1878
|
|
|
1831
1879
|
const viewport = this._viewport;
|
|
@@ -1872,6 +1920,7 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1872
1920
|
camera.updatePanelOrder();
|
|
1873
1921
|
camera.updateOffset();
|
|
1874
1922
|
await renderer.render();
|
|
1923
|
+
|
|
1875
1924
|
if (!this._initialized) {
|
|
1876
1925
|
return;
|
|
1877
1926
|
}
|
|
@@ -1901,6 +1950,11 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1901
1950
|
);
|
|
1902
1951
|
|
|
1903
1952
|
this._isResizing = false;
|
|
1953
|
+
|
|
1954
|
+
if (this._scheduleResize) {
|
|
1955
|
+
this.resize();
|
|
1956
|
+
}
|
|
1957
|
+
return;
|
|
1904
1958
|
}
|
|
1905
1959
|
|
|
1906
1960
|
/**
|
|
@@ -2098,8 +2152,8 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
2098
2152
|
const nearestAnchor = camera.findNearestAnchor(defaultPanel.position);
|
|
2099
2153
|
const initialPanel =
|
|
2100
2154
|
nearestAnchor &&
|
|
2101
|
-
|
|
2102
|
-
|
|
2155
|
+
defaultPanel.position !== nearestAnchor.panel.position &&
|
|
2156
|
+
defaultPanel.index !== nearestAnchor.panel.index
|
|
2103
2157
|
? nearestAnchor.panel
|
|
2104
2158
|
: defaultPanel;
|
|
2105
2159
|
control.setActive(initialPanel, null, false);
|
|
@@ -12,13 +12,17 @@ export default <T>(flicking: Flicking, diffResult: DiffResult<T>) => {
|
|
|
12
12
|
map[prev] = current;
|
|
13
13
|
return map;
|
|
14
14
|
}, {});
|
|
15
|
+
const renderingPanels = flicking.panels
|
|
16
|
+
.filter(panel => !removedPanels[panel.index]);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if (!flicking.useCSSOrder) {
|
|
20
|
+
// useCSSOrder를 사용하게 되는 경우 sort를 하지 않는다.
|
|
21
|
+
renderingPanels.sort((panel1, panel2) => (panel1.position + panel1.offset) - (panel2.position + panel2.offset));
|
|
22
|
+
}
|
|
15
23
|
|
|
16
24
|
return [
|
|
17
|
-
...
|
|
18
|
-
.filter(panel => !removedPanels[panel.index])
|
|
19
|
-
// Sort panels by position
|
|
20
|
-
.sort((panel1, panel2) => (panel1.position + panel1.offset) - (panel2.position + panel2.offset))
|
|
21
|
-
.map(panel => diffResult.list[maintainedMap[panel.index]]),
|
|
25
|
+
...renderingPanels.map(panel => diffResult.list[maintainedMap[panel.index]]),
|
|
22
26
|
...diffResult.added.map(idx => diffResult.list[idx])
|
|
23
27
|
];
|
|
24
28
|
};
|
|
@@ -397,8 +397,8 @@ class AxesController {
|
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
/**
|
|
400
|
-
*
|
|
401
|
-
* @
|
|
400
|
+
* Returns the current axes position
|
|
401
|
+
* @ko 현재 axes의 position을 반환합니다.
|
|
402
402
|
*/
|
|
403
403
|
public getCurrentPosition() {
|
|
404
404
|
return this._axes?.get([AXES.POSITION_KEY])[AXES.POSITION_KEY] ?? 0;
|
package/src/control/Control.ts
CHANGED
|
@@ -384,7 +384,7 @@ abstract class Control {
|
|
|
384
384
|
// 거리(1px 미만)가 매우 짧은 경우 duration이 늘어지는걸 방지하기 위해 0으로 바꿔 즉시 변경
|
|
385
385
|
let nextDuration = duration;
|
|
386
386
|
|
|
387
|
-
if (Math.abs(nextDuration - position) <
|
|
387
|
+
if (Math.abs(nextDuration - position) < flicking.animationThreshold) {
|
|
388
388
|
nextDuration = 0;
|
|
389
389
|
}
|
|
390
390
|
const animate = () => this._controller.animateTo(position, nextDuration, axesEvent);
|
package/src/renderer/Renderer.ts
CHANGED
|
@@ -152,6 +152,17 @@ abstract class Renderer {
|
|
|
152
152
|
return Promise.resolve();
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Return Rendered Panels
|
|
157
|
+
* @ko 렌더링이 된 패널을 반환합니다.
|
|
158
|
+
* @return {Panel[]}
|
|
159
|
+
*/
|
|
160
|
+
public getRenderedPanels() {
|
|
161
|
+
const flicking = getFlickingAttached(this._flicking);
|
|
162
|
+
|
|
163
|
+
return flicking.renderer.panels.filter(panel => panel.rendered);
|
|
164
|
+
}
|
|
165
|
+
|
|
155
166
|
/**
|
|
156
167
|
* Update all panel sizes
|
|
157
168
|
* @ko 모든 패널의 크기를 업데이트합니다
|
|
@@ -554,6 +565,15 @@ abstract class Renderer {
|
|
|
554
565
|
const flicking = getFlickingAttached(this._flicking);
|
|
555
566
|
|
|
556
567
|
flicking.camera.applyTransform();
|
|
568
|
+
|
|
569
|
+
if (flicking.useCSSOrder) {
|
|
570
|
+
// useCSSOrder를 사용하는 경우 DOM은 변화가 없지만 대신 CSS Order가 추가 된다.
|
|
571
|
+
const panels = flicking.panels;
|
|
572
|
+
|
|
573
|
+
this._strategy.getRenderingIndexesByOrder(flicking).forEach((domIndex, index) => {
|
|
574
|
+
panels[domIndex].element.style.order = `${index}`;
|
|
575
|
+
});
|
|
576
|
+
}
|
|
557
577
|
}
|
|
558
578
|
}
|
|
559
579
|
|
|
@@ -40,9 +40,17 @@ class VanillaRenderer extends Renderer {
|
|
|
40
40
|
const cameraEl = flicking.camera.element;
|
|
41
41
|
|
|
42
42
|
// We're using reversed panels here as last panel should be the last element of camera element
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
|
|
44
|
+
let reversedElements: HTMLElement[] = [];
|
|
45
|
+
|
|
46
|
+
if (flicking.useCSSOrder) {
|
|
47
|
+
// useCSSOrder를 사용하는 경우 원본 그대로 렌더링
|
|
48
|
+
reversedElements = this.getRenderedPanels().map(panel => panel.element).reverse();
|
|
49
|
+
} else {
|
|
50
|
+
reversedElements = this._strategy
|
|
51
|
+
.getRenderingElementsByOrder(flicking)
|
|
52
|
+
.reverse();
|
|
53
|
+
}
|
|
46
54
|
|
|
47
55
|
reversedElements.forEach((el, idx) => {
|
|
48
56
|
const nextEl = reversedElements[idx - 1] ? reversedElements[idx - 1] : null;
|