@egjs/react-flicking 4.10.1 → 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 -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 -31
- package/dist/flicking.cjs.js +29 -24
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +29 -24
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.umd.js +29 -24
- package/dist/flicking.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/react-flicking/Flicking.tsx +24 -21
- 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,41 +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: 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
|
+
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
|
@@ -235,6 +235,7 @@ var DEFAULT_PROPS = {
|
|
|
235
235
|
viewportTag: "div",
|
|
236
236
|
cameraTag: "div",
|
|
237
237
|
cameraClass: "",
|
|
238
|
+
renderOnSameKey: false,
|
|
238
239
|
plugins: [],
|
|
239
240
|
useFindDOMNode: false,
|
|
240
241
|
hideBeforeInit: false,
|
|
@@ -437,9 +438,9 @@ function (_super) {
|
|
|
437
438
|
return NonStrictPanel;
|
|
438
439
|
}(React.Component);
|
|
439
440
|
|
|
440
|
-
/*
|
|
441
|
-
* Copyright (c) 2015 NAVER Corp.
|
|
442
|
-
* egjs projects are licensed under the MIT license
|
|
441
|
+
/*
|
|
442
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
443
|
+
* egjs projects are licensed under the MIT license
|
|
443
444
|
*/
|
|
444
445
|
var ViewportSlot = React.memo(function (props) {
|
|
445
446
|
return React.createElement(React.Fragment, null, props.children);
|
|
@@ -489,8 +490,11 @@ function (_super) {
|
|
|
489
490
|
|
|
490
491
|
_this._panels = [];
|
|
491
492
|
_this._renderEmitter = new Component();
|
|
492
|
-
|
|
493
|
-
|
|
493
|
+
|
|
494
|
+
var children = _this._getChildren();
|
|
495
|
+
|
|
496
|
+
_this._panels = _this._createPanelRefs(props, children);
|
|
497
|
+
_this._prevChildren = children;
|
|
494
498
|
return _this;
|
|
495
499
|
}
|
|
496
500
|
|
|
@@ -532,7 +536,7 @@ function (_super) {
|
|
|
532
536
|
return panel.key;
|
|
533
537
|
});
|
|
534
538
|
this._pluginsDiffer = new ListDiffer();
|
|
535
|
-
this.
|
|
539
|
+
this._prevChildren = children;
|
|
536
540
|
|
|
537
541
|
this._bindEvents();
|
|
538
542
|
|
|
@@ -553,10 +557,9 @@ function (_super) {
|
|
|
553
557
|
var vanillaFlicking = this._vanillaFlicking;
|
|
554
558
|
var prevProps = this.props;
|
|
555
559
|
if (!vanillaFlicking || !vanillaFlicking.initialized) return false;
|
|
556
|
-
if (!this._hasSameChildren(prevProps, nextProps)) return true;
|
|
557
560
|
|
|
558
|
-
nextProps.children
|
|
559
|
-
|
|
561
|
+
var children = nextProps.children,
|
|
562
|
+
restProps = __rest(nextProps, ["children"]);
|
|
560
563
|
|
|
561
564
|
for (var key in restProps) {
|
|
562
565
|
if (prevProps[key] !== nextProps[key]) {
|
|
@@ -564,21 +567,27 @@ function (_super) {
|
|
|
564
567
|
}
|
|
565
568
|
}
|
|
566
569
|
|
|
570
|
+
var prevChildren = this._prevChildren;
|
|
571
|
+
|
|
572
|
+
var nextChildren = this._getChildren(children);
|
|
573
|
+
|
|
574
|
+
if (nextProps.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) return true;
|
|
567
575
|
return false;
|
|
568
576
|
};
|
|
569
577
|
|
|
570
578
|
__proto.beforeRender = function () {
|
|
571
579
|
var vanillaFlicking = this._vanillaFlicking;
|
|
572
|
-
var
|
|
573
|
-
var
|
|
580
|
+
var props = this.props;
|
|
581
|
+
var prevChildren = this._prevChildren; // Ignore updates before init, they will be updated after "ready" event's force update
|
|
574
582
|
|
|
575
583
|
if (!vanillaFlicking || !vanillaFlicking.initialized) return;
|
|
576
584
|
|
|
577
|
-
|
|
578
|
-
var nextChildren = this._getChildren(nextProps.children);
|
|
585
|
+
var nextChildren = this._getChildren(props.children);
|
|
579
586
|
|
|
580
|
-
|
|
587
|
+
if (props.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) {
|
|
588
|
+
this._panels = this._createPanelRefs(props, nextChildren);
|
|
581
589
|
this._diffResult = this._jsxDiffer.update(nextChildren);
|
|
590
|
+
this._prevChildren = nextChildren;
|
|
582
591
|
}
|
|
583
592
|
};
|
|
584
593
|
|
|
@@ -641,7 +650,6 @@ function (_super) {
|
|
|
641
650
|
}
|
|
642
651
|
} : {};
|
|
643
652
|
var panels = !!props.virtual && ((_b = props.panelsPerView) !== null && _b !== void 0 ? _b : -1) > 0 ? this._getVirtualPanels() : this._getPanels();
|
|
644
|
-
this._prevProps = props;
|
|
645
653
|
return React.createElement(Viewport, __assign({}, attributes, {
|
|
646
654
|
className: viewportClasses.join(" "),
|
|
647
655
|
ref: function (e) {
|
|
@@ -708,14 +716,11 @@ function (_super) {
|
|
|
708
716
|
}));
|
|
709
717
|
};
|
|
710
718
|
|
|
711
|
-
__proto._hasSameChildren = function (
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
var nextChildren = this._getChildren(nextProps.children);
|
|
715
|
-
|
|
716
|
-
if (prevChildren.length !== nextChildren.length) return false;
|
|
719
|
+
__proto._hasSameChildren = function (prevChildren, nextChildren) {
|
|
720
|
+
if (prevChildren.length !== nextChildren.length || prevChildren.length === 0) return false;
|
|
717
721
|
var same = prevChildren.every(function (child, idx) {
|
|
718
722
|
var nextChild = nextChildren[idx];
|
|
723
|
+
console.log(child, nextChild);
|
|
719
724
|
|
|
720
725
|
if (child.key && nextChild.key) {
|
|
721
726
|
return child.key === nextChild.key;
|
|
@@ -816,9 +821,9 @@ function (_super) {
|
|
|
816
821
|
return Flicking;
|
|
817
822
|
}(React.Component);
|
|
818
823
|
|
|
819
|
-
/*
|
|
820
|
-
* Copyright (c) 2015 NAVER Corp.
|
|
821
|
-
* egjs projects are licensed under the MIT license
|
|
824
|
+
/*
|
|
825
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
826
|
+
* egjs projects are licensed under the MIT license
|
|
822
827
|
*/
|
|
823
828
|
Flicking.ViewportSlot = ViewportSlot;
|
|
824
829
|
|