@egjs/react-flicking 4.10.0 → 4.10.2-beta.0
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/README.md +17 -8
- package/declaration/Flicking.d.ts +41 -39
- 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 -31
- package/dist/flicking.cjs.js +65 -31
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +65 -31
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.umd.js +65 -31
- package/dist/flicking.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/react-flicking/Flicking.tsx +51 -26
- package/src/react-flicking/ReactRenderer.ts +3 -2
- package/src/react-flicking/consts.ts +1 -0
- package/src/react-flicking/types.ts +1 -0
- package/dist/flicking-inline.css +0 -45
- package/dist/flicking-inline.min.css +0 -1
- package/dist/flicking.css +0 -44
- package/dist/flicking.min.css +0 -1
package/README.md
CHANGED
|
@@ -42,14 +42,15 @@ npm install --save @egjs/react-flicking
|
|
|
42
42
|
import Flicking, { MoveEvent, WillChangeEvent } from "@egjs/react-flicking";
|
|
43
43
|
|
|
44
44
|
<Flicking
|
|
45
|
-
viewportTag
|
|
46
|
-
cameraTag
|
|
47
|
-
cameraClass
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
viewportTag="div"
|
|
46
|
+
cameraTag="div"
|
|
47
|
+
cameraClass=""
|
|
48
|
+
renderOnSameKey={false}
|
|
49
|
+
align="center"
|
|
50
|
+
onMove={(e: MoveEvent) => {}}
|
|
51
|
+
onWillChange={(e: WillChangeEvent) => {}}
|
|
52
|
+
horizontal={true}
|
|
53
|
+
circular={true}
|
|
53
54
|
>
|
|
54
55
|
<div>panel 0</div>
|
|
55
56
|
<div>panel 1</div>
|
|
@@ -57,6 +58,14 @@ import Flicking, { MoveEvent, WillChangeEvent } from "@egjs/react-flicking";
|
|
|
57
58
|
</Flicking>
|
|
58
59
|
```
|
|
59
60
|
|
|
61
|
+
## ✨ React exclusive options
|
|
62
|
+
- viewportTag: HTML tag for `.flicking-viewport` element. (default: **"div"**)
|
|
63
|
+
- cameraTag: HTML tag for `.flicking-camera` element. (default: **"div"**)
|
|
64
|
+
- cameraClass: `className` for `.flicking-camera` element. (default: **""**)
|
|
65
|
+
- renderOnSameKey: Whether to always render children even they have the same keys (default: **false**)
|
|
66
|
+
- Flicking doesn't rerender when children have same length & keys for performance by default.
|
|
67
|
+
- If you have to bypass this behavior, like when you have to update panel's innerHTML without changing the list of child elements, you can either set this option to `true`, or you can call Flicking component's `forceUpdate()`.
|
|
68
|
+
|
|
60
69
|
## 📦 Packages
|
|
61
70
|
You can use all plugins just like native @egjs/flicking.
|
|
62
71
|
|
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import Component from "@egjs/component";
|
|
3
|
-
import VanillaFlicking, { FlickingOptions } from "@egjs/flicking";
|
|
4
|
-
import { FlickingProps } from "./types";
|
|
5
|
-
import StrictPanel from "./StrictPanel";
|
|
6
|
-
import NonStrictPanel from "./NonStrictPanel";
|
|
7
|
-
declare class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>> {
|
|
8
|
-
static defaultProps: FlickingProps;
|
|
9
|
-
private _vanillaFlicking;
|
|
10
|
-
private _panels;
|
|
11
|
-
private _pluginsDiffer;
|
|
12
|
-
private _jsxDiffer;
|
|
13
|
-
private _viewportElement;
|
|
14
|
-
private _diffResult;
|
|
15
|
-
private _renderEmitter;
|
|
16
|
-
private
|
|
17
|
-
get reactPanels(): (StrictPanel | NonStrictPanel | HTMLDivElement)[];
|
|
18
|
-
get renderEmitter(): Component<{
|
|
19
|
-
render: void;
|
|
20
|
-
}>;
|
|
21
|
-
constructor(props: Partial<FlickingProps & FlickingOptions>);
|
|
22
|
-
componentDidMount(): void;
|
|
23
|
-
componentWillUnmount(): void;
|
|
24
|
-
shouldComponentUpdate(nextProps:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
private
|
|
34
|
-
private
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Component from "@egjs/component";
|
|
3
|
+
import VanillaFlicking, { FlickingOptions } from "@egjs/flicking";
|
|
4
|
+
import { FlickingProps } from "./types";
|
|
5
|
+
import StrictPanel from "./StrictPanel";
|
|
6
|
+
import NonStrictPanel from "./NonStrictPanel";
|
|
7
|
+
declare class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>> {
|
|
8
|
+
static defaultProps: FlickingProps;
|
|
9
|
+
private _vanillaFlicking;
|
|
10
|
+
private _panels;
|
|
11
|
+
private _pluginsDiffer;
|
|
12
|
+
private _jsxDiffer;
|
|
13
|
+
private _viewportElement;
|
|
14
|
+
private _diffResult;
|
|
15
|
+
private _renderEmitter;
|
|
16
|
+
private _prevChildren;
|
|
17
|
+
get reactPanels(): (StrictPanel | NonStrictPanel | HTMLDivElement)[];
|
|
18
|
+
get renderEmitter(): Component<{
|
|
19
|
+
render: void;
|
|
20
|
+
}>;
|
|
21
|
+
constructor(props: Partial<FlickingProps & FlickingOptions>);
|
|
22
|
+
componentDidMount(): void;
|
|
23
|
+
componentWillUnmount(): void;
|
|
24
|
+
shouldComponentUpdate(nextProps: Readonly<Partial<FlickingProps & FlickingOptions>>): boolean;
|
|
25
|
+
beforeRender(): void;
|
|
26
|
+
componentDidUpdate(): void;
|
|
27
|
+
render(): JSX.Element;
|
|
28
|
+
private _createPanelRefs;
|
|
29
|
+
private _bindEvents;
|
|
30
|
+
private _checkPlugins;
|
|
31
|
+
private _hasSameChildren;
|
|
32
|
+
private _getChildren;
|
|
33
|
+
private _getViewportSlot;
|
|
34
|
+
private _unpackFragment;
|
|
35
|
+
private _getVirtualPanels;
|
|
36
|
+
private _getPanels;
|
|
37
|
+
private _isFragment;
|
|
38
|
+
}
|
|
39
|
+
interface Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>, VanillaFlicking {
|
|
40
|
+
}
|
|
41
|
+
export default Flicking;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
declare class NonStrictPanel extends React.Component<{
|
|
3
|
-
children?: React.ReactElement;
|
|
4
|
-
}> {
|
|
5
|
-
private _hide;
|
|
6
|
-
get nativeElement(): HTMLElement;
|
|
7
|
-
get rendered(): boolean;
|
|
8
|
-
render(): JSX.Element | undefined;
|
|
9
|
-
show(): void;
|
|
10
|
-
hide(): void;
|
|
11
|
-
}
|
|
12
|
-
export default NonStrictPanel;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare class NonStrictPanel extends React.Component<{
|
|
3
|
+
children?: React.ReactElement;
|
|
4
|
+
}> {
|
|
5
|
+
private _hide;
|
|
6
|
+
get nativeElement(): HTMLElement;
|
|
7
|
+
get rendered(): boolean;
|
|
8
|
+
render(): JSX.Element | undefined;
|
|
9
|
+
show(): void;
|
|
10
|
+
hide(): void;
|
|
11
|
+
}
|
|
12
|
+
export default NonStrictPanel;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ElementProvider } from "@egjs/flicking";
|
|
2
|
-
import StrictPanel from "./StrictPanel";
|
|
3
|
-
import NonStrictPanel from "./NonStrictPanel";
|
|
4
|
-
declare class ReactElementProvider implements ElementProvider {
|
|
5
|
-
private _el;
|
|
6
|
-
get element(): HTMLElement;
|
|
7
|
-
get rendered(): boolean;
|
|
8
|
-
constructor(el: StrictPanel | NonStrictPanel);
|
|
9
|
-
show(): void;
|
|
10
|
-
hide(): void;
|
|
11
|
-
}
|
|
12
|
-
export default ReactElementProvider;
|
|
1
|
+
import { ElementProvider } from "@egjs/flicking";
|
|
2
|
+
import StrictPanel from "./StrictPanel";
|
|
3
|
+
import NonStrictPanel from "./NonStrictPanel";
|
|
4
|
+
declare class ReactElementProvider implements ElementProvider {
|
|
5
|
+
private _el;
|
|
6
|
+
get element(): HTMLElement;
|
|
7
|
+
get rendered(): boolean;
|
|
8
|
+
constructor(el: StrictPanel | NonStrictPanel);
|
|
9
|
+
show(): void;
|
|
10
|
+
hide(): void;
|
|
11
|
+
}
|
|
12
|
+
export default ReactElementProvider;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ExternalRenderer, PanelOptions, RendererOptions } from "@egjs/flicking";
|
|
2
|
-
import ReactFlicking from "./Flicking";
|
|
3
|
-
import StrictPanel from "./StrictPanel";
|
|
4
|
-
import NonStrictPanel from "./NonStrictPanel";
|
|
5
|
-
export interface ReactRendererOptions extends RendererOptions {
|
|
6
|
-
reactFlicking: ReactFlicking;
|
|
7
|
-
}
|
|
8
|
-
declare class ReactRenderer extends ExternalRenderer {
|
|
9
|
-
protected _reactFlicking: ReactFlicking;
|
|
10
|
-
constructor(options: ReactRendererOptions);
|
|
11
|
-
render(): Promise<void>;
|
|
12
|
-
forceRenderAllPanels(): Promise<void>;
|
|
13
|
-
protected _collectPanels(): void;
|
|
14
|
-
protected _createPanel(externalComponent: StrictPanel | NonStrictPanel | HTMLDivElement, options: PanelOptions): import("@egjs/flicking/declaration/core/panel/Panel").default;
|
|
15
|
-
}
|
|
16
|
-
export default ReactRenderer;
|
|
1
|
+
import { ExternalRenderer, PanelOptions, RendererOptions } from "@egjs/flicking";
|
|
2
|
+
import ReactFlicking from "./Flicking";
|
|
3
|
+
import StrictPanel from "./StrictPanel";
|
|
4
|
+
import NonStrictPanel from "./NonStrictPanel";
|
|
5
|
+
export interface ReactRendererOptions extends RendererOptions {
|
|
6
|
+
reactFlicking: ReactFlicking;
|
|
7
|
+
}
|
|
8
|
+
declare class ReactRenderer extends ExternalRenderer {
|
|
9
|
+
protected _reactFlicking: ReactFlicking;
|
|
10
|
+
constructor(options: ReactRendererOptions);
|
|
11
|
+
render(): Promise<void>;
|
|
12
|
+
forceRenderAllPanels(): Promise<void>;
|
|
13
|
+
protected _collectPanels(): void;
|
|
14
|
+
protected _createPanel(externalComponent: StrictPanel | NonStrictPanel | HTMLDivElement, options: PanelOptions): import("@egjs/flicking/declaration/core/panel/Panel").default;
|
|
15
|
+
}
|
|
16
|
+
export default ReactRenderer;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
declare class StrictPanel extends React.Component<{
|
|
3
|
-
children?: React.ReactElement;
|
|
4
|
-
}> {
|
|
5
|
-
private _hide;
|
|
6
|
-
private _elRef;
|
|
7
|
-
get nativeElement(): HTMLElement;
|
|
8
|
-
get rendered(): boolean;
|
|
9
|
-
render(): JSX.Element;
|
|
10
|
-
show(): void;
|
|
11
|
-
hide(): void;
|
|
12
|
-
private _getElement;
|
|
13
|
-
}
|
|
14
|
-
export default StrictPanel;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare class StrictPanel extends React.Component<{
|
|
3
|
+
children?: React.ReactElement;
|
|
4
|
+
}> {
|
|
5
|
+
private _hide;
|
|
6
|
+
private _elRef;
|
|
7
|
+
get nativeElement(): HTMLElement;
|
|
8
|
+
get rendered(): boolean;
|
|
9
|
+
render(): JSX.Element;
|
|
10
|
+
show(): void;
|
|
11
|
+
hide(): void;
|
|
12
|
+
private _getElement;
|
|
13
|
+
}
|
|
14
|
+
export default StrictPanel;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
declare const ViewportSlot: React.MemoExoticComponent<(props: {
|
|
3
|
-
children?: ReactNode;
|
|
4
|
-
}) => JSX.Element>;
|
|
5
|
-
export default ViewportSlot;
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
declare const ViewportSlot: React.MemoExoticComponent<(props: {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
}) => JSX.Element>;
|
|
5
|
+
export default ViewportSlot;
|
package/declaration/consts.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FlickingProps } from "./types";
|
|
2
|
-
export declare const DEFAULT_PROPS: FlickingProps;
|
|
1
|
+
import { FlickingProps } from "./types";
|
|
2
|
+
export declare const DEFAULT_PROPS: FlickingProps;
|
package/declaration/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Flicking from "./Flicking";
|
|
2
|
-
import ViewportSlot from "./ViewportSlot";
|
|
3
|
-
export * from "@egjs/flicking";
|
|
4
|
-
export * from "./types";
|
|
5
|
-
export { ViewportSlot };
|
|
6
|
-
export default Flicking;
|
|
1
|
+
import Flicking from "./Flicking";
|
|
2
|
+
import ViewportSlot from "./ViewportSlot";
|
|
3
|
+
export * from "@egjs/flicking";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export { ViewportSlot };
|
|
6
|
+
export default Flicking;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Flicking from "./Flicking";
|
|
2
|
-
export default Flicking;
|
|
1
|
+
import Flicking from "./Flicking";
|
|
2
|
+
export default Flicking;
|
package/declaration/types.d.ts
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import ReactFlicking from "./Flicking";
|
|
3
|
-
import { SelectEvent, NeedPanelEvent, VisibleChangeEvent, HoldStartEvent, HoldEndEvent, MoveStartEvent, MoveEvent, MoveEndEvent, WillChangeEvent, ChangedEvent, WillRestoreEvent, RestoredEvent, ReadyEvent, BeforeResizeEvent, AfterResizeEvent, ReachEdgeEvent, PanelChangeEvent, Plugin, Status } from "@egjs/flicking";
|
|
4
|
-
export interface FlickingProps {
|
|
5
|
-
viewportTag: keyof JSX.IntrinsicElements;
|
|
6
|
-
cameraTag: keyof JSX.IntrinsicElements;
|
|
7
|
-
cameraClass: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import ReactFlicking from "./Flicking";
|
|
3
|
+
import { SelectEvent, NeedPanelEvent, VisibleChangeEvent, HoldStartEvent, HoldEndEvent, MoveStartEvent, MoveEvent, MoveEndEvent, WillChangeEvent, ChangedEvent, WillRestoreEvent, RestoredEvent, ReadyEvent, BeforeResizeEvent, AfterResizeEvent, ReachEdgeEvent, PanelChangeEvent, Plugin, Status } from "@egjs/flicking";
|
|
4
|
+
export interface FlickingProps {
|
|
5
|
+
viewportTag: keyof JSX.IntrinsicElements;
|
|
6
|
+
cameraTag: keyof JSX.IntrinsicElements;
|
|
7
|
+
cameraClass: string;
|
|
8
|
+
renderOnSameKey: boolean;
|
|
9
|
+
plugins: Plugin[];
|
|
10
|
+
status?: Status;
|
|
11
|
+
useFindDOMNode: boolean;
|
|
12
|
+
hideBeforeInit: boolean;
|
|
13
|
+
firstPanelSize?: string;
|
|
14
|
+
onReady: (e: ReadyEvent<ReactFlicking>) => any;
|
|
15
|
+
onBeforeResize: (e: BeforeResizeEvent<ReactFlicking>) => any;
|
|
16
|
+
onAfterResize: (e: AfterResizeEvent<ReactFlicking>) => any;
|
|
17
|
+
onHoldStart: (e: HoldStartEvent<ReactFlicking>) => any;
|
|
18
|
+
onHoldEnd: (e: HoldEndEvent<ReactFlicking>) => any;
|
|
19
|
+
onMoveStart: (e: MoveStartEvent<ReactFlicking>) => any;
|
|
20
|
+
onMove: (e: MoveEvent<ReactFlicking>) => any;
|
|
21
|
+
onMoveEnd: (e: MoveEndEvent<ReactFlicking>) => any;
|
|
22
|
+
onWillChange: (e: WillChangeEvent<ReactFlicking>) => any;
|
|
23
|
+
onChanged: (e: ChangedEvent<ReactFlicking>) => any;
|
|
24
|
+
onWillRestore: (e: WillRestoreEvent<ReactFlicking>) => any;
|
|
25
|
+
onRestored: (e: RestoredEvent<ReactFlicking>) => any;
|
|
26
|
+
onSelect: (e: SelectEvent<ReactFlicking>) => any;
|
|
27
|
+
onNeedPanel: (e: NeedPanelEvent<ReactFlicking>) => any;
|
|
28
|
+
onVisibleChange: (e: VisibleChangeEvent<ReactFlicking>) => any;
|
|
29
|
+
onReachEdge: (e: ReachEdgeEvent<ReactFlicking>) => any;
|
|
30
|
+
onPanelChange: (e: PanelChangeEvent<ReactFlicking>) => any;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}
|
package/dist/flicking.cjs.js
CHANGED
|
@@ -65,6 +65,16 @@ var __assign = function () {
|
|
|
65
65
|
|
|
66
66
|
return __assign.apply(this, arguments);
|
|
67
67
|
};
|
|
68
|
+
function __rest(s, e) {
|
|
69
|
+
var t = {};
|
|
70
|
+
|
|
71
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
72
|
+
|
|
73
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
74
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
75
|
+
}
|
|
76
|
+
return t;
|
|
77
|
+
}
|
|
68
78
|
function __decorate(decorators, target, key, desc) {
|
|
69
79
|
var c = arguments.length,
|
|
70
80
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
@@ -225,6 +235,7 @@ var DEFAULT_PROPS = {
|
|
|
225
235
|
viewportTag: "div",
|
|
226
236
|
cameraTag: "div",
|
|
227
237
|
cameraClass: "",
|
|
238
|
+
renderOnSameKey: false,
|
|
228
239
|
plugins: [],
|
|
229
240
|
useFindDOMNode: false,
|
|
230
241
|
hideBeforeInit: false,
|
|
@@ -427,9 +438,9 @@ function (_super) {
|
|
|
427
438
|
return NonStrictPanel;
|
|
428
439
|
}(React.Component);
|
|
429
440
|
|
|
430
|
-
/*
|
|
431
|
-
* Copyright (c) 2015 NAVER Corp.
|
|
432
|
-
* egjs projects are licensed under the MIT license
|
|
441
|
+
/*
|
|
442
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
443
|
+
* egjs projects are licensed under the MIT license
|
|
433
444
|
*/
|
|
434
445
|
var ViewportSlot = React.memo(function (props) {
|
|
435
446
|
return React.createElement(React.Fragment, null, props.children);
|
|
@@ -469,14 +480,6 @@ function () {
|
|
|
469
480
|
return ReactElementProvider;
|
|
470
481
|
}();
|
|
471
482
|
|
|
472
|
-
var LifeCycleState;
|
|
473
|
-
|
|
474
|
-
(function (LifeCycleState) {
|
|
475
|
-
LifeCycleState[LifeCycleState["BEFORE_UPDATE"] = 0] = "BEFORE_UPDATE";
|
|
476
|
-
LifeCycleState[LifeCycleState["RENDER"] = 1] = "RENDER";
|
|
477
|
-
LifeCycleState[LifeCycleState["UPDATED"] = 2] = "UPDATED";
|
|
478
|
-
})(LifeCycleState || (LifeCycleState = {}));
|
|
479
|
-
|
|
480
483
|
var Flicking =
|
|
481
484
|
/*#__PURE__*/
|
|
482
485
|
function (_super) {
|
|
@@ -487,8 +490,11 @@ function (_super) {
|
|
|
487
490
|
|
|
488
491
|
_this._panels = [];
|
|
489
492
|
_this._renderEmitter = new Component();
|
|
490
|
-
|
|
491
|
-
|
|
493
|
+
|
|
494
|
+
var children = _this._getChildren();
|
|
495
|
+
|
|
496
|
+
_this._panels = _this._createPanelRefs(props, children);
|
|
497
|
+
_this._prevChildren = children;
|
|
492
498
|
return _this;
|
|
493
499
|
}
|
|
494
500
|
|
|
@@ -523,7 +529,6 @@ function (_super) {
|
|
|
523
529
|
externalRenderer: new ReactRenderer(rendererOptions)
|
|
524
530
|
}));
|
|
525
531
|
this._vanillaFlicking = flicking;
|
|
526
|
-
this._currentState = LifeCycleState.UPDATED;
|
|
527
532
|
|
|
528
533
|
var children = this._getChildren();
|
|
529
534
|
|
|
@@ -531,6 +536,7 @@ function (_super) {
|
|
|
531
536
|
return panel.key;
|
|
532
537
|
});
|
|
533
538
|
this._pluginsDiffer = new ListDiffer();
|
|
539
|
+
this._prevChildren = children;
|
|
534
540
|
|
|
535
541
|
this._bindEvents();
|
|
536
542
|
|
|
@@ -549,28 +555,42 @@ function (_super) {
|
|
|
549
555
|
|
|
550
556
|
__proto.shouldComponentUpdate = function (nextProps) {
|
|
551
557
|
var vanillaFlicking = this._vanillaFlicking;
|
|
552
|
-
var
|
|
553
|
-
|
|
558
|
+
var prevProps = this.props;
|
|
554
559
|
if (!vanillaFlicking || !vanillaFlicking.initialized) return false;
|
|
555
560
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
this._panels = this._createPanelRefs(nextProps, nextChildren);
|
|
560
|
-
this._diffResult = this._jsxDiffer.update(nextChildren);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
this._currentState = LifeCycleState.BEFORE_UPDATE;
|
|
561
|
+
var children = nextProps.children,
|
|
562
|
+
restProps = __rest(nextProps, ["children"]);
|
|
564
563
|
|
|
565
|
-
for (var key in
|
|
566
|
-
if (
|
|
564
|
+
for (var key in restProps) {
|
|
565
|
+
if (prevProps[key] !== nextProps[key]) {
|
|
567
566
|
return true;
|
|
568
567
|
}
|
|
569
568
|
}
|
|
570
569
|
|
|
570
|
+
var prevChildren = this._prevChildren;
|
|
571
|
+
|
|
572
|
+
var nextChildren = this._getChildren(children);
|
|
573
|
+
|
|
574
|
+
if (nextProps.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) return true;
|
|
571
575
|
return false;
|
|
572
576
|
};
|
|
573
577
|
|
|
578
|
+
__proto.beforeRender = function () {
|
|
579
|
+
var vanillaFlicking = this._vanillaFlicking;
|
|
580
|
+
var props = this.props;
|
|
581
|
+
var prevChildren = this._prevChildren; // Ignore updates before init, they will be updated after "ready" event's force update
|
|
582
|
+
|
|
583
|
+
if (!vanillaFlicking || !vanillaFlicking.initialized) return;
|
|
584
|
+
|
|
585
|
+
var nextChildren = this._getChildren(props.children);
|
|
586
|
+
|
|
587
|
+
if (props.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) {
|
|
588
|
+
this._panels = this._createPanelRefs(props, nextChildren);
|
|
589
|
+
this._diffResult = this._jsxDiffer.update(nextChildren);
|
|
590
|
+
this._prevChildren = nextChildren;
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
|
|
574
594
|
__proto.componentDidUpdate = function () {
|
|
575
595
|
var flicking = this._vanillaFlicking;
|
|
576
596
|
var renderEmitter = this._renderEmitter;
|
|
@@ -580,7 +600,6 @@ function (_super) {
|
|
|
580
600
|
|
|
581
601
|
renderEmitter.trigger("render");
|
|
582
602
|
flicking.camera.updateOffset();
|
|
583
|
-
this._currentState = LifeCycleState.UPDATED;
|
|
584
603
|
if (!diffResult || !flicking.initialized) return;
|
|
585
604
|
VanillaFlicking.sync(flicking, diffResult, this.reactPanels);
|
|
586
605
|
this._diffResult = null;
|
|
@@ -596,7 +615,7 @@ function (_super) {
|
|
|
596
615
|
var Camera = props.cameraTag;
|
|
597
616
|
var attributes = {};
|
|
598
617
|
var flicking = this._vanillaFlicking;
|
|
599
|
-
this.
|
|
618
|
+
this.beforeRender();
|
|
600
619
|
|
|
601
620
|
for (var name in props) {
|
|
602
621
|
if (!(name in DEFAULT_PROPS) && !(name in VanillaFlicking.prototype)) {
|
|
@@ -697,6 +716,21 @@ function (_super) {
|
|
|
697
716
|
}));
|
|
698
717
|
};
|
|
699
718
|
|
|
719
|
+
__proto._hasSameChildren = function (prevChildren, nextChildren) {
|
|
720
|
+
if (prevChildren.length !== nextChildren.length || prevChildren.length === 0) return false;
|
|
721
|
+
var same = prevChildren.every(function (child, idx) {
|
|
722
|
+
var nextChild = nextChildren[idx];
|
|
723
|
+
console.log(child, nextChild);
|
|
724
|
+
|
|
725
|
+
if (child.key && nextChild.key) {
|
|
726
|
+
return child.key === nextChild.key;
|
|
727
|
+
} else {
|
|
728
|
+
return child === nextChild;
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
return same;
|
|
732
|
+
};
|
|
733
|
+
|
|
700
734
|
__proto._getChildren = function (children) {
|
|
701
735
|
var _this = this;
|
|
702
736
|
|
|
@@ -787,9 +821,9 @@ function (_super) {
|
|
|
787
821
|
return Flicking;
|
|
788
822
|
}(React.Component);
|
|
789
823
|
|
|
790
|
-
/*
|
|
791
|
-
* Copyright (c) 2015 NAVER Corp.
|
|
792
|
-
* egjs projects are licensed under the MIT license
|
|
824
|
+
/*
|
|
825
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
826
|
+
* egjs projects are licensed under the MIT license
|
|
793
827
|
*/
|
|
794
828
|
Flicking.ViewportSlot = ViewportSlot;
|
|
795
829
|
|