aptechka 0.1.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/.prettierignore +16 -0
- package/.prettierrc +9 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +11 -0
- package/.vscode/settings.json +18 -0
- package/README.md +0 -0
- package/index.html +32 -0
- package/package.json +272 -0
- package/public/vite.svg +1 -0
- package/src/packages/animation/Animated.ts +189 -0
- package/src/packages/animation/Damped.ts +39 -0
- package/src/packages/animation/Tweened.ts +51 -0
- package/src/packages/animation/index.ts +10 -0
- package/src/packages/attribute/index.ts +59 -0
- package/src/packages/canvas-2d/index.ts +137 -0
- package/src/packages/controls/Controls.ts +15 -0
- package/src/packages/controls/KeyboardControls.ts +63 -0
- package/src/packages/controls/LinearControls.ts +27 -0
- package/src/packages/controls/User.ts +20 -0
- package/src/packages/controls/WheelControls.ts +92 -0
- package/src/packages/controls/index.ts +5 -0
- package/src/packages/css-unit-parser/index.ts +32 -0
- package/src/packages/custom-element/index.ts +19 -0
- package/src/packages/device/Device.ts +113 -0
- package/src/packages/device/Viewport.ts +67 -0
- package/src/packages/device/index.ts +2 -0
- package/src/packages/element-constructor/ElementConstructor.ts +577 -0
- package/src/packages/element-constructor/htmlTags.ts +679 -0
- package/src/packages/element-constructor/index.ts +4 -0
- package/src/packages/element-constructor/specialObjects.ts +8 -0
- package/src/packages/element-constructor/svgTags.ts +588 -0
- package/src/packages/en3/attachments/En3SourceManager.ts +116 -0
- package/src/packages/en3/core/en3.ts +306 -0
- package/src/packages/en3/index.ts +52 -0
- package/src/packages/en3/instances/en3LazyLoader.ts +22 -0
- package/src/packages/en3/libs/MeshoptDecoder.js +138 -0
- package/src/packages/en3/loaders/en3GLTFLoader.ts +54 -0
- package/src/packages/en3/loaders/en3TextureLoader.ts +3 -0
- package/src/packages/en3/objects/En3Clip.ts +53 -0
- package/src/packages/en3/objects/En3ClipHelpers.ts +12 -0
- package/src/packages/en3/objects/En3GLTF.ts +35 -0
- package/src/packages/en3/objects/En3Image.ts +18 -0
- package/src/packages/en3/objects/En3ImageLike.ts +101 -0
- package/src/packages/en3/objects/En3SourceConsumer.ts +5 -0
- package/src/packages/en3/objects/En3Video.ts +88 -0
- package/src/packages/en3/test/En3HTML.ts +55 -0
- package/src/packages/en3/test/En3ModifiedMaterial.ts +221 -0
- package/src/packages/en3/test/En3Raycaster.ts +187 -0
- package/src/packages/en3/utils/coverTexture.ts +29 -0
- package/src/packages/en3/utils/dispose.ts +27 -0
- package/src/packages/en3/utils/traverseMaterials.ts +10 -0
- package/src/packages/en3/utils/traverseMeshes.ts +9 -0
- package/src/packages/image/index.ts +19 -0
- package/src/packages/intersector/index.ts +83 -0
- package/src/packages/ladder/index.ts +112 -0
- package/src/packages/layout-box/index.ts +417 -0
- package/src/packages/loading/index.ts +131 -0
- package/src/packages/measurer/CumulativeOffsetLeft.ts +8 -0
- package/src/packages/measurer/CumulativeOffsetTop.ts +8 -0
- package/src/packages/measurer/Meaurer.ts +38 -0
- package/src/packages/measurer/index.ts +3 -0
- package/src/packages/media/index.ts +38 -0
- package/src/packages/morph/Link.ts +32 -0
- package/src/packages/morph/Morph.ts +246 -0
- package/src/packages/morph/index.ts +10 -0
- package/src/packages/notifier/index.ts +41 -0
- package/src/packages/order/index.ts +14 -0
- package/src/packages/resizer/index.ts +55 -0
- package/src/packages/router/Link.ts +33 -0
- package/src/packages/router/Route.ts +152 -0
- package/src/packages/router/RouteElement.ts +34 -0
- package/src/packages/router/Router.ts +190 -0
- package/src/packages/router/index.ts +13 -0
- package/src/packages/scroll/ScrollElement.ts +618 -0
- package/src/packages/scroll/ScrollUserElement.ts +21 -0
- package/src/packages/scroll/ScrollbarElement.ts +170 -0
- package/src/packages/scroll/index.ts +2 -0
- package/src/packages/scroll-entries/index.ts +74 -0
- package/src/packages/source/SourceClass.ts +77 -0
- package/src/packages/source/SourceElement.ts +177 -0
- package/src/packages/source/SourceManager.ts +61 -0
- package/src/packages/source/SourceSet.ts +52 -0
- package/src/packages/source/index.ts +8 -0
- package/src/packages/store/Composed.ts +33 -0
- package/src/packages/store/Derived.ts +24 -0
- package/src/packages/store/DerivedArray.ts +36 -0
- package/src/packages/store/Resource.ts +38 -0
- package/src/packages/store/Store.ts +144 -0
- package/src/packages/store/StoreRegistry.ts +105 -0
- package/src/packages/store/index.ts +23 -0
- package/src/packages/ticker/index.ts +173 -0
- package/src/packages/utils/array.ts +3 -0
- package/src/packages/utils/attributes.ts +19 -0
- package/src/packages/utils/browser.ts +2 -0
- package/src/packages/utils/canvas.ts +46 -0
- package/src/packages/utils/collisions.ts +12 -0
- package/src/packages/utils/coordinates.ts +40 -0
- package/src/packages/utils/decoding.ts +11 -0
- package/src/packages/utils/dev.ts +5 -0
- package/src/packages/utils/dom.ts +48 -0
- package/src/packages/utils/easings.ts +69 -0
- package/src/packages/utils/file.ts +17 -0
- package/src/packages/utils/function.ts +29 -0
- package/src/packages/utils/index.ts +61 -0
- package/src/packages/utils/layout.ts +22 -0
- package/src/packages/utils/math.ts +74 -0
- package/src/packages/utils/number.ts +26 -0
- package/src/packages/utils/object.ts +108 -0
- package/src/packages/utils/string.ts +49 -0
- package/src/packages/utils/ts-shape.ts +25 -0
- package/src/packages/utils/ts-utility.ts +47 -0
- package/src/packages/video/index.ts +39 -0
- package/src/playground/index.ts +0 -0
- package/tsconfig.json +31 -0
- package/vite.config.ts +65 -0
package/.prettierignore
ADDED
package/.prettierrc
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"[typescript]": {
|
|
3
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
4
|
+
},
|
|
5
|
+
"[javascript]": {
|
|
6
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
7
|
+
},
|
|
8
|
+
"[json]": {
|
|
9
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
10
|
+
},
|
|
11
|
+
"[typescriptreact]": {
|
|
12
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
13
|
+
},
|
|
14
|
+
"[html]": {
|
|
15
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
16
|
+
},
|
|
17
|
+
"typescript.tsdk": "node_modules/typescript/lib"
|
|
18
|
+
}
|
package/README.md
ADDED
|
File without changes
|
package/index.html
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta
|
|
6
|
+
name="viewport"
|
|
7
|
+
content="width=device-width, initial-scale=1.0"
|
|
8
|
+
/>
|
|
9
|
+
<title>🍓</title>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
* {
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 0;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
html,
|
|
19
|
+
body {
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
<body>
|
|
27
|
+
<script
|
|
28
|
+
type="module"
|
|
29
|
+
src="/src/playground/index.ts"
|
|
30
|
+
></script>
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aptechka",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/denisavitski/aptechka.git"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://github.com/denisavitski/aptechka#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/denisavitski/aptechka/issues"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"images": [
|
|
17
|
+
"dist/"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
"./animation": {
|
|
22
|
+
"require": "./dist/animation/index.cjs",
|
|
23
|
+
"default": "./dist/animation/index.js",
|
|
24
|
+
"types": "./dist/animation/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./attribute": {
|
|
27
|
+
"require": "./dist/attribute/index.cjs",
|
|
28
|
+
"default": "./dist/attribute/index.js",
|
|
29
|
+
"types": "./dist/attribute/index.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./canvas-2d": {
|
|
32
|
+
"require": "./dist/canvas-2d/index.cjs",
|
|
33
|
+
"default": "./dist/canvas-2d/index.js",
|
|
34
|
+
"types": "./dist/canvas-2d/index.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./controls": {
|
|
37
|
+
"require": "./dist/controls/index.cjs",
|
|
38
|
+
"default": "./dist/controls/index.js",
|
|
39
|
+
"types": "./dist/controls/index.d.ts"
|
|
40
|
+
},
|
|
41
|
+
"./css-unit-parser": {
|
|
42
|
+
"require": "./dist/css-unit-parser/index.cjs",
|
|
43
|
+
"default": "./dist/css-unit-parser/index.js",
|
|
44
|
+
"types": "./dist/css-unit-parser/index.d.ts"
|
|
45
|
+
},
|
|
46
|
+
"./custom-element": {
|
|
47
|
+
"require": "./dist/custom-element/index.cjs",
|
|
48
|
+
"default": "./dist/custom-element/index.js",
|
|
49
|
+
"types": "./dist/custom-element/index.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./device": {
|
|
52
|
+
"require": "./dist/device/index.cjs",
|
|
53
|
+
"default": "./dist/device/index.js",
|
|
54
|
+
"types": "./dist/device/index.d.ts"
|
|
55
|
+
},
|
|
56
|
+
"./element-constructor": {
|
|
57
|
+
"require": "./dist/element-constructor/index.cjs",
|
|
58
|
+
"default": "./dist/element-constructor/index.js",
|
|
59
|
+
"types": "./dist/element-constructor/index.d.ts"
|
|
60
|
+
},
|
|
61
|
+
"./en3": {
|
|
62
|
+
"require": "./dist/en3/index.cjs",
|
|
63
|
+
"default": "./dist/en3/index.js",
|
|
64
|
+
"types": "./dist/en3/index.d.ts"
|
|
65
|
+
},
|
|
66
|
+
"./image": {
|
|
67
|
+
"require": "./dist/image/index.cjs",
|
|
68
|
+
"default": "./dist/image/index.js",
|
|
69
|
+
"types": "./dist/image/index.d.ts"
|
|
70
|
+
},
|
|
71
|
+
"./intersector": {
|
|
72
|
+
"require": "./dist/intersector/index.cjs",
|
|
73
|
+
"default": "./dist/intersector/index.js",
|
|
74
|
+
"types": "./dist/intersector/index.d.ts"
|
|
75
|
+
},
|
|
76
|
+
"./ladder": {
|
|
77
|
+
"require": "./dist/ladder/index.cjs",
|
|
78
|
+
"default": "./dist/ladder/index.js",
|
|
79
|
+
"types": "./dist/ladder/index.d.ts"
|
|
80
|
+
},
|
|
81
|
+
"./layout-box": {
|
|
82
|
+
"require": "./dist/layout-box/index.cjs",
|
|
83
|
+
"default": "./dist/layout-box/index.js",
|
|
84
|
+
"types": "./dist/layout-box/index.d.ts"
|
|
85
|
+
},
|
|
86
|
+
"./loading": {
|
|
87
|
+
"require": "./dist/loading/index.cjs",
|
|
88
|
+
"default": "./dist/loading/index.js",
|
|
89
|
+
"types": "./dist/loading/index.d.ts"
|
|
90
|
+
},
|
|
91
|
+
"./measurer": {
|
|
92
|
+
"require": "./dist/measurer/index.cjs",
|
|
93
|
+
"default": "./dist/measurer/index.js",
|
|
94
|
+
"types": "./dist/measurer/index.d.ts"
|
|
95
|
+
},
|
|
96
|
+
"./media": {
|
|
97
|
+
"require": "./dist/media/index.cjs",
|
|
98
|
+
"default": "./dist/media/index.js",
|
|
99
|
+
"types": "./dist/media/index.d.ts"
|
|
100
|
+
},
|
|
101
|
+
"./morph": {
|
|
102
|
+
"require": "./dist/morph/index.cjs",
|
|
103
|
+
"default": "./dist/morph/index.js",
|
|
104
|
+
"types": "./dist/morph/index.d.ts"
|
|
105
|
+
},
|
|
106
|
+
"./notifier": {
|
|
107
|
+
"require": "./dist/notifier/index.cjs",
|
|
108
|
+
"default": "./dist/notifier/index.js",
|
|
109
|
+
"types": "./dist/notifier/index.d.ts"
|
|
110
|
+
},
|
|
111
|
+
"./order": {
|
|
112
|
+
"require": "./dist/order/index.cjs",
|
|
113
|
+
"default": "./dist/order/index.js",
|
|
114
|
+
"types": "./dist/order/index.d.ts"
|
|
115
|
+
},
|
|
116
|
+
"./resizer": {
|
|
117
|
+
"require": "./dist/resizer/index.cjs",
|
|
118
|
+
"default": "./dist/resizer/index.js",
|
|
119
|
+
"types": "./dist/resizer/index.d.ts"
|
|
120
|
+
},
|
|
121
|
+
"./router": {
|
|
122
|
+
"require": "./dist/router/index.cjs",
|
|
123
|
+
"default": "./dist/router/index.js",
|
|
124
|
+
"types": "./dist/router/index.d.ts"
|
|
125
|
+
},
|
|
126
|
+
"./scroll": {
|
|
127
|
+
"require": "./dist/scroll/index.cjs",
|
|
128
|
+
"default": "./dist/scroll/index.js",
|
|
129
|
+
"types": "./dist/scroll/index.d.ts"
|
|
130
|
+
},
|
|
131
|
+
"./scroll-entries": {
|
|
132
|
+
"require": "./dist/scroll-entries/index.cjs",
|
|
133
|
+
"default": "./dist/scroll-entries/index.js",
|
|
134
|
+
"types": "./dist/scroll-entries/index.d.ts"
|
|
135
|
+
},
|
|
136
|
+
"./source": {
|
|
137
|
+
"require": "./dist/source/index.cjs",
|
|
138
|
+
"default": "./dist/source/index.js",
|
|
139
|
+
"types": "./dist/source/index.d.ts"
|
|
140
|
+
},
|
|
141
|
+
"./store": {
|
|
142
|
+
"require": "./dist/store/index.cjs",
|
|
143
|
+
"default": "./dist/store/index.js",
|
|
144
|
+
"types": "./dist/store/index.d.ts"
|
|
145
|
+
},
|
|
146
|
+
"./ticker": {
|
|
147
|
+
"require": "./dist/ticker/index.cjs",
|
|
148
|
+
"default": "./dist/ticker/index.js",
|
|
149
|
+
"types": "./dist/ticker/index.d.ts"
|
|
150
|
+
},
|
|
151
|
+
"./utils": {
|
|
152
|
+
"require": "./dist/utils/index.cjs",
|
|
153
|
+
"default": "./dist/utils/index.js",
|
|
154
|
+
"types": "./dist/utils/index.d.ts"
|
|
155
|
+
},
|
|
156
|
+
"./video": {
|
|
157
|
+
"require": "./dist/video/index.cjs",
|
|
158
|
+
"default": "./dist/video/index.js",
|
|
159
|
+
"types": "./dist/video/index.d.ts"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"typesVersions": {
|
|
163
|
+
"*": {
|
|
164
|
+
"animation": [
|
|
165
|
+
"dist/animation/index.d.ts"
|
|
166
|
+
],
|
|
167
|
+
"attribute": [
|
|
168
|
+
"dist/attribute/index.d.ts"
|
|
169
|
+
],
|
|
170
|
+
"canvas-2d": [
|
|
171
|
+
"dist/canvas-2d/index.d.ts"
|
|
172
|
+
],
|
|
173
|
+
"controls": [
|
|
174
|
+
"dist/controls/index.d.ts"
|
|
175
|
+
],
|
|
176
|
+
"css-unit-parser": [
|
|
177
|
+
"dist/css-unit-parser/index.d.ts"
|
|
178
|
+
],
|
|
179
|
+
"custom-element": [
|
|
180
|
+
"dist/custom-element/index.d.ts"
|
|
181
|
+
],
|
|
182
|
+
"device": [
|
|
183
|
+
"dist/device/index.d.ts"
|
|
184
|
+
],
|
|
185
|
+
"element-constructor": [
|
|
186
|
+
"dist/element-constructor/index.d.ts"
|
|
187
|
+
],
|
|
188
|
+
"en3": [
|
|
189
|
+
"dist/en3/index.d.ts"
|
|
190
|
+
],
|
|
191
|
+
"image": [
|
|
192
|
+
"dist/image/index.d.ts"
|
|
193
|
+
],
|
|
194
|
+
"intersector": [
|
|
195
|
+
"dist/intersector/index.d.ts"
|
|
196
|
+
],
|
|
197
|
+
"ladder": [
|
|
198
|
+
"dist/ladder/index.d.ts"
|
|
199
|
+
],
|
|
200
|
+
"layout-box": [
|
|
201
|
+
"dist/layout-box/index.d.ts"
|
|
202
|
+
],
|
|
203
|
+
"loading": [
|
|
204
|
+
"dist/loading/index.d.ts"
|
|
205
|
+
],
|
|
206
|
+
"measurer": [
|
|
207
|
+
"dist/measurer/index.d.ts"
|
|
208
|
+
],
|
|
209
|
+
"media": [
|
|
210
|
+
"dist/media/index.d.ts"
|
|
211
|
+
],
|
|
212
|
+
"morph": [
|
|
213
|
+
"dist/morph/index.d.ts"
|
|
214
|
+
],
|
|
215
|
+
"notifier": [
|
|
216
|
+
"dist/notifier/index.d.ts"
|
|
217
|
+
],
|
|
218
|
+
"order": [
|
|
219
|
+
"dist/order/index.d.ts"
|
|
220
|
+
],
|
|
221
|
+
"resizer": [
|
|
222
|
+
"dist/resizer/index.d.ts"
|
|
223
|
+
],
|
|
224
|
+
"router": [
|
|
225
|
+
"dist/router/index.d.ts"
|
|
226
|
+
],
|
|
227
|
+
"scroll": [
|
|
228
|
+
"dist/scroll/index.d.ts"
|
|
229
|
+
],
|
|
230
|
+
"scroll-entries": [
|
|
231
|
+
"dist/scroll-entries/index.d.ts"
|
|
232
|
+
],
|
|
233
|
+
"source": [
|
|
234
|
+
"dist/source/index.d.ts"
|
|
235
|
+
],
|
|
236
|
+
"store": [
|
|
237
|
+
"dist/store/index.d.ts"
|
|
238
|
+
],
|
|
239
|
+
"ticker": [
|
|
240
|
+
"dist/ticker/index.d.ts"
|
|
241
|
+
],
|
|
242
|
+
"utils": [
|
|
243
|
+
"dist/utils/index.d.ts"
|
|
244
|
+
],
|
|
245
|
+
"video": [
|
|
246
|
+
"dist/video/index.d.ts"
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"scripts": {
|
|
251
|
+
"dev": "vite",
|
|
252
|
+
"build": "tsc && vite build",
|
|
253
|
+
"preview": "vite preview",
|
|
254
|
+
"pp": "npm publish --access public"
|
|
255
|
+
},
|
|
256
|
+
"devDependencies": {
|
|
257
|
+
"@types/node": "^20.11.5",
|
|
258
|
+
"@types/three": "^0.160.0",
|
|
259
|
+
"vite": "^5.0.12",
|
|
260
|
+
"vite-plugin-dts": "^3.7.2"
|
|
261
|
+
},
|
|
262
|
+
"dependencies": {
|
|
263
|
+
"detect-gpu": "^5.0.37",
|
|
264
|
+
"three": "^0.160.1",
|
|
265
|
+
"urlpattern-polyfill": "^10.0.0"
|
|
266
|
+
},
|
|
267
|
+
"peerDependencies": {
|
|
268
|
+
"detect-gpu": "^5.0.37",
|
|
269
|
+
"three": "^0.160.1",
|
|
270
|
+
"urlpattern-polyfill": "^10.0.0"
|
|
271
|
+
}
|
|
272
|
+
}
|
package/public/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { StoreOptions, StoreEntry, Store, StoreCallback } from '$packages/store'
|
|
2
|
+
import { ticker, TickerCallbackEntry, TickerCallback, TickerAddOptions } from '$packages/ticker'
|
|
3
|
+
import { ElementOrSelector, clamp, fix } from '$packages/utils'
|
|
4
|
+
|
|
5
|
+
export interface AnimatedOptions extends StoreOptions<number>, TickerAddOptions {
|
|
6
|
+
min?: number | AnimatedEdgeFunction
|
|
7
|
+
max?: number | AnimatedEdgeFunction
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type AnimatedEdgeFunction = () => number
|
|
11
|
+
|
|
12
|
+
export interface AnimatedEntry extends StoreEntry<number> {
|
|
13
|
+
min: number
|
|
14
|
+
max: number
|
|
15
|
+
delta: number
|
|
16
|
+
progress: number
|
|
17
|
+
direction: number
|
|
18
|
+
speed: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export abstract class Animated<Entry extends AnimatedEntry = AnimatedEntry> extends Store<
|
|
22
|
+
number,
|
|
23
|
+
Entry
|
|
24
|
+
> {
|
|
25
|
+
#maxFPS: number | undefined
|
|
26
|
+
#order: number | undefined
|
|
27
|
+
#culling: ElementOrSelector | undefined
|
|
28
|
+
#target: number
|
|
29
|
+
#min: AnimatedEdgeFunction
|
|
30
|
+
#max: AnimatedEdgeFunction
|
|
31
|
+
#setter: Animated | undefined
|
|
32
|
+
#isRunning = new Store(false)
|
|
33
|
+
#direction = 0
|
|
34
|
+
#speed = 0
|
|
35
|
+
|
|
36
|
+
constructor(options?: AnimatedOptions) {
|
|
37
|
+
super(0, options)
|
|
38
|
+
|
|
39
|
+
this.#order = options?.order
|
|
40
|
+
this.#maxFPS = options?.maxFPS
|
|
41
|
+
this.#culling = options?.culling
|
|
42
|
+
this.#min = this.#getEdgeFunction(options?.min)
|
|
43
|
+
this.#max = this.#getEdgeFunction(options?.max)
|
|
44
|
+
this.#target = this.current = 0
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public get target() {
|
|
48
|
+
return this.#target
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public get isRunning() {
|
|
52
|
+
return this.#isRunning
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public get direction() {
|
|
56
|
+
return this.#direction
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public get maxFPS() {
|
|
60
|
+
return this.#maxFPS
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public get speed() {
|
|
64
|
+
return this.#speed
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public get min(): number {
|
|
68
|
+
return this.#min()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public set min(value: number | AnimatedEdgeFunction | undefined) {
|
|
72
|
+
this.#min = this.#getEdgeFunction(value)
|
|
73
|
+
this.set(this.#target)
|
|
74
|
+
this.current = this.#target
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public get max(): number {
|
|
78
|
+
return this.#max()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public set max(value: number | AnimatedEdgeFunction | undefined) {
|
|
82
|
+
this.#max = this.#getEdgeFunction(value)
|
|
83
|
+
this.set(this.#target)
|
|
84
|
+
this.current = this.#target
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public get delta() {
|
|
88
|
+
return this.max - this.min
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public get progress() {
|
|
92
|
+
return this.delta ? fix((this.current - this.min) / this.delta, 6) : 0
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public get setter() {
|
|
96
|
+
return this.#setter
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public override get entry(): Entry {
|
|
100
|
+
return {
|
|
101
|
+
...super.entry,
|
|
102
|
+
min: this.min,
|
|
103
|
+
max: this.max,
|
|
104
|
+
delta: this.delta,
|
|
105
|
+
direction: this.direction,
|
|
106
|
+
progress: this.progress,
|
|
107
|
+
speed: this.speed,
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public set setter(animated: Animated | undefined) {
|
|
112
|
+
this.#setter?.unsubscribe(this.#setterListener)
|
|
113
|
+
this.#setter = animated
|
|
114
|
+
this.#setter?.subscribe(this.#setterListener)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public set(value: number, equalize = false) {
|
|
118
|
+
const previous = this.#target
|
|
119
|
+
|
|
120
|
+
this.#target = clamp(value, this.min, this.max)
|
|
121
|
+
|
|
122
|
+
if (equalize) {
|
|
123
|
+
this.current = this.#target
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (this.#target !== previous) {
|
|
127
|
+
this.#speed = 0
|
|
128
|
+
this.#direction = Math.sign(value - this.#target) || 1
|
|
129
|
+
this.update()
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public shift(value: number, equalize = false) {
|
|
134
|
+
this.set(this.#target + value, equalize)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public override close() {
|
|
138
|
+
super.close()
|
|
139
|
+
|
|
140
|
+
this.unlistenAnimationFrame()
|
|
141
|
+
|
|
142
|
+
this.#setter?.unsubscribe(this.#setterListener)
|
|
143
|
+
this.#setter = undefined
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public override reset() {
|
|
147
|
+
this.set(this.initial, true)
|
|
148
|
+
super.reset()
|
|
149
|
+
this.unlistenAnimationFrame()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public listenAnimationFrame() {
|
|
153
|
+
this.#isRunning.current = true
|
|
154
|
+
ticker.subscribe(this.#animationFrameListener, {
|
|
155
|
+
maxFPS: this.#maxFPS,
|
|
156
|
+
order: this.#order,
|
|
157
|
+
culling: this.#culling,
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public unlistenAnimationFrame() {
|
|
162
|
+
this.#speed = 0
|
|
163
|
+
this.#isRunning.current = false
|
|
164
|
+
ticker.unsubscribe(this.#animationFrameListener)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
protected abstract update(): void
|
|
168
|
+
|
|
169
|
+
protected abstract handleAnimationFrame(e: TickerCallbackEntry): void
|
|
170
|
+
|
|
171
|
+
#setterListener: StoreCallback<AnimatedEntry> = (e) => {
|
|
172
|
+
this.set(e.current)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#animationFrameListener: TickerCallback = (e) => {
|
|
176
|
+
const current = this.current
|
|
177
|
+
|
|
178
|
+
this.handleAnimationFrame(e)
|
|
179
|
+
|
|
180
|
+
const delta = Math.abs(current - this.target)
|
|
181
|
+
|
|
182
|
+
this.#speed = delta / e.elapsed
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#getEdgeFunction(value: number | AnimatedEdgeFunction | undefined) {
|
|
186
|
+
const v = value || 0
|
|
187
|
+
return typeof v === 'function' ? v : () => v
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TickerCallbackEntry } from '$packages/ticker'
|
|
2
|
+
import { damp, fix } from '$packages/utils'
|
|
3
|
+
import { AnimatedOptions, Animated } from './Animated'
|
|
4
|
+
|
|
5
|
+
export interface DampedOptions extends AnimatedOptions {
|
|
6
|
+
damping?: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class Damped extends Animated {
|
|
10
|
+
public damping: number
|
|
11
|
+
|
|
12
|
+
constructor(options?: DampedOptions) {
|
|
13
|
+
super({
|
|
14
|
+
...options,
|
|
15
|
+
min: options?.min ?? -Infinity,
|
|
16
|
+
max: options?.max ?? Infinity,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
this.damping = options?.damping || 0
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
protected update() {
|
|
23
|
+
if (this.damping) {
|
|
24
|
+
this.listenAnimationFrame()
|
|
25
|
+
} else {
|
|
26
|
+
this.current = this.target
|
|
27
|
+
this.unlistenAnimationFrame()
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected handleAnimationFrame(e: TickerCallbackEntry) {
|
|
32
|
+
if (fix(this.current, 4) === fix(this.target, 4)) {
|
|
33
|
+
this.unlistenAnimationFrame()
|
|
34
|
+
this.current = this.target
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.current = damp(this.current, this.target, this.damping, e.elapsed)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TickerCallbackEntry } from '$packages/ticker'
|
|
2
|
+
import { EasingFunction, linear } from '$packages/utils'
|
|
3
|
+
import { AnimatedOptions, Animated } from './Animated'
|
|
4
|
+
|
|
5
|
+
export interface TweenedOptions extends AnimatedOptions {
|
|
6
|
+
easing?: EasingFunction
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class Tweened extends Animated {
|
|
10
|
+
public easing: EasingFunction
|
|
11
|
+
|
|
12
|
+
constructor(options?: TweenedOptions) {
|
|
13
|
+
super({
|
|
14
|
+
...options,
|
|
15
|
+
min: options?.min || 0,
|
|
16
|
+
max: options?.max || 1000,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
this.easing = options?.easing || linear
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public start() {
|
|
23
|
+
this.listenAnimationFrame()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public pause() {
|
|
27
|
+
this.unlistenAnimationFrame()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public stop() {
|
|
31
|
+
this.reset()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public override get max() {
|
|
35
|
+
return super.max
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected update() {
|
|
39
|
+
const normalized = (this.target - this.min) / (this.delta || 1)
|
|
40
|
+
const eased = this.easing(normalized)
|
|
41
|
+
this.current = this.min + eased * this.delta
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected handleAnimationFrame(e: TickerCallbackEntry) {
|
|
45
|
+
this.shift(e.elapsed)
|
|
46
|
+
|
|
47
|
+
if ((e.elapsed && this.current === 0) || this.current === this.delta) {
|
|
48
|
+
this.unlistenAnimationFrame()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|