@egjs/react-flicking 4.10.2-beta.0 → 4.10.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 +42 -41
- package/declaration/NonStrictPanel.d.ts +12 -12
- package/declaration/ReactElementProvider.d.ts +12 -12
- package/declaration/ReactRenderer.d.ts +16 -16
- package/declaration/StrictPanel.d.ts +14 -14
- package/declaration/ViewportSlot.d.ts +5 -5
- package/declaration/consts.d.ts +2 -2
- package/declaration/index.d.ts +6 -6
- package/declaration/index.umd.d.ts +2 -2
- package/declaration/types.d.ts +32 -32
- package/dist/flicking-inline.css +45 -0
- package/dist/flicking-inline.css.map +1 -0
- package/dist/flicking-inline.min.css +1 -0
- package/dist/flicking.cjs.js +20 -8
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.css +44 -0
- package/dist/flicking.css.map +1 -0
- package/dist/flicking.esm.js +20 -8
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.min.css +1 -0
- package/dist/flicking.umd.js +20 -8
- package/dist/flicking.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/react-flicking/Flicking.tsx +19 -3
- package/src/react-flicking/ReactRenderer.ts +2 -3
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import { flushSync } from "react-dom";
|
|
7
6
|
import Component from "@egjs/component";
|
|
8
7
|
import ListDiffer, { diff, DiffResult } from "@egjs/list-differ";
|
|
9
8
|
import VanillaFlicking, {
|
|
@@ -27,6 +26,12 @@ import NonStrictPanel from "./NonStrictPanel";
|
|
|
27
26
|
import ViewportSlot from "./ViewportSlot";
|
|
28
27
|
import ReactElementProvider from "./ReactElementProvider";
|
|
29
28
|
|
|
29
|
+
enum RenderingState {
|
|
30
|
+
NONE,
|
|
31
|
+
RENDERED,
|
|
32
|
+
UPDATED
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>> {
|
|
31
36
|
public static defaultProps: FlickingProps = DEFAULT_PROPS;
|
|
32
37
|
|
|
@@ -38,6 +43,12 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
38
43
|
private _diffResult: DiffResult<React.ReactElement> | null;
|
|
39
44
|
private _renderEmitter = new Component<{ render: void }>();
|
|
40
45
|
private _prevChildren: React.ReactElement[];
|
|
46
|
+
/**
|
|
47
|
+
* The Purpose of "Rendering State" is:
|
|
48
|
+
* In some cases, like in <StrictMode>, React attempts to render twice without calling `componentDidUpdate`.
|
|
49
|
+
* We ignore the diff update between the two rendering calls, using this rendering state.
|
|
50
|
+
*/
|
|
51
|
+
private _renderingState: RenderingState;
|
|
41
52
|
|
|
42
53
|
public get reactPanels() { return this._panels.map(panel => panel.current!); }
|
|
43
54
|
public get renderEmitter() { return this._renderEmitter; }
|
|
@@ -48,6 +59,7 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
48
59
|
const children = this._getChildren();
|
|
49
60
|
this._panels = this._createPanelRefs(props, children);
|
|
50
61
|
this._prevChildren = children;
|
|
62
|
+
this._renderingState = RenderingState.NONE;
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
public componentDidMount() {
|
|
@@ -116,7 +128,8 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
116
128
|
const prevChildren = this._prevChildren;
|
|
117
129
|
|
|
118
130
|
// Ignore updates before init, they will be updated after "ready" event's force update
|
|
119
|
-
|
|
131
|
+
// Also, ignore update between two successive rendering calls
|
|
132
|
+
if (!vanillaFlicking || !vanillaFlicking.initialized || this._renderingState === RenderingState.RENDERED) return;
|
|
120
133
|
|
|
121
134
|
const nextChildren = this._getChildren(props.children);
|
|
122
135
|
if (props.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) {
|
|
@@ -139,6 +152,7 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
139
152
|
|
|
140
153
|
sync(flicking, diffResult, this.reactPanels);
|
|
141
154
|
|
|
155
|
+
this._renderingState = RenderingState.UPDATED;
|
|
142
156
|
this._diffResult = null;
|
|
143
157
|
}
|
|
144
158
|
|
|
@@ -187,6 +201,8 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
187
201
|
? this._getVirtualPanels()
|
|
188
202
|
: this._getPanels();
|
|
189
203
|
|
|
204
|
+
this._renderingState = RenderingState.RENDERED;
|
|
205
|
+
|
|
190
206
|
return (
|
|
191
207
|
<Viewport {...attributes} className={viewportClasses.join(" ")} ref={(e?: HTMLElement) => {
|
|
192
208
|
e && (this._viewportElement = e);
|
|
@@ -232,7 +248,7 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
232
248
|
this._diffResult = diffResult;
|
|
233
249
|
}
|
|
234
250
|
|
|
235
|
-
|
|
251
|
+
this.forceUpdate();
|
|
236
252
|
});
|
|
237
253
|
}
|
|
238
254
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import { flushSync } from "react-dom";
|
|
6
5
|
import { ExternalRenderer, PanelOptions, RendererOptions, getFlickingAttached } from "@egjs/flicking";
|
|
7
6
|
|
|
8
7
|
import ReactFlicking from "./Flicking";
|
|
@@ -39,7 +38,7 @@ class ReactRenderer extends ExternalRenderer {
|
|
|
39
38
|
this._rendering = false;
|
|
40
39
|
resolve()
|
|
41
40
|
});
|
|
42
|
-
|
|
41
|
+
reactFlicking.forceUpdate();
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -54,7 +53,7 @@ class ReactRenderer extends ExternalRenderer {
|
|
|
54
53
|
this._rendering = false;
|
|
55
54
|
resolve();
|
|
56
55
|
});
|
|
57
|
-
|
|
56
|
+
reactFlicking.forceUpdate();
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
59
|
|