@egjs/flicking 4.11.5-beta.0 → 4.11.5-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/core/AutoResizer.d.ts +1 -0
- package/dist/flicking.cjs.js +27 -6
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +27 -6
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +27 -6
- 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 +27 -6
- 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 +11 -1
- package/src/core/AutoResizer.ts +15 -3
- package/src/renderer/Renderer.ts +4 -2
package/package.json
CHANGED
package/src/Flicking.ts
CHANGED
|
@@ -218,6 +218,12 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
218
218
|
* @see Viewport
|
|
219
219
|
*/
|
|
220
220
|
public get viewport() { return this._viewport; }
|
|
221
|
+
/**
|
|
222
|
+
* {@link AutoResizer} instance of the Flicking
|
|
223
|
+
* @ko 현재 Flicking에 활성화된 {@link AutoResizer} 인스턴스
|
|
224
|
+
* @internal
|
|
225
|
+
* @readonly
|
|
226
|
+
*/
|
|
221
227
|
public get autoResizer() { return this._autoResizer; }
|
|
222
228
|
// Internal States
|
|
223
229
|
/**
|
|
@@ -907,6 +913,10 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
907
913
|
public set autoResize(val: FlickingOptions["autoResize"]) {
|
|
908
914
|
this._autoResize = val;
|
|
909
915
|
|
|
916
|
+
if (!this._initialized) {
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
|
|
910
920
|
if (val) {
|
|
911
921
|
this._autoResizer.enable();
|
|
912
922
|
} else {
|
|
@@ -917,7 +927,7 @@ class Flicking extends Component<FlickingEvents> {
|
|
|
917
927
|
public set useResizeObserver(val: FlickingOptions["useResizeObserver"]) {
|
|
918
928
|
this._useResizeObserver = val;
|
|
919
929
|
|
|
920
|
-
if (this._autoResize) {
|
|
930
|
+
if (this._initialized && this._autoResize) {
|
|
921
931
|
this._autoResizer.enable();
|
|
922
932
|
}
|
|
923
933
|
}
|
package/src/core/AutoResizer.ts
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import Flicking from "../Flicking";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A component that detects size change and trigger resize method when the autoResize option is used
|
|
9
|
+
* @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
|
|
10
|
+
*/
|
|
7
11
|
class AutoResizer {
|
|
8
12
|
private _flicking: Flicking;
|
|
9
13
|
private _enabled: boolean;
|
|
@@ -38,9 +42,9 @@ class AutoResizer {
|
|
|
38
42
|
|
|
39
43
|
[
|
|
40
44
|
flicking.viewport.element,
|
|
41
|
-
|
|
42
|
-
...flicking.panels.map(panel => panel.element)
|
|
43
|
-
].forEach((element) => { resizeObserver.observe(element) });
|
|
45
|
+
flicking.camera.element,
|
|
46
|
+
...flicking.panels.map(panel => panel.element)
|
|
47
|
+
].forEach((element) => { resizeObserver.observe(element); });
|
|
44
48
|
|
|
45
49
|
this._resizeObserver = resizeObserver;
|
|
46
50
|
} else {
|
|
@@ -68,10 +72,18 @@ class AutoResizer {
|
|
|
68
72
|
return this;
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
public observe(element: Element): this {
|
|
76
|
+
if (this._resizeObserver) {
|
|
77
|
+
this._resizeObserver.observe(element);
|
|
78
|
+
}
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
71
82
|
private _onResize = () => {
|
|
72
83
|
const flicking = this._flicking;
|
|
73
84
|
const resizeDebounce = flicking.resizeDebounce;
|
|
74
85
|
const maxResizeDebounce = flicking.maxResizeDebounce;
|
|
86
|
+
|
|
75
87
|
if (resizeDebounce <= 0) {
|
|
76
88
|
void flicking.resize();
|
|
77
89
|
} else {
|
package/src/renderer/Renderer.ts
CHANGED
|
@@ -335,8 +335,10 @@ abstract class Renderer {
|
|
|
335
335
|
// Update camera & control
|
|
336
336
|
this._updateCameraAndControl();
|
|
337
337
|
|
|
338
|
-
if (flicking.autoResize) {
|
|
339
|
-
|
|
338
|
+
if (flicking.autoResize && flicking.useResizeObserver) {
|
|
339
|
+
panelsAdded.forEach((panel) => {
|
|
340
|
+
flicking.autoResizer.observe(panel.element);
|
|
341
|
+
});
|
|
340
342
|
}
|
|
341
343
|
|
|
342
344
|
void this.render();
|