@egjs/flicking 4.14.2-beta.2 → 4.16.0-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 +6 -175
- package/{declaration → dist}/CrossFlicking.d.ts +7 -2
- package/dist/Flicking.d.ts +1231 -0
- package/dist/camera/Camera.d.ts +324 -0
- package/{declaration → dist}/camera/mode/BoundCameraMode.d.ts +5 -4
- package/{declaration → dist}/camera/mode/CameraMode.d.ts +7 -6
- package/{declaration → dist}/camera/mode/CircularCameraMode.d.ts +9 -5
- package/{declaration → dist}/camera/mode/LinearCameraMode.d.ts +2 -4
- package/{declaration → dist}/cfc/getDefaultCameraTransform.d.ts +1 -1
- package/dist/cfc/withFlickingMethods.d.ts +15 -0
- package/{declaration/const/axes.d.ts → dist/constants/internal.d.ts} +8 -0
- package/dist/constants/values.d.ts +67 -0
- package/dist/control/AxesController.d.ts +186 -0
- package/dist/control/Control.d.ts +185 -0
- package/dist/control/FreeControl.d.ts +44 -0
- package/dist/control/SnapControl.d.ts +54 -0
- package/{declaration → dist}/control/StateMachine.d.ts +3 -0
- package/dist/control/StrictControl.d.ts +60 -0
- package/{declaration → dist}/control/states/AnimatingState.d.ts +12 -0
- package/{declaration → dist}/control/states/DisabledState.d.ts +12 -0
- package/{declaration → dist}/control/states/DraggingState.d.ts +12 -0
- package/{declaration → dist}/control/states/HoldingState.d.ts +12 -0
- package/{declaration → dist}/control/states/IdleState.d.ts +12 -0
- package/dist/control/states/State.d.ts +86 -0
- package/dist/core/AnchorPoint.d.ts +40 -0
- package/{declaration → dist}/core/AutoResizer.d.ts +6 -0
- package/dist/core/Viewport.d.ts +60 -0
- package/dist/core/VirtualManager.d.ts +84 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/panel/Panel.d.ts +298 -0
- package/dist/core/panel/VirtualPanel.d.ts +41 -0
- package/dist/core/panel/index.d.ts +5 -0
- package/{declaration → dist}/core/panel/provider/VanillaElementProvider.d.ts +3 -0
- package/{declaration → dist}/core/panel/provider/VirtualElementProvider.d.ts +3 -0
- package/dist/error/FlickingError.d.ts +25 -0
- package/dist/error/codes.d.ts +79 -0
- package/dist/error/groups.d.ts +94 -0
- package/dist/error/index.d.ts +4 -0
- package/dist/error/types.d.ts +516 -0
- package/dist/event/groups.d.ts +40 -0
- package/dist/event/index.d.ts +3 -0
- package/dist/event/names.d.ts +47 -0
- package/dist/event/types.d.ts +318 -0
- package/dist/flicking.cjs.js +5560 -7784
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +5638 -7692
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +6722 -8885
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +1 -9
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +9661 -14078
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +1 -9
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/reactive/index.d.ts +126 -0
- package/{declaration → dist}/renderer/ExternalRenderer.d.ts +3 -0
- package/dist/renderer/Renderer.d.ts +215 -0
- package/{declaration → dist}/renderer/VanillaRenderer.d.ts +6 -0
- package/{declaration → dist}/renderer/strategy/NormalRenderingStrategy.d.ts +5 -2
- package/{declaration → dist}/renderer/strategy/RenderingStrategy.d.ts +4 -1
- package/dist/types/external.d.ts +58 -0
- package/dist/types/params.d.ts +10 -0
- package/{declaration → dist}/utils.d.ts +7 -7
- package/package.json +35 -162
- package/src/CrossFlicking.ts +68 -96
- package/src/Flicking.ts +1055 -972
- package/src/camera/Camera.ts +217 -206
- package/src/camera/index.ts +2 -6
- package/src/camera/mode/BoundCameraMode.ts +38 -27
- package/src/camera/mode/CameraMode.ts +14 -12
- package/src/camera/mode/CircularCameraMode.ts +24 -16
- package/src/camera/mode/LinearCameraMode.ts +3 -1
- package/src/camera/mode/index.ts +4 -10
- package/src/cfc/getDefaultCameraTransform.ts +9 -11
- package/src/cfc/getRenderingPanels.ts +2 -5
- package/src/cfc/index.ts +4 -9
- package/src/cfc/sync.ts +11 -5
- package/src/cfc/withFlickingMethods.ts +6 -7
- package/src/{const/axes.ts → constants/internal.ts} +1 -0
- package/src/constants/values.ts +78 -0
- package/src/control/AxesController.ts +119 -110
- package/src/control/Control.ts +147 -180
- package/src/control/FreeControl.ts +36 -60
- package/src/control/SnapControl.ts +64 -68
- package/src/control/StateMachine.ts +14 -11
- package/src/control/StrictControl.ts +58 -73
- package/src/control/index.ts +9 -12
- package/src/control/states/AnimatingState.ts +8 -11
- package/src/control/states/DisabledState.ts +0 -5
- package/src/control/states/DraggingState.ts +8 -12
- package/src/control/states/HoldingState.ts +10 -15
- package/src/control/states/IdleState.ts +1 -6
- package/src/control/states/State.ts +46 -85
- package/src/core/AnchorPoint.ts +25 -23
- package/src/core/AutoResizer.ts +6 -15
- package/src/core/ResizeWatcher.ts +17 -16
- package/src/core/Viewport.ts +35 -46
- package/src/core/VirtualManager.ts +48 -36
- package/src/core/index.ts +6 -9
- package/src/core/panel/Panel.ts +190 -185
- package/src/core/panel/VirtualPanel.ts +17 -21
- package/src/core/panel/index.ts +4 -9
- package/src/core/panel/provider/VanillaElementProvider.ts +6 -2
- package/src/core/panel/provider/VirtualElementProvider.ts +6 -2
- package/src/core/panel/provider/index.ts +2 -7
- package/src/{core → error}/FlickingError.ts +5 -7
- package/src/error/codes.ts +164 -0
- package/src/error/groups.ts +124 -0
- package/src/error/index.ts +9 -0
- package/src/error/types.ts +535 -0
- package/src/event/groups.ts +61 -0
- package/src/event/index.ts +8 -0
- package/src/event/names.ts +52 -0
- package/src/event/types.ts +355 -0
- package/src/index.ts +9 -11
- package/src/index.umd.ts +9 -3
- package/src/reactive/index.ts +39 -74
- package/src/renderer/Renderer.ts +177 -119
- package/src/renderer/VanillaRenderer.ts +13 -10
- package/src/renderer/index.ts +4 -9
- package/src/renderer/strategy/NormalRenderingStrategy.ts +26 -22
- package/src/renderer/strategy/RenderingStrategy.ts +2 -1
- package/src/renderer/strategy/VirtualRenderingStrategy.ts +20 -13
- package/src/renderer/strategy/index.ts +4 -9
- package/src/types/external.ts +72 -0
- package/src/{type → types}/internal.ts +2 -5
- package/src/types/params.ts +15 -0
- package/src/utils.ts +37 -32
- package/CONTRIBUTING.md +0 -59
- package/NOTICE +0 -31
- package/core-packages-link.js +0 -75
- package/debug/reactive/index.html +0 -240
- package/declaration/Flicking.d.ts +0 -264
- package/declaration/camera/Camera.d.ts +0 -90
- package/declaration/cfc/withFlickingMethods.d.ts +0 -2
- package/declaration/const/error.d.ts +0 -34
- package/declaration/const/external.d.ts +0 -54
- package/declaration/control/AxesController.d.ts +0 -45
- package/declaration/control/Control.d.ts +0 -45
- package/declaration/control/FreeControl.d.ts +0 -14
- package/declaration/control/SnapControl.d.ts +0 -16
- package/declaration/control/StrictControl.d.ts +0 -20
- package/declaration/control/states/State.d.ts +0 -47
- package/declaration/core/AnchorPoint.d.ts +0 -15
- package/declaration/core/FlickingError.d.ts +0 -5
- package/declaration/core/Viewport.d.ts +0 -25
- package/declaration/core/VirtualManager.d.ts +0 -37
- package/declaration/core/index.d.ts +0 -6
- package/declaration/core/panel/Panel.d.ts +0 -89
- package/declaration/core/panel/VirtualPanel.d.ts +0 -19
- package/declaration/core/panel/index.d.ts +0 -5
- package/declaration/index.d.ts +0 -16
- package/declaration/reactive/index.d.ts +0 -25
- package/declaration/renderer/Renderer.d.ts +0 -60
- package/declaration/type/event.d.ts +0 -88
- package/declaration/type/external.d.ts +0 -31
- package/jsconfig.json +0 -5
- package/jsdoc-to-mdx.json +0 -7
- package/rollup.config.demo.js +0 -24
- package/rollup.config.dev.js +0 -12
- package/rollup.config.js +0 -57
- package/src/const/error.ts +0 -64
- package/src/const/external.ts +0 -138
- package/src/type/event.ts +0 -315
- package/src/type/external.ts +0 -78
- package/tsconfig.declaration.json +0 -17
- package/tsconfig.eslint.json +0 -10
- package/tsconfig.json +0 -23
- package/{declaration → dist}/camera/index.d.ts +0 -0
- package/{declaration → dist}/camera/mode/index.d.ts +2 -2
- package/{declaration → dist}/cfc/getRenderingPanels.d.ts +0 -0
- package/{declaration → dist}/cfc/index.d.ts +3 -3
- package/{declaration → dist}/cfc/sync.d.ts +0 -0
- package/{declaration → dist}/control/index.d.ts +7 -7
- package/{declaration → dist}/core/ResizeWatcher.d.ts +0 -0
- package/{declaration → dist}/core/panel/provider/ElementProvider.d.ts +0 -0
- package/{declaration → dist}/core/panel/provider/index.d.ts +0 -0
- package/{declaration → dist}/index.cjs.d.ts +0 -0
- package/{declaration → dist}/index.umd.d.ts +0 -0
- package/{declaration → dist}/renderer/index.d.ts +1 -1
- package/{declaration → dist}/renderer/strategy/VirtualRenderingStrategy.d.ts +1 -1
- package/{declaration → dist}/renderer/strategy/index.d.ts +1 -1
- /package/{declaration/type → dist/types}/internal.d.ts +0 -0
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import { DIRECTION } from "../../constants/values";
|
|
6
7
|
import Panel, { PanelOptions } from "../../core/panel/Panel";
|
|
7
8
|
import ElementProvider from "../../core/panel/provider/ElementProvider";
|
|
8
|
-
import
|
|
9
|
+
import Flicking from "../../Flicking";
|
|
9
10
|
import { parsePanelAlign } from "../../utils";
|
|
10
11
|
|
|
11
12
|
import RenderingStrategy from "./RenderingStrategy";
|
|
@@ -14,11 +15,11 @@ export interface NormalRenderingStrategyOptions {
|
|
|
14
15
|
providerCtor: new (...args: any) => ElementProvider;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
18
|
class NormalRenderingStrategy implements RenderingStrategy {
|
|
19
19
|
private _providerCtor: NormalRenderingStrategyOptions["providerCtor"];
|
|
20
20
|
|
|
21
|
-
public constructor(
|
|
21
|
+
public constructor(options: NormalRenderingStrategyOptions) {
|
|
22
|
+
const { providerCtor } = options;
|
|
22
23
|
this._providerCtor = providerCtor;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -49,37 +50,40 @@ class NormalRenderingStrategy implements RenderingStrategy {
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
public collectPanels(
|
|
53
|
-
flicking: Flicking,
|
|
54
|
-
elements: any[]
|
|
55
|
-
) {
|
|
53
|
+
public collectPanels(flicking: Flicking, elements: any[]) {
|
|
56
54
|
const align = parsePanelAlign(flicking.renderer.align);
|
|
57
55
|
|
|
58
|
-
return elements.map(
|
|
59
|
-
index
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
return elements.map(
|
|
57
|
+
(el, index) =>
|
|
58
|
+
new Panel({
|
|
59
|
+
index,
|
|
60
|
+
elementProvider: new this._providerCtor(el),
|
|
61
|
+
align,
|
|
62
|
+
flicking
|
|
63
|
+
})
|
|
64
|
+
);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
public createPanel(
|
|
67
|
-
element: any,
|
|
68
|
-
options: Omit<PanelOptions, "elementProvider">
|
|
69
|
-
) {
|
|
67
|
+
public createPanel(element: any, options: Omit<PanelOptions, "elementProvider">) {
|
|
70
68
|
return new Panel({
|
|
71
69
|
...options,
|
|
72
70
|
elementProvider: new this._providerCtor(element)
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
public updatePanelSizes(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
public updatePanelSizes(
|
|
75
|
+
flicking: Flicking,
|
|
76
|
+
size: Partial<{
|
|
77
|
+
width: number | string;
|
|
78
|
+
height: number | string;
|
|
79
|
+
}>
|
|
80
|
+
) {
|
|
80
81
|
flicking.panels.forEach(panel => panel.setSize(size));
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
83
87
|
private _showOnlyVisiblePanels(flicking: Flicking) {
|
|
84
88
|
const panels = flicking.renderer.panels;
|
|
85
89
|
const camera = flicking.camera;
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import { PanelOptions } from "../../core/panel/Panel";
|
|
7
|
-
import VirtualPanel from "../../core/panel/VirtualPanel";
|
|
8
7
|
import VirtualElementProvider from "../../core/panel/provider/VirtualElementProvider";
|
|
8
|
+
import VirtualPanel from "../../core/panel/VirtualPanel";
|
|
9
|
+
import Flicking from "../../Flicking";
|
|
9
10
|
import { parsePanelAlign, range, setSize } from "../../utils";
|
|
10
11
|
|
|
11
12
|
import RenderingStrategy from "./RenderingStrategy";
|
|
@@ -37,7 +38,7 @@ class VirtualRenderingStrategy implements RenderingStrategy {
|
|
|
37
38
|
const visiblePanels = [...flicking.visiblePanels]
|
|
38
39
|
.filter(panel => panel.rendered)
|
|
39
40
|
.sort((panel1, panel2) => {
|
|
40
|
-
return
|
|
41
|
+
return panel1.position + panel1.offset - (panel2.position + panel2.offset);
|
|
41
42
|
}) as VirtualPanel[];
|
|
42
43
|
|
|
43
44
|
if (visiblePanels.length <= 0) return virtualManager.elements.map((_, idx) => idx);
|
|
@@ -81,12 +82,15 @@ class VirtualRenderingStrategy implements RenderingStrategy {
|
|
|
81
82
|
public collectPanels(flicking: Flicking) {
|
|
82
83
|
const align = parsePanelAlign(flicking.renderer.align);
|
|
83
84
|
|
|
84
|
-
return range(flicking.virtual.initialPanelCount).map(
|
|
85
|
-
index
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
return range(flicking.virtual.initialPanelCount).map(
|
|
86
|
+
index =>
|
|
87
|
+
new VirtualPanel({
|
|
88
|
+
index,
|
|
89
|
+
elementProvider: new VirtualElementProvider(flicking),
|
|
90
|
+
align,
|
|
91
|
+
flicking
|
|
92
|
+
})
|
|
93
|
+
);
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
public createPanel(_el: any, options: PanelOptions) {
|
|
@@ -96,10 +100,13 @@ class VirtualRenderingStrategy implements RenderingStrategy {
|
|
|
96
100
|
});
|
|
97
101
|
}
|
|
98
102
|
|
|
99
|
-
public updatePanelSizes(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
public updatePanelSizes(
|
|
104
|
+
flicking: Flicking,
|
|
105
|
+
size: Partial<{
|
|
106
|
+
width: number | string;
|
|
107
|
+
height: number | string;
|
|
108
|
+
}>
|
|
109
|
+
) {
|
|
103
110
|
flicking.virtual.elements.forEach(el => {
|
|
104
111
|
setSize(el.nativeElement, size);
|
|
105
112
|
});
|
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import NormalRenderingStrategy, { NormalRenderingStrategyOptions } from "./NormalRenderingStrategy";
|
|
7
|
+
import RenderingStrategy from "./RenderingStrategy";
|
|
7
8
|
import VirtualRenderingStrategy from "./VirtualRenderingStrategy";
|
|
8
9
|
|
|
9
|
-
export {
|
|
10
|
-
NormalRenderingStrategy,
|
|
11
|
-
VirtualRenderingStrategy
|
|
12
|
-
};
|
|
10
|
+
export { NormalRenderingStrategy, VirtualRenderingStrategy };
|
|
13
11
|
|
|
14
|
-
export type {
|
|
15
|
-
RenderingStrategy,
|
|
16
|
-
NormalRenderingStrategyOptions
|
|
17
|
-
};
|
|
12
|
+
export type { RenderingStrategy, NormalRenderingStrategyOptions };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { MOVE_TYPE } from "../constants/values";
|
|
2
|
+
import { FreeControlOptions, SnapControlOptions, StrictControlOptions } from "../control";
|
|
3
|
+
import Flicking from "../Flicking";
|
|
4
|
+
|
|
5
|
+
import { ValueOf } from "./internal";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* HTML `string` of single/mutiple HTMLElement, or an instance of `HTMLElement`
|
|
9
|
+
*/
|
|
10
|
+
export type ElementLike = string | HTMLElement;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Flicking Plugin
|
|
14
|
+
*/
|
|
15
|
+
export interface Plugin {
|
|
16
|
+
/** Initialize the plugin */
|
|
17
|
+
init(flicking: Flicking): void;
|
|
18
|
+
/** Destroy plugin and detach all events binded */
|
|
19
|
+
destroy(): void;
|
|
20
|
+
/** Update plugin to match current Flicking's status */
|
|
21
|
+
update(flicking: Flicking): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Flicking Status returned by {@link Flicking.getStatus}
|
|
26
|
+
*/
|
|
27
|
+
export interface Status {
|
|
28
|
+
/** An index of the active panel */
|
|
29
|
+
index?: number;
|
|
30
|
+
/** A info to restore camera {@link Camera.position | position} */
|
|
31
|
+
position?: {
|
|
32
|
+
/** An index of the panel camera is located at */
|
|
33
|
+
panel: number;
|
|
34
|
+
/** A progress of the camera position inside the panel */
|
|
35
|
+
progressInPanel: number;
|
|
36
|
+
};
|
|
37
|
+
/** An offset to visible panel's original index. This value is available only when `visiblePanelsOnly` is `true` */
|
|
38
|
+
visibleOffset?: number;
|
|
39
|
+
/** A data array of panels */
|
|
40
|
+
panels: Array<{
|
|
41
|
+
/** An index of the panel */
|
|
42
|
+
index: number;
|
|
43
|
+
/** An `outerHTML` of the panel element */
|
|
44
|
+
html?: string;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
49
|
+
export type MoveTypeOptions<T extends ValueOf<typeof MOVE_TYPE>> = T extends typeof MOVE_TYPE.SNAP
|
|
50
|
+
? [T] | [T, Partial<SnapControlOptions>]
|
|
51
|
+
: T extends typeof MOVE_TYPE.FREE_SCROLL
|
|
52
|
+
? [T] | [T, Partial<FreeControlOptions>]
|
|
53
|
+
: T extends typeof MOVE_TYPE.STRICT
|
|
54
|
+
? [T] | [T, Partial<StrictControlOptions>]
|
|
55
|
+
: [T];
|
|
56
|
+
/* eslint-enable */
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A current parameters of the Camera for updating {@link AxesController}
|
|
60
|
+
* @readonly
|
|
61
|
+
*/
|
|
62
|
+
export interface ControlParams {
|
|
63
|
+
/** A moveable range for Camera */
|
|
64
|
+
range: {
|
|
65
|
+
min: number;
|
|
66
|
+
max: number;
|
|
67
|
+
};
|
|
68
|
+
/** Current camera position */
|
|
69
|
+
position: number;
|
|
70
|
+
/** A Boolean indicating whether the {@link Flicking.circular | circular} option is enabled */
|
|
71
|
+
circular: boolean;
|
|
72
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
export type ValueOf<T> = T[keyof T];
|
|
6
|
-
export type LiteralUnion<T extends U, U = string> = T | (Pick<U, never> & {_?: never});
|
|
6
|
+
export type LiteralUnion<T extends U, U = string> = T | (Pick<U, never> & { _?: never });
|
|
7
7
|
|
|
8
8
|
export interface ArrayLike<T> {
|
|
9
9
|
[index: number]: T;
|
|
@@ -20,7 +20,4 @@ export type MergeObject<T, U> = {
|
|
|
20
20
|
: T[K];
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export type Merged<From, To> =
|
|
24
|
-
Unique<From, To>
|
|
25
|
-
& Unique<To, From>
|
|
26
|
-
& MergeObject<From, To>;
|
|
23
|
+
export type Merged<From, To> = Unique<From, To> & Unique<To, From> & MergeObject<From, To>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parameters for setting element size
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface SetSizeParams {
|
|
11
|
+
/** CSS string or number(in px) */
|
|
12
|
+
width?: number | string;
|
|
13
|
+
/** CSS string or number(in px) */
|
|
14
|
+
height?: number | string;
|
|
15
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
+
|
|
6
|
+
import { ALIGN, DIRECTION } from "./constants/values";
|
|
7
|
+
import * as ERROR from "./error/codes";
|
|
8
|
+
import FlickingError from "./error/FlickingError";
|
|
5
9
|
import Flicking, { FlickingOptions } from "./Flicking";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { ALIGN, DIRECTION } from "./const/external";
|
|
9
|
-
import { LiteralUnion, Merged, ValueOf } from "./type/internal";
|
|
10
|
-
import { ElementLike } from "./type/external";
|
|
10
|
+
import { ElementLike } from "./types/external";
|
|
11
|
+
import { LiteralUnion, Merged, ValueOf } from "./types/internal";
|
|
11
12
|
|
|
12
13
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
13
14
|
export const merge = <From extends object, To extends object>(target: From, ...sources: To[]): Merged<From, To> => {
|
|
@@ -112,8 +113,10 @@ export const parseArithmeticSize = (cssValue: number | string, base: number): nu
|
|
|
112
113
|
return parsed.percentage * base + parsed.absolute;
|
|
113
114
|
};
|
|
114
115
|
|
|
115
|
-
export const parseArithmeticExpression = (
|
|
116
|
-
|
|
116
|
+
export const parseArithmeticExpression = (
|
|
117
|
+
cssValue: number | string
|
|
118
|
+
): { percentage: number; absolute: number } | null => {
|
|
119
|
+
const cssRegex = /(?:(\+|-)\s*)?(\d+(?:\.\d+)?(%|px)?)/g;
|
|
117
120
|
|
|
118
121
|
if (typeof cssValue === "number") {
|
|
119
122
|
return { percentage: 0, absolute: cssValue };
|
|
@@ -161,11 +164,10 @@ export const parseArithmeticExpression = (cssValue: number | string): { percenta
|
|
|
161
164
|
return parsed;
|
|
162
165
|
};
|
|
163
166
|
|
|
164
|
-
export const parseCSSSizeValue = (val: string | number): string => isString(val) ? val : `${val}px
|
|
167
|
+
export const parseCSSSizeValue = (val: string | number): string => (isString(val) ? val : `${val}px`);
|
|
165
168
|
|
|
166
|
-
export const parsePanelAlign = (align: FlickingOptions["align"]) =>
|
|
167
|
-
? (align as { panel: string | number }).panel
|
|
168
|
-
: align;
|
|
169
|
+
export const parsePanelAlign = (align: FlickingOptions["align"]) =>
|
|
170
|
+
typeof align === "object" ? (align as { panel: string | number }).panel : align;
|
|
169
171
|
|
|
170
172
|
export const getDirection = (start: number, end: number): ValueOf<typeof DIRECTION> => {
|
|
171
173
|
if (start === end) return DIRECTION.NONE;
|
|
@@ -183,7 +185,7 @@ export const parseElement = (element: ElementLike | ElementLike[]): HTMLElement[
|
|
|
183
185
|
const tempDiv = document.createElement("div");
|
|
184
186
|
tempDiv.innerHTML = el;
|
|
185
187
|
|
|
186
|
-
elements.push(...toArray(tempDiv.children) as HTMLElement[]);
|
|
188
|
+
elements.push(...(toArray(tempDiv.children) as HTMLElement[]));
|
|
187
189
|
while (tempDiv.firstChild) {
|
|
188
190
|
tempDiv.removeChild(tempDiv.firstChild);
|
|
189
191
|
}
|
|
@@ -197,7 +199,8 @@ export const parseElement = (element: ElementLike | ElementLike[]): HTMLElement[
|
|
|
197
199
|
return elements;
|
|
198
200
|
};
|
|
199
201
|
|
|
200
|
-
export const getMinusCompensatedIndex = (idx: number, max: number) =>
|
|
202
|
+
export const getMinusCompensatedIndex = (idx: number, max: number) =>
|
|
203
|
+
idx < 0 ? clamp(idx + max, 0, max) : clamp(idx, 0, max);
|
|
201
204
|
|
|
202
205
|
export const includes = <T>(array: T[], target: any): target is T => {
|
|
203
206
|
for (const val of array) {
|
|
@@ -260,13 +263,19 @@ export const getStyle = (el: HTMLElement): CSSStyleDeclaration => {
|
|
|
260
263
|
if (!el) {
|
|
261
264
|
return {} as CSSStyleDeclaration;
|
|
262
265
|
}
|
|
263
|
-
return window.getComputedStyle(el) || (el as any).currentStyle as CSSStyleDeclaration;
|
|
266
|
+
return window.getComputedStyle(el) || ((el as any).currentStyle as CSSStyleDeclaration);
|
|
264
267
|
};
|
|
265
268
|
|
|
266
|
-
export const setSize = (
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
export const setSize = (
|
|
270
|
+
el: HTMLElement,
|
|
271
|
+
{
|
|
272
|
+
width,
|
|
273
|
+
height
|
|
274
|
+
}: Partial<{
|
|
275
|
+
width: number | string;
|
|
276
|
+
height: number | string;
|
|
277
|
+
}>
|
|
278
|
+
) => {
|
|
270
279
|
if (!el) {
|
|
271
280
|
return;
|
|
272
281
|
}
|
|
@@ -293,7 +302,7 @@ export const circulateIndex = (index: number, max: number): number => {
|
|
|
293
302
|
if (index >= max) {
|
|
294
303
|
return index % max;
|
|
295
304
|
} else if (index < 0) {
|
|
296
|
-
return getMinusCompensatedIndex((index + 1) % max - 1, max);
|
|
305
|
+
return getMinusCompensatedIndex(((index + 1) % max) - 1, max);
|
|
297
306
|
} else {
|
|
298
307
|
return index;
|
|
299
308
|
}
|
|
@@ -331,33 +340,29 @@ export const getElementSize = ({
|
|
|
331
340
|
: parseFloat(style.borderTopWidth || "0") + parseFloat(style.borderBottomWidth || "0");
|
|
332
341
|
|
|
333
342
|
if (isBorderBoxSizing) {
|
|
334
|
-
size = useOffset
|
|
335
|
-
? baseSize
|
|
336
|
-
: baseSize - border;
|
|
343
|
+
size = useOffset ? baseSize : baseSize - border;
|
|
337
344
|
} else {
|
|
338
345
|
const padding = horizontal
|
|
339
346
|
? parseFloat(style.paddingLeft || "0") + parseFloat(style.paddingRight || "0")
|
|
340
347
|
: parseFloat(style.paddingTop || "0") + parseFloat(style.paddingBottom || "0");
|
|
341
348
|
|
|
342
|
-
size = useOffset
|
|
343
|
-
? baseSize + padding + border
|
|
344
|
-
: baseSize + padding;
|
|
349
|
+
size = useOffset ? baseSize + padding + border : baseSize + padding;
|
|
345
350
|
}
|
|
346
351
|
} else {
|
|
347
352
|
const sizeStr = horizontal ? "Width" : "Height";
|
|
348
353
|
|
|
349
|
-
size = useOffset
|
|
350
|
-
? el[`offset${sizeStr}`]
|
|
351
|
-
: el[`client${sizeStr}`];
|
|
354
|
+
size = useOffset ? el[`offset${sizeStr}`] : el[`client${sizeStr}`];
|
|
352
355
|
}
|
|
353
356
|
|
|
354
357
|
return Math.max(size, 0);
|
|
355
358
|
};
|
|
356
359
|
|
|
357
|
-
export const setPrototypeOf =
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
360
|
+
export const setPrototypeOf =
|
|
361
|
+
Object.setPrototypeOf ||
|
|
362
|
+
((obj, proto) => {
|
|
363
|
+
obj.__proto__ = proto;
|
|
364
|
+
return obj;
|
|
365
|
+
});
|
|
361
366
|
|
|
362
367
|
export const camelize = (str: string): string => {
|
|
363
368
|
return str.replace(/[\s-_]([a-z])/g, (all, letter) => letter.toUpperCase());
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# How to contribute to egjs-flicking
|
|
2
|
-
egjs-flicking is opened to everyone and we're welcoming for any kind of contribution.
|
|
3
|
-
We believe that our project can grow with your interests helping others' necessities.
|
|
4
|
-
|
|
5
|
-
## Style Guide
|
|
6
|
-
|
|
7
|
-
egjs-flicking has several style guidelines to follow.
|
|
8
|
-
Before your start, please read attentively below instructions.
|
|
9
|
-
|
|
10
|
-
### Linting and Code Conventions
|
|
11
|
-
We adopted [ESLint](http://eslint.org/) to maintain our code quality. The [rules](https://github.com/naver/eslint-config-naver/tree/master/rules) are modified version based on [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript).
|
|
12
|
-
All rules are described at [.eslintrc](.eslintrc) file.
|
|
13
|
-
|
|
14
|
-
### Commit Log Guidelines
|
|
15
|
-
egjs-flicking use commit logs in many different purposes (like creating CHANGELOG, ease history searching, etc.).
|
|
16
|
-
To not break, you'll be forced to follow our commit log guidelines.
|
|
17
|
-
Before your commit/push, make sure following our commit log guidelines.
|
|
18
|
-
|
|
19
|
-
The outline is as below:
|
|
20
|
-
```
|
|
21
|
-
<type>(<module>): <subject>
|
|
22
|
-
<BLANK LINE>
|
|
23
|
-
<body>
|
|
24
|
-
<BLANK LINE>
|
|
25
|
-
<footer>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
- **Types**
|
|
29
|
-
- **feat**: A new feature
|
|
30
|
-
- **fix**: A bug fix
|
|
31
|
-
- **docs**: Documentation only changes
|
|
32
|
-
- **style**: Changes that do not affect the meaning of the code. Such as white-space, formatting, missing semi-colons, etc... It also possible to change JSHint, JSCS rules of the code.
|
|
33
|
-
- **refactor**: A code change that neither fixes a bug nor adds a feature
|
|
34
|
-
- **test**: Adding missing tests. Changing tests.
|
|
35
|
-
- **demo**: Adding missing demos. Changing demos.
|
|
36
|
-
- **chore**: Changes to the build process or tools and libraries such as documentation generation
|
|
37
|
-
|
|
38
|
-
[See More Commit Log Guidelines](https://github.com/naver/egjs/wiki/Commit-Log-Guidelines)
|
|
39
|
-
|
|
40
|
-
## How to submit Pull Requests
|
|
41
|
-
Steps to submit your pull request:
|
|
42
|
-
|
|
43
|
-
1. Fork `egjs-flicking` on your repository
|
|
44
|
-
2. Create new branch from your egjs master branch (and be sure always to be up-to-date)
|
|
45
|
-
3. Before starting a local development, `npm run docs:build` in the root directory to generate API documents.
|
|
46
|
-
4. Do your work
|
|
47
|
-
5. Create test code for your work (when is possible)
|
|
48
|
-
6. Run `npm run lint` for linting and Code Conventions (update until without any error or warnings)
|
|
49
|
-
7. Run test code by `npm run test OR npm run test:chrome`.
|
|
50
|
-
Make sure tests are all passed at least in Chrome(latest desktop version)
|
|
51
|
-
8. Write commit log following convention and push to your repository branch.
|
|
52
|
-
9. Create a new PR from your branch to egjs-flicking.
|
|
53
|
-
10. Wait for reviews.
|
|
54
|
-
When your contribution is well enough to be accepted, then will be merged to our branch.
|
|
55
|
-
11. All done!
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## License
|
|
59
|
-
By contributing to egjs-flicking, you're agreeing that your contributions will be licensed under its [MIT](https://opensource.org/licenses/MIT) license.
|
package/NOTICE
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
egjs-flicking
|
|
2
|
-
Copyright 2015 NAVER Corp.
|
|
3
|
-
|
|
4
|
-
This project contains subcomponents with separate copyright notices and license terms.
|
|
5
|
-
Your use of the source code for these subcomponents is subject to the terms and conditions of the following licenses.
|
|
6
|
-
|
|
7
|
-
=====
|
|
8
|
-
|
|
9
|
-
AngularJS from https://github.com/angular/angular.js
|
|
10
|
-
|
|
11
|
-
=====
|
|
12
|
-
|
|
13
|
-
Copyright (c) 2010-2015 Google, Inc. http://angularjs.org
|
|
14
|
-
|
|
15
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
-
in the Software without restriction, including without limitation the rights
|
|
18
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
-
furnished to do so, subject to the following conditions:
|
|
21
|
-
|
|
22
|
-
The above copyright notice and this permission notice shall be included in
|
|
23
|
-
all copies or substantial portions of the Software.
|
|
24
|
-
|
|
25
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
31
|
-
THE SOFTWARE.
|
package/core-packages-link.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 프레임워크 컴포넌트를 디버깅할 때 코어 바닐라 로직을 수정하면서 확인할 필요가 있을 때,
|
|
5
|
-
* 이 스크립트를 이용하면 바닐라 로직 수정사항이 프레임워크 컴포넌트 로컬 데모환경에도 반영된다.
|
|
6
|
-
* 다만, 바닐라 로직 수정 이후 리액트 데모에 핫 모듈 리로딩까지는 되지 않는다.
|
|
7
|
-
* 따라서 수정 사항들을 추가적으로 반영해주려면 바닐라를 다시 빌드해야 한다. 링크는 다시 하지 않아도 된다.
|
|
8
|
-
*
|
|
9
|
-
* 인자로 프레임워크 컴포넌트 패키지의 루트 디렉토리를 제공하면 된다.
|
|
10
|
-
* 인자를 제공하지 않으면 packages 하위의 전체 프레임워크 패키지에 대해 링크를 시도한다.
|
|
11
|
-
*
|
|
12
|
-
* 사용 예시: node core-package-link.js react-flicking
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* 개발 흐름:
|
|
16
|
-
* 1. 이 스크립트를 실행
|
|
17
|
-
* 2. 바닐라 로직 수정 후 빌드 수행
|
|
18
|
-
* 3. 프레임워크 컴포넌트의 데모를 실행 (바닐라 로직 변경사항이 반영됨)
|
|
19
|
-
* 4. 바닐라 로직 추가 수정 후 빌드 수행
|
|
20
|
-
* 5. 프레임워크 컴포넌트의 데모를 새로고침 (바닐라 로직 변경사항이 반영됨)
|
|
21
|
-
* - 원래는 새로고침만 하면 되야 하지만 타입 에러가 발생하는 경우가 있어 데모를 중지하고 다시 실행해야 할 수도 있다.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function run(cmd, cwd = process.cwd()) {
|
|
29
|
-
console.log(`\n▶️ Running: ${cmd} (in ${cwd})`);
|
|
30
|
-
execSync(cmd, { stdio: "inherit", cwd });
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const { execSync } = require("child_process");
|
|
34
|
-
const path = require("path");
|
|
35
|
-
const fs = require("fs");
|
|
36
|
-
|
|
37
|
-
const frameworks = [
|
|
38
|
-
"ngx-flicking",
|
|
39
|
-
"preact-flicking",
|
|
40
|
-
"react-flicking",
|
|
41
|
-
"vue-flicking",
|
|
42
|
-
"vue3-flicking",
|
|
43
|
-
"svelte-flicking",
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
const args = process.argv.slice(2);
|
|
47
|
-
const targetDir = args[0];
|
|
48
|
-
|
|
49
|
-
if (!targetDir) {
|
|
50
|
-
console.log(
|
|
51
|
-
"❗️ 디렉토리명을 인자로 입력하지 않았습니다. 전체 프레임워크에 대해 링크를 시도합니다."
|
|
52
|
-
);
|
|
53
|
-
run("npm run build");
|
|
54
|
-
run("npm link");
|
|
55
|
-
frameworks.forEach((target) => {
|
|
56
|
-
const fullPath = path.resolve(process.cwd(), "packages", target);
|
|
57
|
-
if (!fs.existsSync(fullPath)) {
|
|
58
|
-
console.error(`❌ 디렉토리 없음: ${fullPath}`);
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
run(`npm link '@egjs/flicking'`, fullPath);
|
|
62
|
-
});
|
|
63
|
-
} else {
|
|
64
|
-
const fullPath = path.resolve(process.cwd(), "packages", targetDir);
|
|
65
|
-
if (!fs.existsSync(fullPath)) {
|
|
66
|
-
console.error(`❌ 디렉토리 없음: ${fullPath}`);
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
run("npm run build");
|
|
71
|
-
run("npm link");
|
|
72
|
-
run(`npm link '@egjs/flicking'`, fullPath);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|