@egjs/flicking-plugins 4.8.0-beta.1 → 4.8.1-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 +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 +106 -51
- package/declaration/AutoPlay.d.ts +104 -44
- package/declaration/Fade.d.ts +41 -16
- package/declaration/Parallax.d.ts +41 -16
- package/declaration/Perspective.d.ts +71 -28
- package/declaration/Sync.d.ts +93 -37
- package/declaration/const.d.ts +31 -31
- package/declaration/event.d.ts +5 -5
- package/declaration/index.d.ts +13 -10
- package/declaration/pagination/Pagination.d.ts +141 -61
- package/declaration/pagination/index.d.ts +3 -3
- package/declaration/pagination/renderer/BulletRenderer.d.ts +11 -11
- package/declaration/pagination/renderer/FractionRenderer.d.ts +9 -9
- package/declaration/pagination/renderer/Renderer.d.ts +19 -19
- package/declaration/pagination/renderer/ScrollBulletRenderer.d.ts +12 -12
- package/declaration/tsdoc-metadata.json +11 -0
- package/declaration/type.d.ts +9 -9
- package/declaration/utils.d.ts +3 -3
- 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 +1030 -1591
- package/dist/plugins.esm.js.map +1 -1
- package/dist/plugins.js +1047 -1620
- 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 +133 -82
- package/src/AutoPlay.ts +105 -35
- package/src/Fade.ts +31 -11
- package/src/Parallax.ts +31 -11
- package/src/Perspective.ts +69 -22
- package/src/Sync.ts +69 -25
- 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/package.json
CHANGED
|
@@ -1,106 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"license": "MIT",
|
|
52
|
-
"bugs": {
|
|
53
|
-
"url": "https://github.com/naver/egjs-flicking-plugins/issues"
|
|
54
|
-
},
|
|
55
|
-
"browserslist": [
|
|
56
|
-
"last 2 version",
|
|
57
|
-
"ie 9-11",
|
|
58
|
-
"not op_mini all"
|
|
59
|
-
],
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"@egjs/flicking": "^4.11.3"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"@egjs/build-helper": "0.0.5",
|
|
65
|
-
"@egjs/flicking": "^4.11.3",
|
|
66
|
-
"@egjs/release-helper": "0.0.3",
|
|
67
|
-
"@types/chai": "^4.0.10",
|
|
68
|
-
"@types/karma-chai": "^0.1.1",
|
|
69
|
-
"@types/mocha": "^5.2.5",
|
|
70
|
-
"@types/node": "^14.0.27",
|
|
71
|
-
"@types/sinon": "^7.0.3",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
|
73
|
-
"@typescript-eslint/eslint-plugin-tslint": "^4.22.0",
|
|
74
|
-
"@typescript-eslint/parser": "^4.22.0",
|
|
75
|
-
"autoprefixer": "^9.8.6",
|
|
76
|
-
"bulma": "^0.9.2",
|
|
77
|
-
"chai": "^4.2.0",
|
|
78
|
-
"concurrently": "^6.2.0",
|
|
79
|
-
"coveralls": "^3.1.0",
|
|
80
|
-
"cpx": "^1.5.0",
|
|
81
|
-
"eslint": "^7.25.0",
|
|
82
|
-
"eslint-plugin-import": "^2.22.1",
|
|
83
|
-
"eslint-plugin-jsdoc": "^33.0.0",
|
|
84
|
-
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
85
|
-
"gh-pages": "^2.0.1",
|
|
86
|
-
"hammer-simulator": "^0.0.1",
|
|
87
|
-
"http-serve": "^1.0.1",
|
|
88
|
-
"karma": "^3.1.4",
|
|
89
|
-
"karma-chai": "^0.1.0",
|
|
90
|
-
"karma-chrome-launcher": "^2.2.0",
|
|
91
|
-
"karma-mocha": "^1.3.0",
|
|
92
|
-
"karma-mocha-reporter": "^2.2.5",
|
|
93
|
-
"karma-sinon": "^1.0.5",
|
|
94
|
-
"karma-typescript-egjs": "^4.0.0",
|
|
95
|
-
"karma-viewport": "^1.0.4",
|
|
96
|
-
"mocha": "^5.2.0",
|
|
97
|
-
"postcss-clean": "^1.2.2",
|
|
98
|
-
"postcss-js": "^3.0.3",
|
|
99
|
-
"print-coveralls": "^1.2.2",
|
|
100
|
-
"print-sizes": "^0.1.0",
|
|
101
|
-
"sinon": "^7.2.3",
|
|
102
|
-
"tslib": "^2.3.0",
|
|
103
|
-
"tslint": "^5.13.1",
|
|
104
|
-
"typescript": "^4.2.3"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
2
|
+
"name": "@egjs/flicking-plugins",
|
|
3
|
+
"version": "4.8.1-beta.0",
|
|
4
|
+
"description": "Ready-to-use plugins for @egjs/flicking",
|
|
5
|
+
"module": "./dist/plugins.esm.js",
|
|
6
|
+
"main": "./dist/plugins.js",
|
|
7
|
+
"types": "./declaration/index.d.ts",
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"**/*.css"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"flicking",
|
|
13
|
+
"plugins",
|
|
14
|
+
"carousel",
|
|
15
|
+
"slide",
|
|
16
|
+
"swipe",
|
|
17
|
+
"parallax",
|
|
18
|
+
"fade",
|
|
19
|
+
"autoplay",
|
|
20
|
+
"egjs"
|
|
21
|
+
],
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "NAVER Corp."
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/naver/egjs-flicking",
|
|
28
|
+
"directory": "packages/flicking-plugins"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@egjs/flicking": "^4.1.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@egjs/flicking": "~4.16.1-beta.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"dev": "vite --config vite.dev.config.ts",
|
|
39
|
+
"dev:preview": "vite --config vite.dev.config.ts --mode production",
|
|
40
|
+
"start": "vite build --watch",
|
|
41
|
+
"build": "run-s build:bundle build:css build:declaration printsizes",
|
|
42
|
+
"build:bundle": "rm -rf ./dist && concurrently \"vite build\" \"VITE_BUILD_FORMAT=umd vite build\" \"VITE_BUILD_FORMAT=umd-min vite build\"",
|
|
43
|
+
"build:css": "run-s build:css-process build:css-bundle",
|
|
44
|
+
"build:css-process": "node ../../config/build-plugins-css.js",
|
|
45
|
+
"build:css-bundle": "cat dist/arrow.css dist/pagination.css > dist/flicking-plugins.css && postcss dist/flicking-plugins.css --use postcss-clean --no-map --output dist/flicking-plugins.min.css",
|
|
46
|
+
"build:declaration": "tsc -p tsconfig.declaration.json",
|
|
47
|
+
"printsizes": "print-sizes ./dist --exclude=\\.map",
|
|
48
|
+
"lint": "biome check src/"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/Arrow.ts
CHANGED
|
@@ -1,30 +1,53 @@
|
|
|
1
|
-
import Flicking, { EVENTS, FlickingError, Plugin
|
|
2
|
-
|
|
3
|
-
import { BROWSER } from "./event";
|
|
1
|
+
import Flicking, { EVENTS, FlickingError, Plugin } from "@egjs/flicking";
|
|
4
2
|
import { ARROW } from "./const";
|
|
3
|
+
import { BROWSER } from "./event";
|
|
5
4
|
import { addClass, getElement, removeClass } from "./utils";
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Options for the {@link Arrow} plugin
|
|
8
|
+
*/
|
|
9
|
+
export interface ArrowOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The parent element to search for arrow elements. If `null`, the Flicking element is used
|
|
12
|
+
* @defaultValue null
|
|
13
|
+
*/
|
|
8
14
|
parentEl: HTMLElement | null;
|
|
15
|
+
/**
|
|
16
|
+
* CSS selector for the "previous" arrow element
|
|
17
|
+
* @defaultValue ".flicking-arrow-prev"
|
|
18
|
+
*/
|
|
9
19
|
prevElSelector: string;
|
|
20
|
+
/**
|
|
21
|
+
* CSS selector for the "next" arrow element
|
|
22
|
+
* @defaultValue ".flicking-arrow-next"
|
|
23
|
+
*/
|
|
10
24
|
nextElSelector: string;
|
|
25
|
+
/**
|
|
26
|
+
* CSS class added to an arrow element when it is disabled (at the start/end of non-circular Flicking)
|
|
27
|
+
* @defaultValue "flicking-arrow-disabled"
|
|
28
|
+
*/
|
|
11
29
|
disabledClass: string;
|
|
30
|
+
/**
|
|
31
|
+
* Number of panels to move when an arrow is clicked
|
|
32
|
+
* @defaultValue 1
|
|
33
|
+
*/
|
|
12
34
|
moveCount: number;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to move by viewport size instead of panel count
|
|
37
|
+
* @defaultValue false
|
|
38
|
+
*/
|
|
13
39
|
moveByViewportSize: boolean;
|
|
14
|
-
interruptable: boolean;
|
|
15
40
|
}
|
|
16
41
|
|
|
17
42
|
/**
|
|
18
|
-
* A plugin to easily create prev/
|
|
19
|
-
* @
|
|
20
|
-
* @memberof Flicking.Plugins
|
|
43
|
+
* A plugin to easily create prev/next arrow buttons for Flicking
|
|
44
|
+
* @see {@link https://naver.github.io/egjs-flicking/docs/demos/plugins/arrow | Demo: Arrow}
|
|
21
45
|
*/
|
|
22
46
|
class Arrow implements Plugin {
|
|
23
47
|
/* Internal Values */
|
|
24
48
|
private _flicking: Flicking | null = null;
|
|
25
49
|
private _prevEl: HTMLElement;
|
|
26
50
|
private _nextEl: HTMLElement;
|
|
27
|
-
private _nextIndex: number;
|
|
28
51
|
|
|
29
52
|
/* Options */
|
|
30
53
|
private _parentEl: ArrowOptions["parentEl"];
|
|
@@ -33,45 +56,98 @@ class Arrow implements Plugin {
|
|
|
33
56
|
private _disabledClass: ArrowOptions["disabledClass"];
|
|
34
57
|
private _moveCount: ArrowOptions["moveCount"];
|
|
35
58
|
private _moveByViewportSize: ArrowOptions["moveByViewportSize"];
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
public get
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
public
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
public
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
59
|
+
|
|
60
|
+
/** The "previous" arrow HTMLElement
|
|
61
|
+
* @readonly
|
|
62
|
+
*/
|
|
63
|
+
public get prevEl() {
|
|
64
|
+
return this._prevEl;
|
|
65
|
+
}
|
|
66
|
+
/** The "next" arrow HTMLElement
|
|
67
|
+
* @readonly
|
|
68
|
+
*/
|
|
69
|
+
public get nextEl() {
|
|
70
|
+
return this._nextEl;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Current value of the {@link ArrowOptions.parentEl | parentEl} option. */
|
|
74
|
+
public get parentEl() {
|
|
75
|
+
return this._parentEl;
|
|
76
|
+
}
|
|
77
|
+
/** Current value of the {@link ArrowOptions.prevElSelector | prevElSelector} option. */
|
|
78
|
+
public get prevElSelector() {
|
|
79
|
+
return this._prevElSelector;
|
|
80
|
+
}
|
|
81
|
+
/** Current value of the {@link ArrowOptions.nextElSelector | nextElSelector} option. */
|
|
82
|
+
public get nextElSelector() {
|
|
83
|
+
return this._nextElSelector;
|
|
84
|
+
}
|
|
85
|
+
/** Current value of the {@link ArrowOptions.disabledClass | disabledClass} option. */
|
|
86
|
+
public get disabledClass() {
|
|
87
|
+
return this._disabledClass;
|
|
88
|
+
}
|
|
89
|
+
/** Current value of the {@link ArrowOptions.moveCount | moveCount} option. */
|
|
90
|
+
public get moveCount() {
|
|
91
|
+
return this._moveCount;
|
|
92
|
+
}
|
|
93
|
+
/** Current value of the {@link ArrowOptions.moveByViewportSize | moveByViewportSize} option. */
|
|
94
|
+
public get moveByViewportSize() {
|
|
95
|
+
return this._moveByViewportSize;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Sets {@link ArrowOptions.parentEl | parentEl}. */
|
|
99
|
+
public set parentEl(val: ArrowOptions["parentEl"]) {
|
|
100
|
+
this._parentEl = val;
|
|
101
|
+
}
|
|
102
|
+
/** Sets {@link ArrowOptions.prevElSelector | prevElSelector}. */
|
|
103
|
+
public set prevElSelector(val: ArrowOptions["prevElSelector"]) {
|
|
104
|
+
this._prevElSelector = val;
|
|
105
|
+
}
|
|
106
|
+
/** Sets {@link ArrowOptions.nextElSelector | nextElSelector}. */
|
|
107
|
+
public set nextElSelector(val: ArrowOptions["nextElSelector"]) {
|
|
108
|
+
this._nextElSelector = val;
|
|
109
|
+
}
|
|
110
|
+
/** Sets {@link ArrowOptions.disabledClass | disabledClass}. */
|
|
111
|
+
public set disabledClass(val: ArrowOptions["disabledClass"]) {
|
|
112
|
+
this._disabledClass = val;
|
|
113
|
+
}
|
|
114
|
+
/** Sets {@link ArrowOptions.moveCount | moveCount}. */
|
|
115
|
+
public set moveCount(val: ArrowOptions["moveCount"]) {
|
|
116
|
+
this._moveCount = val;
|
|
117
|
+
}
|
|
118
|
+
/** Sets {@link ArrowOptions.moveByViewportSize | moveByViewportSize}. */
|
|
119
|
+
public set moveByViewportSize(val: ArrowOptions["moveByViewportSize"]) {
|
|
120
|
+
this._moveByViewportSize = val;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param options - Options for the Arrow instance
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* flicking.addPlugins(new Arrow({ parentEl: null, prevElSelector: ".flicking-arrow-prev", nextElSelector: ".flicking-arrow-next" }));
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
public constructor(options: Partial<ArrowOptions> = {}) {
|
|
131
|
+
const {
|
|
132
|
+
parentEl = null,
|
|
133
|
+
prevElSelector = ARROW.PREV_SELECTOR,
|
|
134
|
+
nextElSelector = ARROW.NEXT_SELECTOR,
|
|
135
|
+
disabledClass = ARROW.DISABLED_CLASS,
|
|
136
|
+
moveCount = 1,
|
|
137
|
+
moveByViewportSize = false
|
|
138
|
+
} = options;
|
|
139
|
+
|
|
66
140
|
this._parentEl = parentEl;
|
|
67
141
|
this._prevElSelector = prevElSelector;
|
|
68
142
|
this._nextElSelector = nextElSelector;
|
|
69
143
|
this._disabledClass = disabledClass;
|
|
70
144
|
this._moveCount = moveCount;
|
|
71
145
|
this._moveByViewportSize = moveByViewportSize;
|
|
72
|
-
this._interruptable = interruptable;
|
|
73
146
|
}
|
|
74
147
|
|
|
148
|
+
/** Initialize the plugin and attach arrow event listeners to the Flicking instance.
|
|
149
|
+
* @param flicking - The Flicking instance to attach this plugin to
|
|
150
|
+
*/
|
|
75
151
|
public init(flicking: Flicking): void {
|
|
76
152
|
if (this._flicking) {
|
|
77
153
|
this.destroy();
|
|
@@ -80,7 +156,6 @@ class Arrow implements Plugin {
|
|
|
80
156
|
this._flicking = flicking;
|
|
81
157
|
|
|
82
158
|
flicking.on(EVENTS.MOVE, this._onAnimation);
|
|
83
|
-
flicking.on(EVENTS.WILL_CHANGE, this._onWillChange);
|
|
84
159
|
|
|
85
160
|
const parentEl = this._parentEl ? this._parentEl : flicking.element;
|
|
86
161
|
const prevEl = getElement(this._prevElSelector, parentEl, "Arrow");
|
|
@@ -100,6 +175,7 @@ class Arrow implements Plugin {
|
|
|
100
175
|
this.update();
|
|
101
176
|
}
|
|
102
177
|
|
|
178
|
+
/** Destroy the plugin and remove all arrow event listeners. */
|
|
103
179
|
public destroy(): void {
|
|
104
180
|
const flicking = this._flicking;
|
|
105
181
|
|
|
@@ -108,7 +184,6 @@ class Arrow implements Plugin {
|
|
|
108
184
|
}
|
|
109
185
|
|
|
110
186
|
flicking.off(EVENTS.MOVE, this._onAnimation);
|
|
111
|
-
flicking.off(EVENTS.WILL_CHANGE, this._onWillChange);
|
|
112
187
|
|
|
113
188
|
const prevEl = this._prevEl;
|
|
114
189
|
const nextEl = this._nextEl;
|
|
@@ -123,6 +198,7 @@ class Arrow implements Plugin {
|
|
|
123
198
|
this._flicking = null;
|
|
124
199
|
}
|
|
125
200
|
|
|
201
|
+
/** Update the arrow disabled/enabled state based on the current camera position. */
|
|
126
202
|
public update(): void {
|
|
127
203
|
this._updateClass(this._flicking!.camera.position);
|
|
128
204
|
}
|
|
@@ -133,76 +209,59 @@ class Arrow implements Plugin {
|
|
|
133
209
|
|
|
134
210
|
private _onPrevClick = () => {
|
|
135
211
|
const flicking = this._flicking!;
|
|
136
|
-
const index = flicking.animating ? this._nextIndex : flicking.index;
|
|
137
|
-
const currentPanel = flicking.animating ? flicking.panels[this._nextIndex] : flicking.currentPanel;
|
|
138
212
|
const camera = flicking.camera;
|
|
139
213
|
const anchorPoints = camera.anchorPoints;
|
|
140
214
|
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
if (flicking.animating) {
|
|
144
|
-
flicking.stopAnimation();
|
|
145
|
-
}
|
|
215
|
+
if (flicking.animating || anchorPoints.length <= 0) return;
|
|
146
216
|
|
|
147
217
|
const firstAnchor = anchorPoints[0];
|
|
148
218
|
const moveCount = this._moveCount;
|
|
149
219
|
|
|
150
220
|
if (this._moveByViewportSize) {
|
|
151
|
-
flicking.control.moveToPosition(camera.position - camera.size, flicking.duration)
|
|
152
|
-
.catch(this._onCatch);
|
|
221
|
+
flicking.control.moveToPosition(camera.position - camera.size, flicking.duration).catch(this._onCatch);
|
|
153
222
|
} else {
|
|
154
223
|
if (flicking.circularEnabled) {
|
|
155
|
-
let targetPanel = currentPanel;
|
|
224
|
+
let targetPanel = flicking.currentPanel;
|
|
156
225
|
|
|
157
226
|
for (let i = 0; i < moveCount; i++) {
|
|
158
227
|
targetPanel = targetPanel.prev()!;
|
|
159
228
|
}
|
|
160
229
|
|
|
161
230
|
targetPanel.focus().catch(this._onCatch);
|
|
162
|
-
} else if (index > firstAnchor.panel.index) {
|
|
163
|
-
flicking.moveTo(Math.max(index - moveCount, firstAnchor.panel.index))
|
|
164
|
-
.catch(this._onCatch);
|
|
231
|
+
} else if (flicking.index > firstAnchor.panel.index) {
|
|
232
|
+
flicking.moveTo(Math.max(flicking.index - moveCount, firstAnchor.panel.index)).catch(this._onCatch);
|
|
165
233
|
} else if (camera.position > camera.range.min) {
|
|
166
|
-
flicking.moveTo(index)
|
|
167
|
-
.catch(this._onCatch);
|
|
234
|
+
flicking.moveTo(flicking.index).catch(this._onCatch);
|
|
168
235
|
}
|
|
169
236
|
}
|
|
170
237
|
};
|
|
171
238
|
|
|
172
239
|
private _onNextClick = () => {
|
|
173
240
|
const flicking = this._flicking!;
|
|
174
|
-
|
|
175
|
-
const currentPanel = flicking.animating ? flicking.panels[this._nextIndex] : flicking.currentPanel;
|
|
241
|
+
|
|
176
242
|
const camera = flicking.camera;
|
|
177
243
|
const anchorPoints = camera.anchorPoints;
|
|
178
244
|
|
|
179
|
-
if (
|
|
180
|
-
|
|
181
|
-
if (flicking.animating) {
|
|
182
|
-
flicking.stopAnimation();
|
|
183
|
-
}
|
|
245
|
+
if (flicking.animating || anchorPoints.length <= 0) return;
|
|
184
246
|
|
|
185
247
|
const lastAnchor = anchorPoints[anchorPoints.length - 1];
|
|
186
248
|
const moveCount = this._moveCount;
|
|
187
249
|
|
|
188
250
|
if (this._moveByViewportSize) {
|
|
189
|
-
flicking.control.moveToPosition(camera.position + camera.size, flicking.duration)
|
|
190
|
-
.catch(this._onCatch);
|
|
251
|
+
flicking.control.moveToPosition(camera.position + camera.size, flicking.duration).catch(this._onCatch);
|
|
191
252
|
} else {
|
|
192
253
|
if (flicking.circularEnabled) {
|
|
193
|
-
let targetPanel = currentPanel;
|
|
254
|
+
let targetPanel = flicking.currentPanel;
|
|
194
255
|
|
|
195
256
|
for (let i = 0; i < moveCount; i++) {
|
|
196
257
|
targetPanel = targetPanel.next()!;
|
|
197
258
|
}
|
|
198
259
|
|
|
199
260
|
targetPanel.focus().catch(this._onCatch);
|
|
200
|
-
} else if (index < lastAnchor.panel.index) {
|
|
201
|
-
flicking.moveTo(Math.min(index + moveCount, lastAnchor.panel.index))
|
|
202
|
-
.catch(this._onCatch);
|
|
261
|
+
} else if (flicking.index < lastAnchor.panel.index) {
|
|
262
|
+
flicking.moveTo(Math.min(flicking.index + moveCount, lastAnchor.panel.index)).catch(this._onCatch);
|
|
203
263
|
} else if (camera.position > camera.range.min) {
|
|
204
|
-
flicking.moveTo(index)
|
|
205
|
-
.catch(this._onCatch);
|
|
264
|
+
flicking.moveTo(flicking.index).catch(this._onCatch);
|
|
206
265
|
}
|
|
207
266
|
}
|
|
208
267
|
};
|
|
@@ -219,10 +278,6 @@ class Arrow implements Plugin {
|
|
|
219
278
|
}
|
|
220
279
|
};
|
|
221
280
|
|
|
222
|
-
private _onWillChange = (e: WillChangeEvent) => {
|
|
223
|
-
this._nextIndex = e.index;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
281
|
private _updateClass(pos: number) {
|
|
227
282
|
const flicking = this._flicking!;
|
|
228
283
|
const disabledClass = this._disabledClass;
|
|
@@ -230,12 +285,8 @@ class Arrow implements Plugin {
|
|
|
230
285
|
const nextEl = this._nextEl;
|
|
231
286
|
const cameraRange = flicking.camera.range;
|
|
232
287
|
|
|
233
|
-
const stopAtPrevEdge = flicking.circularEnabled
|
|
234
|
-
|
|
235
|
-
: pos <= cameraRange.min;
|
|
236
|
-
const stopAtNextEdge = flicking.circularEnabled
|
|
237
|
-
? false
|
|
238
|
-
: pos >= cameraRange.max;
|
|
288
|
+
const stopAtPrevEdge = flicking.circularEnabled ? false : pos <= cameraRange.min;
|
|
289
|
+
const stopAtNextEdge = flicking.circularEnabled ? false : pos >= cameraRange.max;
|
|
239
290
|
|
|
240
291
|
if (stopAtPrevEdge) {
|
|
241
292
|
addClass(prevEl, disabledClass);
|