@egjs/flicking 4.14.1 → 4.14.2-beta.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 +9 -1
- package/declaration/control/AxesController.d.ts +1 -0
- package/declaration/renderer/Renderer.d.ts +1 -0
- package/dist/flicking.cjs.js +115 -19
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +115 -19
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +115 -19
- 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 +166 -70
- 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 +39 -1
- package/src/cfc/getRenderingPanels.ts +9 -5
- package/src/control/AxesController.ts +9 -1
- package/src/control/Control.ts +9 -2
- package/src/control/StrictControl.ts +3 -2
- package/src/core/AutoResizer.ts +3 -0
- 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
|
+
useCSSOrderProperty: 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 _useCSSOrderProperty: FlickingOptions["useCSSOrderProperty"];
|
|
207
|
+
|
|
203
208
|
private _interruptable: FlickingOptions["interruptable"];
|
|
204
209
|
private _bounce: FlickingOptions["bounce"];
|
|
205
210
|
private _iOSEdgeSwipeThreshold: FlickingOptions["iOSEdgeSwipeThreshold"];
|
|
@@ -703,6 +708,29 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
703
708
|
public get dragThreshold() {
|
|
704
709
|
return this._dragThreshold;
|
|
705
710
|
}
|
|
711
|
+
/**
|
|
712
|
+
* 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).
|
|
713
|
+
* @ko animation이 진행되기 위한 최소한의 거리. 이동하려는 거리가 `animationThreshold`보다 적으면 애니메이션 없이(duration: 0) 즉시 이동한다.
|
|
714
|
+
* @type {number}
|
|
715
|
+
* @default 0.5
|
|
716
|
+
* @see {@link https://naver.github.io/egjs-flicking/Options#animationThreshold animationThreshold ( Options )}
|
|
717
|
+
*/
|
|
718
|
+
public get animationThreshold() {
|
|
719
|
+
return this._animationThreshold;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* When `circular` is used, the DOM order changes depending on the position. Using `useCSSOrderProperty` does not change the DOM order, but the `order` CSS property changes the order on the screen.
|
|
723
|
+
* When using `iframe`, you can prevent reloading when the DOM order changes.
|
|
724
|
+
* @ko `circular`를 사용한 경우 위치에 따라 DOM의 순서가 변경된다. `useCSSOrderProperty`를 사용하면 DOM의 순서는 변경되지 않지만 `order` css가 설정되면서 화면상 순서가 바뀐다.
|
|
725
|
+
* `iframe`을 사용하는 경우 DOM의 순서가 변경되면서 reload가 되는 것을 막을 수 있다.
|
|
726
|
+
* @type {boolean}
|
|
727
|
+
* @requires `circular`
|
|
728
|
+
* @default false
|
|
729
|
+
* @see {@link https://naver.github.io/egjs-flicking/Options#useCSSOrderProperty animationThreshold ( Options )}
|
|
730
|
+
*/
|
|
731
|
+
public get useCSSOrderProperty() {
|
|
732
|
+
return this._useCSSOrderProperty;
|
|
733
|
+
}
|
|
706
734
|
|
|
707
735
|
/**
|
|
708
736
|
* Set animation to be interruptable by click/touch.
|
|
@@ -1117,6 +1145,12 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1117
1145
|
panInput.options.threshold = val;
|
|
1118
1146
|
}
|
|
1119
1147
|
}
|
|
1148
|
+
public set animationThreshold(val: FlickingOptions["animationThreshold"]) {
|
|
1149
|
+
this._animationThreshold = val;
|
|
1150
|
+
}
|
|
1151
|
+
public set useCSSOrderProperty(val: FlickingOptions["useCSSOrderProperty"]) {
|
|
1152
|
+
this._useCSSOrderProperty = val;
|
|
1153
|
+
}
|
|
1120
1154
|
|
|
1121
1155
|
public set interruptable(val: FlickingOptions["interruptable"]) {
|
|
1122
1156
|
this._interruptable = val;
|
|
@@ -1291,7 +1325,9 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1291
1325
|
useFractionalSize = false,
|
|
1292
1326
|
externalRenderer = null,
|
|
1293
1327
|
renderExternal = null,
|
|
1294
|
-
optimizeSizeUpdate = false
|
|
1328
|
+
optimizeSizeUpdate = false,
|
|
1329
|
+
animationThreshold = 0.5,
|
|
1330
|
+
useCSSOrderProperty = false,
|
|
1295
1331
|
}: Partial<FlickingOptions> = {}) {
|
|
1296
1332
|
super();
|
|
1297
1333
|
|
|
@@ -1340,6 +1376,8 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
1340
1376
|
this._externalRenderer = externalRenderer;
|
|
1341
1377
|
this._renderExternal = renderExternal;
|
|
1342
1378
|
this._optimizeSizeUpdate = optimizeSizeUpdate;
|
|
1379
|
+
this._animationThreshold = animationThreshold;
|
|
1380
|
+
this._useCSSOrderProperty = useCSSOrderProperty;
|
|
1343
1381
|
|
|
1344
1382
|
// Create core components
|
|
1345
1383
|
this._viewport = new Viewport(this, getElement(root));
|
|
@@ -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.useCSSOrderProperty) {
|
|
20
|
+
// useCSSOrderProperty를 사용하게 되는 경우 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
|
};
|
|
@@ -345,7 +345,7 @@ class AxesController {
|
|
|
345
345
|
return Promise.reject(new FlickingError(ERROR.MESSAGE.NOT_ATTACHED_TO_FLICKING, ERROR.CODE.NOT_ATTACHED_TO_FLICKING));
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
const startPos =
|
|
348
|
+
const startPos = this.getCurrentPosition();
|
|
349
349
|
|
|
350
350
|
if (startPos === position) {
|
|
351
351
|
const flicking = getFlickingAttached(this._flicking);
|
|
@@ -396,6 +396,14 @@ class AxesController {
|
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Returns the current axes position
|
|
401
|
+
* @ko 현재 axes의 position을 반환합니다.
|
|
402
|
+
*/
|
|
403
|
+
public getCurrentPosition() {
|
|
404
|
+
return this._axes?.get([AXES.POSITION_KEY])[AXES.POSITION_KEY] ?? 0;
|
|
405
|
+
}
|
|
406
|
+
|
|
399
407
|
public updateDirection() {
|
|
400
408
|
const flicking = getFlickingAttached(this._flicking);
|
|
401
409
|
const axes = this._axes!;
|
package/src/control/Control.ts
CHANGED
|
@@ -380,12 +380,19 @@ abstract class Control {
|
|
|
380
380
|
axesEvent?: OnRelease;
|
|
381
381
|
}) {
|
|
382
382
|
const flicking = getFlickingAttached(this._flicking);
|
|
383
|
-
|
|
383
|
+
|
|
384
|
+
// 거리(1px 미만)가 매우 짧은 경우 duration이 늘어지는걸 방지하기 위해 0으로 바꿔 즉시 변경
|
|
385
|
+
let nextDuration = duration;
|
|
386
|
+
|
|
387
|
+
if (Math.abs(nextDuration - position) < flicking.animationThreshold) {
|
|
388
|
+
nextDuration = 0;
|
|
389
|
+
}
|
|
390
|
+
const animate = () => this._controller.animateTo(position, nextDuration, axesEvent);
|
|
384
391
|
const state = this._controller.state;
|
|
385
392
|
|
|
386
393
|
state.targetPanel = newActivePanel;
|
|
387
394
|
|
|
388
|
-
if (
|
|
395
|
+
if (nextDuration <= 0) {
|
|
389
396
|
return animate();
|
|
390
397
|
} else {
|
|
391
398
|
return animate().then(async () => {
|
|
@@ -220,8 +220,9 @@ class StrictControl extends Control {
|
|
|
220
220
|
const firstAnchor = anchors[0];
|
|
221
221
|
const lastAnchor = anchors[anchors.length - 1];
|
|
222
222
|
|
|
223
|
-
|
|
224
|
-
const
|
|
223
|
+
// position이 bounce으로 인하여 범위를 넘어가야 동작하도록 변경
|
|
224
|
+
const shouldBounceToFirst = position < cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
|
|
225
|
+
const shouldBounceToLast = position > cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
|
|
225
226
|
|
|
226
227
|
const isAdjacent = adjacentAnchor && (indexRange.min <= indexRange.max
|
|
227
228
|
? isBetween(adjacentAnchor.index, indexRange.min, indexRange.max)
|
package/src/core/AutoResizer.ts
CHANGED
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.useCSSOrderProperty) {
|
|
570
|
+
// useCSSOrderProperty를 사용하는 경우 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.useCSSOrderProperty) {
|
|
47
|
+
// useCSSOrderProperty를 사용하는 경우 원본 그대로 렌더링
|
|
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;
|