@egjs/flicking-plugins 4.7.2-beta.1 → 4.7.2-beta.10
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 +42 -51
- package/css/all.css +2 -0
- package/css/arrow.css +2 -2
- package/css/pagination.css +5 -3
- package/declaration/Arrow.d.ts +63 -2
- package/declaration/AutoPlay.d.ts +68 -4
- package/declaration/Fade.d.ts +25 -0
- package/declaration/Parallax.d.ts +25 -0
- package/declaration/Perspective.d.ts +45 -2
- package/declaration/Sync.d.ts +57 -2
- package/declaration/index.d.ts +7 -4
- package/declaration/pagination/Pagination.d.ts +81 -1
- package/declaration/pagination/renderer/Renderer.d.ts +1 -1
- package/declaration/tsdoc-metadata.json +11 -0
- package/dist/arrow.css +2 -2
- package/dist/flicking-plugins.css +23 -8
- package/dist/flicking-plugins.min.css +1 -1
- package/dist/pagination.css +21 -6
- package/dist/pagination.min.css +1 -1
- package/dist/plugins.esm.js +1020 -1535
- package/dist/plugins.esm.js.map +1 -1
- package/dist/plugins.js +1044 -1571
- package/dist/plugins.js.map +1 -1
- package/dist/plugins.min.js +1 -9
- package/dist/plugins.min.js.map +1 -1
- package/package.json +49 -105
- package/src/Arrow.ts +124 -49
- package/src/AutoPlay.ts +110 -31
- package/src/Fade.ts +31 -11
- package/src/Parallax.ts +31 -11
- package/src/Perspective.ts +69 -22
- package/src/Sync.ts +61 -19
- package/src/index.ts +9 -22
- package/src/pagination/Pagination.ts +163 -40
- package/src/pagination/index.ts +2 -6
- package/src/pagination/renderer/BulletRenderer.ts +1 -4
- package/src/pagination/renderer/FractionRenderer.ts +1 -3
- package/src/pagination/renderer/Renderer.ts +14 -13
- package/src/pagination/renderer/ScrollBulletRenderer.ts +5 -12
- package/CONTRIBUTING +0 -58
- package/rollup.config.dev.js +0 -17
- package/rollup.config.js +0 -33
- package/tsconfig.declaration.json +0 -10
- package/tsconfig.eslint.json +0 -8
- package/tsconfig.json +0 -17
- package/tsconfig.test.json +0 -21
package/src/Fade.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import Flicking, { EVENTS, Plugin } from "@egjs/flicking";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
* @memberof Flicking.Plugins
|
|
4
|
+
* A plugin to apply fade in/out effect while panels are moving
|
|
5
|
+
* @see {@link https://naver.github.io/egjs-flicking/docs/demos/plugins/fade | Demo: Fade}
|
|
7
6
|
*/
|
|
8
7
|
class Fade implements Plugin {
|
|
9
8
|
private _flicking: Flicking | null;
|
|
@@ -12,15 +11,31 @@ class Fade implements Plugin {
|
|
|
12
11
|
private _selector: string;
|
|
13
12
|
private _scale: number;
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/** CSS selector for the element to apply the fade effect. If empty, the panel element itself is used
|
|
15
|
+
* @readonly
|
|
16
|
+
*/
|
|
17
|
+
public get selector() {
|
|
18
|
+
return this._selector;
|
|
19
|
+
}
|
|
20
|
+
/** Effect amplification scale
|
|
21
|
+
* @readonly
|
|
22
|
+
*/
|
|
23
|
+
public get scale() {
|
|
24
|
+
return this._scale;
|
|
25
|
+
}
|
|
17
26
|
|
|
18
|
-
|
|
19
|
-
public set
|
|
27
|
+
/** Sets the CSS selector for the target fade element. */
|
|
28
|
+
public set selector(val: string) {
|
|
29
|
+
this._selector = val;
|
|
30
|
+
}
|
|
31
|
+
/** Sets the effect amplification scale. */
|
|
32
|
+
public set scale(val: number) {
|
|
33
|
+
this._scale = val;
|
|
34
|
+
}
|
|
20
35
|
|
|
21
36
|
/**
|
|
22
|
-
* @param -
|
|
23
|
-
* @param - Effect
|
|
37
|
+
* @param selector - CSS selector for the element to apply the fade effect. If empty, the panel element itself is used
|
|
38
|
+
* @param scale - Effect amplification scale
|
|
24
39
|
* @example
|
|
25
40
|
* ```ts
|
|
26
41
|
* flicking.addPlugins(new Fade("p", 1));
|
|
@@ -32,6 +47,9 @@ class Fade implements Plugin {
|
|
|
32
47
|
this._scale = scale;
|
|
33
48
|
}
|
|
34
49
|
|
|
50
|
+
/** Initialize the plugin and apply the fade effect to the Flicking instance.
|
|
51
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
52
|
+
*/
|
|
35
53
|
public init(flicking: Flicking): void {
|
|
36
54
|
if (this._flicking) {
|
|
37
55
|
this.destroy();
|
|
@@ -44,6 +62,7 @@ class Fade implements Plugin {
|
|
|
44
62
|
this._onMove();
|
|
45
63
|
}
|
|
46
64
|
|
|
65
|
+
/** Destroy the plugin and remove all event listeners. */
|
|
47
66
|
public destroy(): void {
|
|
48
67
|
if (!this._flicking) return;
|
|
49
68
|
|
|
@@ -52,6 +71,7 @@ class Fade implements Plugin {
|
|
|
52
71
|
this._flicking = null;
|
|
53
72
|
}
|
|
54
73
|
|
|
74
|
+
/** Recalculate and apply the fade effect to all visible panels. */
|
|
55
75
|
public update = (): void => {
|
|
56
76
|
this._onMove();
|
|
57
77
|
};
|
|
@@ -68,10 +88,10 @@ class Fade implements Plugin {
|
|
|
68
88
|
panels.forEach(panel => {
|
|
69
89
|
const progress = panel.outsetProgress;
|
|
70
90
|
const el = panel.element;
|
|
71
|
-
const target = selector ? el.querySelector
|
|
91
|
+
const target = selector ? (el.querySelector(selector) as HTMLElement) : el;
|
|
72
92
|
|
|
73
93
|
if (target) {
|
|
74
|
-
const opacity = Math.min(
|
|
94
|
+
const opacity = Math.min(1, Math.max(0, 1 - Math.abs(progress * scale)));
|
|
75
95
|
target.style.opacity = `${opacity}`;
|
|
76
96
|
}
|
|
77
97
|
});
|
package/src/Parallax.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import Flicking, { EVENTS, Plugin } from "@egjs/flicking";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
* @memberof Flicking.Plugins
|
|
4
|
+
* A plugin to apply parallax effect while panels are moving
|
|
5
|
+
* @see {@link https://naver.github.io/egjs-flicking/docs/demos/plugins/parallax | Demo: Parallax}
|
|
7
6
|
*/
|
|
8
7
|
class Parallax implements Plugin {
|
|
9
8
|
private _flicking: Flicking | null;
|
|
@@ -12,15 +11,31 @@ class Parallax implements Plugin {
|
|
|
12
11
|
private _selector: string;
|
|
13
12
|
private _scale: number;
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/** CSS selector for the element to apply the parallax effect. If empty, the panel element itself is used
|
|
15
|
+
* @readonly
|
|
16
|
+
*/
|
|
17
|
+
public get selector() {
|
|
18
|
+
return this._selector;
|
|
19
|
+
}
|
|
20
|
+
/** Effect amplification scale
|
|
21
|
+
* @readonly
|
|
22
|
+
*/
|
|
23
|
+
public get scale() {
|
|
24
|
+
return this._scale;
|
|
25
|
+
}
|
|
17
26
|
|
|
18
|
-
|
|
19
|
-
public set
|
|
27
|
+
/** Sets the CSS selector for the target parallax element. */
|
|
28
|
+
public set selector(val: string) {
|
|
29
|
+
this._selector = val;
|
|
30
|
+
}
|
|
31
|
+
/** Sets the effect amplification scale. */
|
|
32
|
+
public set scale(val: number) {
|
|
33
|
+
this._scale = val;
|
|
34
|
+
}
|
|
20
35
|
|
|
21
36
|
/**
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
37
|
+
* @param selector - CSS selector for the element to apply the parallax effect. If empty, the panel element itself is used
|
|
38
|
+
* @param scale - Effect amplification scale
|
|
24
39
|
* @example
|
|
25
40
|
* ```ts
|
|
26
41
|
* flicking.addPlugins(new Parallax("img", 1));
|
|
@@ -32,6 +47,9 @@ class Parallax implements Plugin {
|
|
|
32
47
|
this._scale = scale;
|
|
33
48
|
}
|
|
34
49
|
|
|
50
|
+
/** Initialize the plugin and apply the parallax effect to the Flicking instance.
|
|
51
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
52
|
+
*/
|
|
35
53
|
public init(flicking: Flicking): void {
|
|
36
54
|
if (this._flicking) {
|
|
37
55
|
this.destroy();
|
|
@@ -44,6 +62,7 @@ class Parallax implements Plugin {
|
|
|
44
62
|
this._onMove();
|
|
45
63
|
}
|
|
46
64
|
|
|
65
|
+
/** Destroy the plugin and remove all event listeners. */
|
|
47
66
|
public destroy(): void {
|
|
48
67
|
if (!this._flicking) return;
|
|
49
68
|
|
|
@@ -52,6 +71,7 @@ class Parallax implements Plugin {
|
|
|
52
71
|
this._flicking = null;
|
|
53
72
|
}
|
|
54
73
|
|
|
74
|
+
/** Recalculate and apply the parallax effect to all visible panels. */
|
|
55
75
|
public update = (): void => {
|
|
56
76
|
this._onMove();
|
|
57
77
|
};
|
|
@@ -66,11 +86,11 @@ class Parallax implements Plugin {
|
|
|
66
86
|
panels.forEach(panel => {
|
|
67
87
|
const progress = panel.outsetProgress;
|
|
68
88
|
const el = panel.element;
|
|
69
|
-
const target = this._selector ? el.querySelector
|
|
89
|
+
const target = this._selector ? (el.querySelector(this._selector) as HTMLElement) : el;
|
|
70
90
|
const parentTarget = target.parentNode as Element;
|
|
71
91
|
const rect = target.getBoundingClientRect();
|
|
72
92
|
const parentRect = parentTarget.getBoundingClientRect();
|
|
73
|
-
const position = (parentRect.width - rect.width) / 2 * progress * this._scale;
|
|
93
|
+
const position = ((parentRect.width - rect.width) / 2) * progress * this._scale;
|
|
74
94
|
const transform = `translate(-50%) translate(${position}px)`;
|
|
75
95
|
const style = target.style;
|
|
76
96
|
|
package/src/Perspective.ts
CHANGED
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
import Flicking, { EVENTS, Plugin } from "@egjs/flicking";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Options for the {@link Perspective} plugin
|
|
6
|
+
*/
|
|
7
|
+
export interface PerspectiveOptions {
|
|
8
|
+
/**
|
|
9
|
+
* CSS selector for the element to apply the perspective effect. If empty, the panel element itself is used
|
|
10
|
+
* @defaultValue ""
|
|
11
|
+
*/
|
|
5
12
|
selector: string;
|
|
13
|
+
/**
|
|
14
|
+
* Effect amplification scale
|
|
15
|
+
* @defaultValue 1
|
|
16
|
+
*/
|
|
6
17
|
scale: number;
|
|
18
|
+
/**
|
|
19
|
+
* Rotation amplification scale
|
|
20
|
+
* @defaultValue 1
|
|
21
|
+
*/
|
|
7
22
|
rotate: number;
|
|
23
|
+
/**
|
|
24
|
+
* The value of the CSS `perspective` property (px)
|
|
25
|
+
* @defaultValue 1000
|
|
26
|
+
*/
|
|
8
27
|
perspective: number;
|
|
9
28
|
}
|
|
10
29
|
|
|
11
30
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
* @memberof Flicking.Plugins
|
|
31
|
+
* A plugin to apply 3D perspective effect while panels are moving
|
|
32
|
+
* @see {@link https://naver.github.io/egjs-flicking/docs/demos/plugins/perspective | Demo: Perspective}
|
|
15
33
|
*/
|
|
16
34
|
class Perspective implements Plugin {
|
|
17
35
|
private _flicking: Flicking | null;
|
|
@@ -22,27 +40,50 @@ class Perspective implements Plugin {
|
|
|
22
40
|
private _rotate: PerspectiveOptions["rotate"];
|
|
23
41
|
private _perspective: PerspectiveOptions["perspective"];
|
|
24
42
|
|
|
25
|
-
|
|
26
|
-
public get
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
/** Current value of the {@link PerspectiveOptions.selector | selector} option. */
|
|
44
|
+
public get selector() {
|
|
45
|
+
return this._selector;
|
|
46
|
+
}
|
|
47
|
+
/** Current value of the {@link PerspectiveOptions.scale | scale} option. */
|
|
48
|
+
public get scale() {
|
|
49
|
+
return this._scale;
|
|
50
|
+
}
|
|
51
|
+
/** Current value of the {@link PerspectiveOptions.rotate | rotate} option. */
|
|
52
|
+
public get rotate() {
|
|
53
|
+
return this._rotate;
|
|
54
|
+
}
|
|
55
|
+
/** Current value of the {@link PerspectiveOptions.perspective | perspective} option. */
|
|
56
|
+
public get perspective() {
|
|
57
|
+
return this._perspective;
|
|
58
|
+
}
|
|
29
59
|
|
|
30
|
-
|
|
31
|
-
public set
|
|
32
|
-
|
|
33
|
-
|
|
60
|
+
/** Sets {@link PerspectiveOptions.selector | selector}. */
|
|
61
|
+
public set selector(val: string) {
|
|
62
|
+
this._selector = val;
|
|
63
|
+
}
|
|
64
|
+
/** Sets {@link PerspectiveOptions.scale | scale}. */
|
|
65
|
+
public set scale(val: number) {
|
|
66
|
+
this._scale = val;
|
|
67
|
+
}
|
|
68
|
+
/** Sets {@link PerspectiveOptions.rotate | rotate}. */
|
|
69
|
+
public set rotate(val: number) {
|
|
70
|
+
this._rotate = val;
|
|
71
|
+
}
|
|
72
|
+
/** Sets {@link PerspectiveOptions.perspective | perspective}. */
|
|
73
|
+
public set perspective(val: number) {
|
|
74
|
+
this._perspective = val;
|
|
75
|
+
}
|
|
34
76
|
|
|
35
77
|
/**
|
|
36
|
-
* @param -
|
|
37
|
-
* @param - Effect amplication scale.<ko>효과 증폭도</ko>
|
|
38
|
-
* @param - Effect amplication rotate.<ko>회전 증폭도</ko>
|
|
39
|
-
* @param - The value of perspective CSS property. <ko>css perspective 속성 값</ko>
|
|
78
|
+
* @param options - Options for the Perspective instance
|
|
40
79
|
* @example
|
|
41
80
|
* ```ts
|
|
42
|
-
* flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective
|
|
81
|
+
* flicking.addPlugins(new Perspective({ selector: "p", scale: 1, rotate: 1, perspective: 1000 }));
|
|
43
82
|
* ```
|
|
44
83
|
*/
|
|
45
|
-
public constructor(
|
|
84
|
+
public constructor(options: Partial<PerspectiveOptions> = {}) {
|
|
85
|
+
const { selector = "", scale = 1, rotate = 1, perspective = 1000 } = options;
|
|
86
|
+
|
|
46
87
|
this._flicking = null;
|
|
47
88
|
this._selector = selector;
|
|
48
89
|
this._scale = scale;
|
|
@@ -50,6 +91,9 @@ class Perspective implements Plugin {
|
|
|
50
91
|
this._perspective = perspective;
|
|
51
92
|
}
|
|
52
93
|
|
|
94
|
+
/** Initialize the plugin and apply the perspective effect to the Flicking instance.
|
|
95
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
96
|
+
*/
|
|
53
97
|
public init(flicking: Flicking): void {
|
|
54
98
|
if (this._flicking) {
|
|
55
99
|
this.destroy();
|
|
@@ -62,6 +106,7 @@ class Perspective implements Plugin {
|
|
|
62
106
|
this._onMove();
|
|
63
107
|
}
|
|
64
108
|
|
|
109
|
+
/** Destroy the plugin and remove all event listeners. */
|
|
65
110
|
public destroy(): void {
|
|
66
111
|
if (!this._flicking) return;
|
|
67
112
|
|
|
@@ -70,6 +115,7 @@ class Perspective implements Plugin {
|
|
|
70
115
|
this._flicking = null;
|
|
71
116
|
}
|
|
72
117
|
|
|
118
|
+
/** Recalculate and apply the perspective effect to all visible panels. */
|
|
73
119
|
public update = (): void => {
|
|
74
120
|
this._onMove();
|
|
75
121
|
};
|
|
@@ -78,7 +124,7 @@ class Perspective implements Plugin {
|
|
|
78
124
|
const flicking = this._flicking;
|
|
79
125
|
const selector = this._selector;
|
|
80
126
|
const scale = this._scale;
|
|
81
|
-
const rotate =
|
|
127
|
+
const rotate = this._rotate;
|
|
82
128
|
const perspective = this._perspective;
|
|
83
129
|
|
|
84
130
|
if (!flicking) return;
|
|
@@ -86,12 +132,13 @@ class Perspective implements Plugin {
|
|
|
86
132
|
const horizontal = flicking.horizontal;
|
|
87
133
|
const panels = flicking.visiblePanels;
|
|
88
134
|
|
|
89
|
-
panels.forEach(
|
|
135
|
+
panels.forEach(panel => {
|
|
90
136
|
const progress = panel.outsetProgress;
|
|
91
137
|
const el = panel.element;
|
|
92
|
-
const target = selector ? el.querySelector
|
|
138
|
+
const target = selector ? (el.querySelector(selector) as HTMLElement) : el;
|
|
93
139
|
const panelScale = 1 / (Math.abs(progress * scale) + 1);
|
|
94
|
-
const rotateDegree =
|
|
140
|
+
const rotateDegree =
|
|
141
|
+
progress > 0 ? Math.min(90, progress * 100 * rotate) : Math.max(-90, progress * 100 * rotate);
|
|
95
142
|
const [rotateX, rotateY] = horizontal ? [0, rotateDegree] : [rotateDegree, 0];
|
|
96
143
|
|
|
97
144
|
target.style.transform = `perspective(${perspective}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${panelScale})`;
|
package/src/Sync.ts
CHANGED
|
@@ -1,35 +1,53 @@
|
|
|
1
|
+
import type { MoveEndEvent, MoveEvent, MoveStartEvent, Plugin, SelectEvent, WillChangeEvent } from "@egjs/flicking";
|
|
1
2
|
import Flicking, { clamp, EVENTS } from "@egjs/flicking";
|
|
2
|
-
import type { MoveEndEvent, MoveEvent, MoveStartEvent, Plugin, WillChangeEvent, SelectEvent } from "@egjs/flicking";
|
|
3
3
|
|
|
4
4
|
import { SYNC } from "./const";
|
|
5
5
|
import { addClass, removeClass } from "./utils";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @property {SychronizableFlickingOptions} [synchronizedFlickingOptions=[]] Detailed options for syncing Flickings.
|
|
8
|
+
* Options for the {@link Sync} plugin
|
|
10
9
|
*/
|
|
11
10
|
export interface SyncOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Method to synchronize between Flickings. `"camera"` syncs by camera position, `"index"` syncs by panel index
|
|
13
|
+
* @defaultValue "camera"
|
|
14
|
+
*/
|
|
12
15
|
type: typeof SYNC.TYPE.CAMERA | typeof SYNC.TYPE.INDEX;
|
|
16
|
+
/**
|
|
17
|
+
* Detailed options for each Flicking instance to synchronize
|
|
18
|
+
* @defaultValue []
|
|
19
|
+
*/
|
|
13
20
|
synchronizedFlickingOptions: SychronizableFlickingOptions[];
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @property {boolean} [isClickable=false] By enabling this option, clicking the given Flicking's panel will change the given & other Flicking's index
|
|
19
|
-
* @property {boolean} [isSlidable=false] By enabling this option, the given Flicking's scroll with mouse/touch input will change other Flicking's index. Only available for the index type
|
|
20
|
-
* @property {string | undefined} [activeClass=undefined] An extra class for the panels when selected
|
|
24
|
+
* Per-instance synchronization options used in {@link SyncOptions.synchronizedFlickingOptions}
|
|
21
25
|
*/
|
|
22
26
|
export interface SychronizableFlickingOptions {
|
|
27
|
+
/**
|
|
28
|
+
* The Flicking instance to synchronize
|
|
29
|
+
*/
|
|
23
30
|
flicking: Flicking;
|
|
31
|
+
/**
|
|
32
|
+
* Whether clicking this Flicking's panel changes the index of all synced Flickings
|
|
33
|
+
* @defaultValue false
|
|
34
|
+
*/
|
|
24
35
|
isClickable?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether mouse/touch scroll on this Flicking changes other Flickings' index. Only available for the `"index"` type
|
|
38
|
+
* @defaultValue false
|
|
39
|
+
*/
|
|
25
40
|
isSlidable?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* CSS class added to the active (selected) panel
|
|
43
|
+
* @defaultValue undefined
|
|
44
|
+
*/
|
|
26
45
|
activeClass?: string;
|
|
27
46
|
}
|
|
28
47
|
|
|
29
48
|
/**
|
|
30
|
-
* Plugin for synchronizing multiple
|
|
31
|
-
* @
|
|
32
|
-
* @memberof Flicking.Plugins
|
|
49
|
+
* Plugin for synchronizing multiple Flicking instances
|
|
50
|
+
* @see {@link https://naver.github.io/egjs-flicking/docs/demos/plugins/sync | Demo: Sync}
|
|
33
51
|
*/
|
|
34
52
|
class Sync implements Plugin {
|
|
35
53
|
/* Internal Values */
|
|
@@ -40,26 +58,48 @@ class Sync implements Plugin {
|
|
|
40
58
|
private _type: SyncOptions["type"];
|
|
41
59
|
private _synchronizedFlickingOptions: SyncOptions["synchronizedFlickingOptions"];
|
|
42
60
|
|
|
43
|
-
|
|
44
|
-
public get
|
|
61
|
+
/** Current value of the {@link SyncOptions.type | type} option. */
|
|
62
|
+
public get type() {
|
|
63
|
+
return this._type;
|
|
64
|
+
}
|
|
65
|
+
/** Current value of the {@link SyncOptions.synchronizedFlickingOptions | synchronizedFlickingOptions} option. */
|
|
66
|
+
public get synchronizedFlickingOptions() {
|
|
67
|
+
return this._synchronizedFlickingOptions;
|
|
68
|
+
}
|
|
45
69
|
|
|
70
|
+
/** Sets {@link SyncOptions.type | type}. */
|
|
46
71
|
public set type(val: SyncOptions["type"]) {
|
|
47
72
|
this._type = val;
|
|
48
73
|
}
|
|
49
74
|
|
|
75
|
+
/** Sets {@link SyncOptions.synchronizedFlickingOptions | synchronizedFlickingOptions}. */
|
|
50
76
|
public set synchronizedFlickingOptions(val: SyncOptions["synchronizedFlickingOptions"]) {
|
|
51
77
|
this._synchronizedFlickingOptions = val;
|
|
52
78
|
}
|
|
53
79
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
80
|
+
/**
|
|
81
|
+
* @param options - Options for the Sync instance
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* flicking.addPlugins(new Sync({
|
|
85
|
+
* type: "camera",
|
|
86
|
+
* synchronizedFlickingOptions: [
|
|
87
|
+
* { flicking: flicking1 },
|
|
88
|
+
* { flicking: flicking2, isClickable: true }
|
|
89
|
+
* ]
|
|
90
|
+
* }));
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
public constructor(options: Partial<SyncOptions> = {}) {
|
|
94
|
+
const { type = SYNC.TYPE.CAMERA, synchronizedFlickingOptions = [] } = options;
|
|
95
|
+
|
|
59
96
|
this._type = type;
|
|
60
97
|
this._synchronizedFlickingOptions = synchronizedFlickingOptions;
|
|
61
98
|
}
|
|
62
99
|
|
|
100
|
+
/** Initialize the plugin and set up synchronization event listeners between Flicking instances.
|
|
101
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
102
|
+
*/
|
|
63
103
|
public init(flicking: Flicking): void {
|
|
64
104
|
const synced = this._synchronizedFlickingOptions;
|
|
65
105
|
|
|
@@ -78,6 +118,7 @@ class Sync implements Plugin {
|
|
|
78
118
|
});
|
|
79
119
|
}
|
|
80
120
|
|
|
121
|
+
/** Destroy the plugin and remove all synchronization event listeners. */
|
|
81
122
|
public destroy(): void {
|
|
82
123
|
const flicking = this._flicking;
|
|
83
124
|
|
|
@@ -90,6 +131,7 @@ class Sync implements Plugin {
|
|
|
90
131
|
this._flicking = null;
|
|
91
132
|
}
|
|
92
133
|
|
|
134
|
+
/** Update the active class state for all synchronized Flicking instances. */
|
|
93
135
|
public update(): void {
|
|
94
136
|
this._synchronizedFlickingOptions.forEach(options => {
|
|
95
137
|
this._updateClass(options, options.flicking.index);
|
|
@@ -184,7 +226,7 @@ class Sync implements Plugin {
|
|
|
184
226
|
};
|
|
185
227
|
|
|
186
228
|
private _onMoveEnd = (e: MoveEndEvent): void => {
|
|
187
|
-
this._disabledIndex.forEach(
|
|
229
|
+
this._disabledIndex.forEach(i => {
|
|
188
230
|
const flicking = this._synchronizedFlickingOptions[i].flicking;
|
|
189
231
|
flicking.enableInput();
|
|
190
232
|
flicking.control.updateInput();
|
|
@@ -226,7 +268,7 @@ class Sync implements Plugin {
|
|
|
226
268
|
if (!activeClass) return;
|
|
227
269
|
|
|
228
270
|
flicking.panels.forEach(panel => {
|
|
229
|
-
if (panel.index === index)
|
|
271
|
+
if (panel.index === index) {
|
|
230
272
|
addClass(panel.element, activeClass);
|
|
231
273
|
} else {
|
|
232
274
|
removeClass(panel.element, activeClass);
|
package/src/index.ts
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @namespace Flicking
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @namespace Flicking.Plugins
|
|
6
|
-
*/
|
|
7
|
-
import Parallax from "./Parallax";
|
|
8
|
-
import Fade from "./Fade";
|
|
9
|
-
import AutoPlay from "./AutoPlay";
|
|
10
1
|
import Arrow from "./Arrow";
|
|
11
|
-
import
|
|
2
|
+
import AutoPlay from "./AutoPlay";
|
|
3
|
+
import Fade from "./Fade";
|
|
4
|
+
import Parallax from "./Parallax";
|
|
12
5
|
import Perspective from "./Perspective";
|
|
6
|
+
import Sync, { SychronizableFlickingOptions, SyncOptions } from "./Sync";
|
|
13
7
|
|
|
14
8
|
export * from "./pagination";
|
|
15
9
|
|
|
16
|
-
export {
|
|
17
|
-
Parallax,
|
|
18
|
-
Fade,
|
|
19
|
-
AutoPlay,
|
|
20
|
-
Arrow,
|
|
21
|
-
Sync,
|
|
22
|
-
Perspective
|
|
23
|
-
};
|
|
10
|
+
export { Parallax, Fade, AutoPlay, Arrow, Sync, Perspective };
|
|
24
11
|
|
|
25
|
-
export type {
|
|
26
|
-
SyncOptions,
|
|
27
|
-
SychronizableFlickingOptions
|
|
28
|
-
};
|
|
12
|
+
export type { SyncOptions, SychronizableFlickingOptions };
|
|
29
13
|
|
|
14
|
+
export type { ArrowOptions } from "./Arrow";
|
|
15
|
+
export type { AutoPlayOptions } from "./AutoPlay";
|
|
30
16
|
export * from "./const";
|
|
17
|
+
export type { PerspectiveOptions } from "./Perspective";
|