@egjs/flicking 4.15.0 → 4.16.0-beta.1
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 +5559 -7791
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +5637 -7699
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +6722 -8893
- 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 -14086
- 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 +1051 -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 -4
- 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 +170 -115
- package/src/renderer/VanillaRenderer.ts +12 -9
- 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
package/package.json
CHANGED
|
@@ -1,163 +1,36 @@
|
|
|
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
|
-
"demo:prebuild-latest": "cpx 'dist/**/*' docs/build/release/latest/dist --clean",
|
|
38
|
-
"demo:deploy": "npm run docs:release && npm run build && npm run demo:prebuild-version && npm run demo:prebuild-latest && gh-pages -d docs/build/ --add --remote upstream",
|
|
39
|
-
"demo:deploy-origin": "npm run docs:release && npm run build && npm run demo:prebuild-version && npm run demo:prebuild-latest && gh-pages -d docs/build/ --add --remote origin",
|
|
40
|
-
"release": "release-helper upstream",
|
|
41
|
-
"changelog": "node ./config/changelog.js",
|
|
42
|
-
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
43
|
-
"packages": "npm run packages:update && npm run packages:build && npm run packages:publish",
|
|
44
|
-
"packages:update": "pvu --update=react-flicking,ngx-flicking/projects/ngx-flicking,vue-flicking,vue3-flicking,svelte-flicking",
|
|
45
|
-
"packages:build": "pvu --build=react-flicking,ngx-flicking,vue-flicking,vue3-flicking,svelte-flicking",
|
|
46
|
-
"packages:publish": "pvu --publish=react-flicking,ngx-flicking/dist/ngx-flicking,vue-flicking,vue3-flicking,svelte-flicking"
|
|
47
|
-
},
|
|
48
|
-
"repository": {
|
|
49
|
-
"type": "git",
|
|
50
|
-
"url": "https://github.com/naver/egjs-flicking"
|
|
51
|
-
},
|
|
52
|
-
"author": {
|
|
53
|
-
"name": "NAVER Corp."
|
|
54
|
-
},
|
|
55
|
-
"homepage": "https://naver.github.io/egjs-flicking/",
|
|
56
|
-
"bugs": {
|
|
57
|
-
"url": "https://github.com/naver/egjs-flicking/issues"
|
|
58
|
-
},
|
|
59
|
-
"license": "MIT",
|
|
60
|
-
"browserslist": [
|
|
61
|
-
"last 2 version",
|
|
62
|
-
"ie 9-11",
|
|
63
|
-
"not op_mini all"
|
|
64
|
-
],
|
|
65
|
-
"keywords": [
|
|
66
|
-
"carousel",
|
|
67
|
-
"flicking",
|
|
68
|
-
"slider",
|
|
69
|
-
"mouse",
|
|
70
|
-
"touch",
|
|
71
|
-
"desktop",
|
|
72
|
-
"mobile",
|
|
73
|
-
"react",
|
|
74
|
-
"vue",
|
|
75
|
-
"angular",
|
|
76
|
-
"preact",
|
|
77
|
-
"gallery",
|
|
78
|
-
"slideshow",
|
|
79
|
-
"swipe",
|
|
80
|
-
"egjs"
|
|
81
|
-
],
|
|
82
|
-
"devDependencies": {
|
|
83
|
-
"@babel/preset-env": "^7.16.0",
|
|
84
|
-
"@daybrush/jsdoc": "^0.3.10",
|
|
85
|
-
"@egjs/flicking-plugins": "^4.2.2",
|
|
86
|
-
"@egjs/release-helper": "0.0.3",
|
|
87
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
88
|
-
"@rollup/plugin-commonjs": "^11.1.0",
|
|
89
|
-
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
90
|
-
"@rollup/plugin-replace": "^2.4.1",
|
|
91
|
-
"@types/fs-extra": "^9.0.11",
|
|
92
|
-
"@types/node": "^14.14.35",
|
|
93
|
-
"@types/resize-observer-browser": "^0.1.6",
|
|
94
|
-
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
|
95
|
-
"@typescript-eslint/eslint-plugin-tslint": "^4.18.0",
|
|
96
|
-
"@typescript-eslint/parser": "^4.18.0",
|
|
97
|
-
"autoprefixer": "^9.8.8",
|
|
98
|
-
"babel-loader": "^8.2.2",
|
|
99
|
-
"babel-preset-env": "^1.7.0",
|
|
100
|
-
"concurrently": "^6.0.0",
|
|
101
|
-
"core-js": "^3.9.1",
|
|
102
|
-
"coveralls": "^3.0.2",
|
|
103
|
-
"cpx": "^1.5.0",
|
|
104
|
-
"egjs-jsdoc-template": "^1.4.4",
|
|
105
|
-
"eslint": "^7.22.0",
|
|
106
|
-
"eslint-plugin-import": "^2.22.1",
|
|
107
|
-
"eslint-plugin-jsdoc": "^30.7.9",
|
|
108
|
-
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
109
|
-
"fs-extra": "^7.0.1",
|
|
110
|
-
"gh-pages": "^2.0.1",
|
|
111
|
-
"hammer-simulator": "0.0.1",
|
|
112
|
-
"html-to-react": "^1.4.5",
|
|
113
|
-
"http-serve": "^1.0.1",
|
|
114
|
-
"husky": "^1.3.1",
|
|
115
|
-
"jsdoc-to-mdx": "^1.1.2",
|
|
116
|
-
"karma-typescript-es6-transform": "^5.5.2",
|
|
117
|
-
"npm-run-all": "^4.1.5",
|
|
118
|
-
"postcss-clean": "^1.2.2",
|
|
119
|
-
"postcss-cli": "^7.1.2",
|
|
120
|
-
"print-coveralls": "^1.2.2",
|
|
121
|
-
"print-sizes": "0.0.3",
|
|
122
|
-
"pvu": "^0.6.1",
|
|
123
|
-
"rollup": "^2.41.5",
|
|
124
|
-
"rollup-plugin-livereload": "^1.3.0",
|
|
125
|
-
"rollup-plugin-postcss": "^3.1.3",
|
|
126
|
-
"rollup-plugin-prototype-minify": "^1.1.0",
|
|
127
|
-
"rollup-plugin-serve": "^1.1.0",
|
|
128
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
129
|
-
"rollup-plugin-typescript2": "^0.36.0",
|
|
130
|
-
"rollup-plugin-visualizer": "^4.2.1",
|
|
131
|
-
"sass": "^1.79.3",
|
|
132
|
-
"sync-exec": "^0.6.2",
|
|
133
|
-
"ts-mock-imports": "^1.3.3",
|
|
134
|
-
"tsconfig-paths-webpack-plugin": "^3.5.1",
|
|
135
|
-
"tslib": "^2.1.0",
|
|
136
|
-
"tslint": "^5.12.1",
|
|
137
|
-
"ttypescript": "^1.5.12",
|
|
138
|
-
"typescript": "^3.9.10",
|
|
139
|
-
"typescript-transform-paths": "^2.2.3"
|
|
140
|
-
},
|
|
141
|
-
"dependencies": {
|
|
142
|
-
"@cfcs/core": "^0.1.0",
|
|
143
|
-
"@egjs/axes": "^3.9.1",
|
|
144
|
-
"@egjs/component": "^3.0.1",
|
|
145
|
-
"@egjs/imready": "^1.3.1",
|
|
146
|
-
"@egjs/list-differ": "^1.0.1"
|
|
147
|
-
},
|
|
148
|
-
"husky": {
|
|
149
|
-
"hooks": {
|
|
150
|
-
"commit-msg": "node config/validate-commit-msg.js",
|
|
151
|
-
"pre-push": "npm run lint"
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
"watch": {
|
|
155
|
-
"jsdoc": {
|
|
156
|
-
"patterns": [
|
|
157
|
-
"src"
|
|
158
|
-
],
|
|
159
|
-
"extensions": "ts",
|
|
160
|
-
"runOnChangeOnly": false
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
2
|
+
"name": "@egjs/flicking",
|
|
3
|
+
"version": "4.16.0-beta.1",
|
|
4
|
+
"description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.",
|
|
5
|
+
"main": "dist/flicking.cjs.js",
|
|
6
|
+
"module": "dist/flicking.esm.js",
|
|
7
|
+
"es2015": "dist/flicking.esm.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@cfcs/core": "^0.1.0",
|
|
11
|
+
"@egjs/axes": "^3.9.1",
|
|
12
|
+
"@egjs/component": "^3.0.2",
|
|
13
|
+
"@egjs/imready": "^1.1.1",
|
|
14
|
+
"@egjs/list-differ": "^1.0.1"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"**/*.css",
|
|
18
|
+
"**/*.sass"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite --config vite.dev.config.ts",
|
|
22
|
+
"dev:preview": "vite --config vite.dev.config.ts --mode production",
|
|
23
|
+
"build": "run-s build:bundle build:css build:declaration printsizes",
|
|
24
|
+
"build:bundle": "rm -rf ./dist && run-s build:bundle:common build:bundle:umd",
|
|
25
|
+
"build:bundle:common": "vite build",
|
|
26
|
+
"build:bundle:umd": "concurrently \"VITE_BUILD_FORMAT=umd vite build\" \"VITE_BUILD_FORMAT=umd VITE_MINIFY=true vite build\" \"VITE_BUILD_FORMAT=umd VITE_RESOLVE=true vite build\" \"VITE_BUILD_FORMAT=umd VITE_RESOLVE=true VITE_MINIFY=true vite build\"",
|
|
27
|
+
"build:css": "run-s build:css-clear build:sass build:css-prefix build:css-min",
|
|
28
|
+
"build:css-clear": "rm -rf ./dist/*.css",
|
|
29
|
+
"build:sass": "sass sass/:dist/ --style=expanded --no-source-map && sass sass/flicking.sass dist/flicking.min.css --style=compressed --no-source-map && sass sass/flicking-inline.sass dist/flicking-inline.min.css --style=compressed --no-source-map",
|
|
30
|
+
"build:css-prefix": "postcss dist/*.css --replace --use autoprefixer --no-map",
|
|
31
|
+
"build:css-min": "postcss dist/*.css --ext .min.css --use postcss-clean -d dist/ --no-map",
|
|
32
|
+
"build:declaration": "tsc -p tsconfig.declaration.json",
|
|
33
|
+
"css": "postcss css/*.css --use autoprefixer postcss-clean -d dist/ -m",
|
|
34
|
+
"printsizes": "print-sizes ./dist --exclude=\\.map"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/CrossFlicking.ts
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ComponentEvent } from "@egjs/component";
|
|
6
6
|
import { EventKey } from "@egjs/component/declaration/types";
|
|
7
|
-
|
|
8
|
-
import
|
|
7
|
+
import { CLASS, MOVE_DIRECTION } from "./constants/values";
|
|
8
|
+
import { EVENTS } from "./event/names";
|
|
9
9
|
import {
|
|
10
10
|
ChangedEvent,
|
|
11
|
+
FlickingEvents,
|
|
11
12
|
HoldEndEvent,
|
|
12
13
|
HoldStartEvent,
|
|
13
14
|
MoveEndEvent,
|
|
@@ -16,9 +17,9 @@ import {
|
|
|
16
17
|
RestoredEvent,
|
|
17
18
|
WillChangeEvent,
|
|
18
19
|
WillRestoreEvent
|
|
19
|
-
} from "./
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
} from "./event/types";
|
|
21
|
+
import Flicking, { FlickingOptions } from "./Flicking";
|
|
22
|
+
import { LiteralUnion, ValueOf } from "./types/internal";
|
|
22
23
|
import { getDataAttributes, includes, toArray } from "./utils";
|
|
23
24
|
|
|
24
25
|
export const SIDE_EVENTS = {
|
|
@@ -69,6 +70,11 @@ export interface CrossFlickingWillChangeEvent extends WillChangeEvent {
|
|
|
69
70
|
sideIndex?: number;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
/**
|
|
74
|
+
* A preset for cross-directional carousel that combines horizontal and vertical Flicking instances
|
|
75
|
+
* @since 4.12.0
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
72
78
|
export class CrossFlicking extends Flicking {
|
|
73
79
|
// Core components
|
|
74
80
|
private _sideFlicking: Flicking[];
|
|
@@ -99,13 +105,21 @@ export class CrossFlicking extends Flicking {
|
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
// Options Getter
|
|
102
|
-
public get sideOptions() {
|
|
108
|
+
public get sideOptions() {
|
|
109
|
+
return this._sideOptions;
|
|
110
|
+
}
|
|
103
111
|
|
|
104
|
-
public get preserveIndex() {
|
|
112
|
+
public get preserveIndex() {
|
|
113
|
+
return this._preserveIndex;
|
|
114
|
+
}
|
|
105
115
|
|
|
106
|
-
public get disableSlideOnHold() {
|
|
116
|
+
public get disableSlideOnHold() {
|
|
117
|
+
return this._disableSlideOnHold;
|
|
118
|
+
}
|
|
107
119
|
|
|
108
|
-
public get disableIndexSync() {
|
|
120
|
+
public get disableIndexSync() {
|
|
121
|
+
return this._disableIndexSync;
|
|
122
|
+
}
|
|
109
123
|
|
|
110
124
|
// Options Setter
|
|
111
125
|
public set sideOptions(val: CrossFlickingOptions["sideOptions"]) {
|
|
@@ -124,17 +138,9 @@ export class CrossFlicking extends Flicking {
|
|
|
124
138
|
this._disableIndexSync = val;
|
|
125
139
|
}
|
|
126
140
|
|
|
127
|
-
public constructor(
|
|
128
|
-
root: HTMLElement | string,
|
|
129
|
-
options: Partial<CrossFlickingOptions>
|
|
130
|
-
) {
|
|
141
|
+
public constructor(root: HTMLElement | string, options: Partial<CrossFlickingOptions>) {
|
|
131
142
|
super(root, options);
|
|
132
|
-
const {
|
|
133
|
-
sideOptions = {},
|
|
134
|
-
preserveIndex = true,
|
|
135
|
-
disableSlideOnHold = true,
|
|
136
|
-
disableIndexSync = false
|
|
137
|
-
} = options;
|
|
143
|
+
const { sideOptions = {}, preserveIndex = true, disableSlideOnHold = true, disableIndexSync = false } = options;
|
|
138
144
|
|
|
139
145
|
// Internal states
|
|
140
146
|
this._moveDirection = null;
|
|
@@ -157,7 +163,7 @@ export class CrossFlicking extends Flicking {
|
|
|
157
163
|
}
|
|
158
164
|
|
|
159
165
|
public destroy(): void {
|
|
160
|
-
this._sideFlicking.forEach(
|
|
166
|
+
this._sideFlicking.forEach(flicking => {
|
|
161
167
|
flicking.destroy();
|
|
162
168
|
});
|
|
163
169
|
super.destroy();
|
|
@@ -167,7 +173,7 @@ export class CrossFlicking extends Flicking {
|
|
|
167
173
|
this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
|
|
168
174
|
this.on(EVENTS.MOVE, this._onHorizontalMove);
|
|
169
175
|
this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
|
|
170
|
-
[EVENTS.CHANGED, EVENTS.WILL_CHANGE].forEach(
|
|
176
|
+
[EVENTS.CHANGED, EVENTS.WILL_CHANGE].forEach(event => {
|
|
171
177
|
this.on(event, this._addSideIndex);
|
|
172
178
|
});
|
|
173
179
|
|
|
@@ -178,7 +184,7 @@ export class CrossFlicking extends Flicking {
|
|
|
178
184
|
flicking.on(EVENTS.CHANGED, this._onSideChanged);
|
|
179
185
|
|
|
180
186
|
Object.keys(SIDE_EVENTS).forEach((name: EventKey<FlickingEvents>) => {
|
|
181
|
-
flicking.on(EVENTS[name],
|
|
187
|
+
flicking.on(EVENTS[name], event => {
|
|
182
188
|
this.trigger(
|
|
183
189
|
new ComponentEvent(SIDE_EVENTS[name], {
|
|
184
190
|
mainIndex,
|
|
@@ -194,10 +200,7 @@ export class CrossFlicking extends Flicking {
|
|
|
194
200
|
const viewportEl = this.element;
|
|
195
201
|
const cameraEl = this.camera.element;
|
|
196
202
|
const panels = toArray(cameraEl.children) as HTMLElement[];
|
|
197
|
-
const isCrossStructure = getDataAttributes(
|
|
198
|
-
viewportEl,
|
|
199
|
-
"data-cross-"
|
|
200
|
-
).structure;
|
|
203
|
+
const isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
|
|
201
204
|
let sideState: SideState[] = [];
|
|
202
205
|
|
|
203
206
|
if (!isCrossStructure) {
|
|
@@ -229,16 +232,14 @@ export class CrossFlicking extends Flicking {
|
|
|
229
232
|
sideState.forEach((state, i) => {
|
|
230
233
|
const panel = this.camera.children[i];
|
|
231
234
|
sidePanels += state.element.innerHTML;
|
|
232
|
-
Array.from(panel.attributes).forEach((attribute)
|
|
233
|
-
panel.removeAttribute(attribute.name)
|
|
234
|
-
);
|
|
235
|
+
Array.from(panel.attributes).forEach(attribute => panel.removeAttribute(attribute.name));
|
|
235
236
|
});
|
|
236
237
|
|
|
237
238
|
sideCamera.innerHTML = sidePanels;
|
|
238
239
|
|
|
239
240
|
sideState.forEach((_, i) => {
|
|
240
241
|
const panel = this.camera.children[i];
|
|
241
|
-
[CLASS.VIEWPORT, CLASS.VERTICAL].forEach(
|
|
242
|
+
[CLASS.VIEWPORT, CLASS.VERTICAL].forEach(className => {
|
|
242
243
|
if (!panel.classList.contains(className)) {
|
|
243
244
|
panel.classList.add(className);
|
|
244
245
|
}
|
|
@@ -249,13 +250,11 @@ export class CrossFlicking extends Flicking {
|
|
|
249
250
|
this.element.setAttribute("data-cross-structure", "true");
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
private _getGroupFromAttribute(
|
|
253
|
-
panels: HTMLElement[]
|
|
254
|
-
): Record<string, HTMLElement[]> {
|
|
253
|
+
private _getGroupFromAttribute(panels: HTMLElement[]): Record<string, HTMLElement[]> {
|
|
255
254
|
const groupKeys: string[] = [];
|
|
256
255
|
const groupPanels: Record<string, HTMLElement[]> = {};
|
|
257
256
|
|
|
258
|
-
panels.forEach(
|
|
257
|
+
panels.forEach(panel => {
|
|
259
258
|
const groupKey = getDataAttributes(panel, "data-cross-").groupkey;
|
|
260
259
|
if (groupKey && !includes(groupKeys, groupKey)) {
|
|
261
260
|
groupKeys.push(groupKey);
|
|
@@ -268,49 +267,38 @@ export class CrossFlicking extends Flicking {
|
|
|
268
267
|
return groupPanels;
|
|
269
268
|
}
|
|
270
269
|
|
|
271
|
-
private _getSideStateFromGroup(
|
|
272
|
-
groupPanels:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
start,
|
|
289
|
-
end: start + groupPanels[key].length - 1,
|
|
290
|
-
element: element
|
|
291
|
-
}
|
|
292
|
-
];
|
|
293
|
-
},
|
|
294
|
-
[]
|
|
295
|
-
);
|
|
270
|
+
private _getSideStateFromGroup(groupPanels: Record<string, HTMLElement[]>): SideState[] {
|
|
271
|
+
return Object.keys(groupPanels).reduce((state: SideState[], key: string) => {
|
|
272
|
+
const start = state.length ? +state[state.length - 1].end + 1 : 0;
|
|
273
|
+
const element = groupPanels[key].reduce((el: HTMLElement, panel: HTMLElement) => {
|
|
274
|
+
el.innerHTML += panel.outerHTML;
|
|
275
|
+
return el;
|
|
276
|
+
}, document.createElement("div"));
|
|
277
|
+
return [
|
|
278
|
+
...state,
|
|
279
|
+
{
|
|
280
|
+
key,
|
|
281
|
+
start,
|
|
282
|
+
end: start + groupPanels[key].length - 1,
|
|
283
|
+
element: element
|
|
284
|
+
}
|
|
285
|
+
];
|
|
286
|
+
}, []);
|
|
296
287
|
}
|
|
297
288
|
|
|
298
289
|
private _getSideStateFromPanels(panels: HTMLElement[]): SideState[] {
|
|
299
|
-
return panels.reduce(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
},
|
|
312
|
-
[]
|
|
313
|
-
);
|
|
290
|
+
return panels.reduce((state: SideState[], panel: HTMLElement, i: number) => {
|
|
291
|
+
const start = state.length ? +state[state.length - 1].end + 1 : 0;
|
|
292
|
+
return [
|
|
293
|
+
...state,
|
|
294
|
+
{
|
|
295
|
+
key: i.toString(),
|
|
296
|
+
start,
|
|
297
|
+
end: start + panel.children.length - 1,
|
|
298
|
+
element: panel
|
|
299
|
+
}
|
|
300
|
+
];
|
|
301
|
+
}, []);
|
|
314
302
|
}
|
|
315
303
|
|
|
316
304
|
private _getSideStateFromCrossStructure(panels: HTMLElement[]): SideState[] {
|
|
@@ -346,25 +334,18 @@ export class CrossFlicking extends Flicking {
|
|
|
346
334
|
});
|
|
347
335
|
};
|
|
348
336
|
|
|
349
|
-
private _setDraggable = (
|
|
350
|
-
direction: ValueOf<typeof MOVE_DIRECTION>,
|
|
351
|
-
draggable: boolean
|
|
352
|
-
): void => {
|
|
337
|
+
private _setDraggable = (direction: ValueOf<typeof MOVE_DIRECTION>, draggable: boolean): void => {
|
|
353
338
|
if (!this._disableSlideOnHold) {
|
|
354
339
|
return;
|
|
355
340
|
}
|
|
356
341
|
|
|
357
342
|
const dragThreshold = this._originalDragThreshold;
|
|
358
|
-
const threshold = draggable
|
|
359
|
-
? dragThreshold && dragThreshold >= 10
|
|
360
|
-
? dragThreshold
|
|
361
|
-
: 10
|
|
362
|
-
: Infinity;
|
|
343
|
+
const threshold = draggable ? (dragThreshold && dragThreshold >= 10 ? dragThreshold : 10) : Infinity;
|
|
363
344
|
|
|
364
345
|
if ((direction === MOVE_DIRECTION.HORIZONTAL) === this.horizontal) {
|
|
365
346
|
this.dragThreshold = threshold;
|
|
366
347
|
} else if ((direction === MOVE_DIRECTION.VERTICAL) === this.horizontal) {
|
|
367
|
-
this._sideFlicking.forEach(
|
|
348
|
+
this._sideFlicking.forEach(child => {
|
|
368
349
|
child.dragThreshold = threshold;
|
|
369
350
|
});
|
|
370
351
|
}
|
|
@@ -412,10 +393,7 @@ export class CrossFlicking extends Flicking {
|
|
|
412
393
|
const visiblePanels = this.visiblePanels;
|
|
413
394
|
|
|
414
395
|
if (visiblePanels.length > 1) {
|
|
415
|
-
this._nextIndex =
|
|
416
|
-
e.direction === "NEXT"
|
|
417
|
-
? visiblePanels[1].index
|
|
418
|
-
: visiblePanels[0].index;
|
|
396
|
+
this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
|
|
419
397
|
} else {
|
|
420
398
|
this._nextIndex = visiblePanels[0].index;
|
|
421
399
|
}
|
|
@@ -427,10 +405,7 @@ export class CrossFlicking extends Flicking {
|
|
|
427
405
|
requestAnimationFrame(() => this._setPreviousSideIndex());
|
|
428
406
|
|
|
429
407
|
if (e.isTrusted) {
|
|
430
|
-
this._syncToCategory(
|
|
431
|
-
this._sideFlicking[this._nextIndex].index,
|
|
432
|
-
this._nextIndex
|
|
433
|
-
);
|
|
408
|
+
this._syncToCategory(this._sideFlicking[this._nextIndex].index, this._nextIndex);
|
|
434
409
|
}
|
|
435
410
|
};
|
|
436
411
|
|
|
@@ -454,10 +429,7 @@ export class CrossFlicking extends Flicking {
|
|
|
454
429
|
private _onSideChanged = (e: ChangedEvent): void => {
|
|
455
430
|
// If this.visiblePanels.length >= 2, it means that horizontal flicking is being dragged.
|
|
456
431
|
// In this case, syncToCategory in _onHorizontalMoveEnd will fire after moving finishes, so we don't fire it here.
|
|
457
|
-
if (
|
|
458
|
-
this.visiblePanels.length < 2 &&
|
|
459
|
-
this._sideFlicking[this.index] === e.currentTarget
|
|
460
|
-
) {
|
|
432
|
+
if (this.visiblePanels.length < 2 && this._sideFlicking[this.index] === e.currentTarget) {
|
|
461
433
|
this._syncToCategory(e.index, this.index);
|
|
462
434
|
}
|
|
463
435
|
};
|