@quicktvui/web-renderer 1.0.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/package.json +24 -0
- package/src/adapters/es3-video-player.js +828 -0
- package/src/components/Modal.js +119 -0
- package/src/components/QtAnimationView.js +678 -0
- package/src/components/QtBaseComponent.js +165 -0
- package/src/components/QtFastListView.js +1920 -0
- package/src/components/QtFlexView.js +799 -0
- package/src/components/QtImage.js +203 -0
- package/src/components/QtItemFrame.js +239 -0
- package/src/components/QtItemStoreView.js +93 -0
- package/src/components/QtItemView.js +125 -0
- package/src/components/QtListView.js +331 -0
- package/src/components/QtLoadingView.js +55 -0
- package/src/components/QtPageRootView.js +19 -0
- package/src/components/QtPlayMark.js +168 -0
- package/src/components/QtProgressBar.js +199 -0
- package/src/components/QtQRCode.js +78 -0
- package/src/components/QtReplaceChild.js +149 -0
- package/src/components/QtRippleView.js +166 -0
- package/src/components/QtSeekBar.js +409 -0
- package/src/components/QtText.js +679 -0
- package/src/components/QtTransitionImage.js +170 -0
- package/src/components/QtView.js +706 -0
- package/src/components/QtWebView.js +613 -0
- package/src/components/TabsView.js +420 -0
- package/src/components/ViewPager.js +206 -0
- package/src/components/index.js +24 -0
- package/src/components/plugins/TextV2Component.js +70 -0
- package/src/components/plugins/index.js +7 -0
- package/src/core/SceneBuilder.js +58 -0
- package/src/core/TVFocusManager.js +2014 -0
- package/src/core/asyncLocalStorage.js +175 -0
- package/src/core/autoProxy.js +165 -0
- package/src/core/componentRegistry.js +84 -0
- package/src/core/constants.js +6 -0
- package/src/core/index.js +8 -0
- package/src/core/moduleUtils.js +36 -0
- package/src/core/patches.js +958 -0
- package/src/core/templateBinding.js +666 -0
- package/src/index.js +246 -0
- package/src/modules/AndroidDevelopModule.js +101 -0
- package/src/modules/AndroidDeviceModule.js +341 -0
- package/src/modules/AndroidNetworkModule.js +178 -0
- package/src/modules/AndroidSharedPreferencesModule.js +100 -0
- package/src/modules/ESDeviceInfoModule.js +450 -0
- package/src/modules/ESGroupDataModule.js +195 -0
- package/src/modules/ESIJKAudioPlayerModule.js +477 -0
- package/src/modules/ESLocalStorageModule.js +100 -0
- package/src/modules/ESLogModule.js +65 -0
- package/src/modules/ESModule.js +106 -0
- package/src/modules/ESNetworkSpeedModule.js +117 -0
- package/src/modules/ESToastModule.js +172 -0
- package/src/modules/EsNativeModule.js +117 -0
- package/src/modules/FastListModule.js +101 -0
- package/src/modules/FocusModule.js +145 -0
- package/src/modules/RuntimeDeviceModule.js +176 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
// QtAnimationView component for web platform
|
|
2
|
+
// Implements animation using Web Animations API
|
|
3
|
+
import { QtBaseComponent } from './QtBaseComponent'
|
|
4
|
+
|
|
5
|
+
// Animation property name mappings
|
|
6
|
+
const PropertyNameMap = {
|
|
7
|
+
alpha: 'opacity',
|
|
8
|
+
rotation: 'rotate',
|
|
9
|
+
rotationX: 'rotateX',
|
|
10
|
+
rotationY: 'rotateY',
|
|
11
|
+
rotationZ: 'rotateZ',
|
|
12
|
+
scaleX: 'scaleX',
|
|
13
|
+
scaleY: 'scaleY',
|
|
14
|
+
scaleZ: 'scaleZ',
|
|
15
|
+
translationX: 'translateX',
|
|
16
|
+
translationY: 'translateY',
|
|
17
|
+
translationZ: 'translateZ',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Easing function mappings for Web Animations API
|
|
21
|
+
const EasingMap = {
|
|
22
|
+
1: 'ease', // QT_ACCELERATE_DECELERATE_INTERPOLATOR
|
|
23
|
+
2: 'ease-in', // QT_ACCELERATE_INTERPOLATOR
|
|
24
|
+
3: 'cubic-bezier(0.36, 0, 0.66, -0.56)', // QT_ANTICIPATE_INTERPOLATOR
|
|
25
|
+
4: 'cubic-bezier(0.68, -0.6, 0.32, 1.6)', // QT_ANTICIPATE_OVERSHOOT_INTERPOLATOR
|
|
26
|
+
5: 'cubic-bezier(0.68, -0.55, 0.27, 1.55)', // QT_BOUNCE_INTERPOLATOR (approximation)
|
|
27
|
+
6: 'ease-in-out', // QT_CYCLE_INTERPOLATOR (simplified)
|
|
28
|
+
7: 'ease-out', // QT_DECELERATE_INTERPOLATOR
|
|
29
|
+
8: 'linear', // QT_LINEAR_INTERPOLATOR
|
|
30
|
+
9: 'cubic-bezier(0.34, 1.56, 0.64, 1)', // QT_OVERSHOOT_INTERPOLATOR
|
|
31
|
+
10: 'cubic-bezier(0.4, 0, 1, 1)', // QT_FAST_OUT_LINEAR_IN_INTERPOLATOR
|
|
32
|
+
11: 'cubic-bezier(0.4, 0, 0.2, 1)', // QT_FAST_OUT_SLOW_IN_INTERPOLATOR
|
|
33
|
+
12: 'linear', // QT_PATH_INTERPOLATOR
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class QtAnimationView extends QtBaseComponent {
|
|
37
|
+
constructor(context, id, pId) {
|
|
38
|
+
super(context, id, pId)
|
|
39
|
+
this.tagName = 'AnimationViewComponent'
|
|
40
|
+
this.dom = document.createElement('div')
|
|
41
|
+
this._animators = new Map() // Store animator configs by id
|
|
42
|
+
this._animatorSets = new Map() // Store animator set configs
|
|
43
|
+
this._runningAnimations = new Map() // Store running Web Animation instances
|
|
44
|
+
this._pivotX = null
|
|
45
|
+
this._pivotY = null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
defaultStyle() {
|
|
49
|
+
return {
|
|
50
|
+
boxSizing: 'border-box',
|
|
51
|
+
zIndex: 0,
|
|
52
|
+
display: 'block',
|
|
53
|
+
position: 'relative',
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Get the target element for animation (first child or self)
|
|
58
|
+
_getAnimationTarget() {
|
|
59
|
+
if (this.dom && this.dom.children.length > 0) {
|
|
60
|
+
return this.dom.children[0]
|
|
61
|
+
}
|
|
62
|
+
return this.dom
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Set pivot point for rotation/scale
|
|
66
|
+
setPivotX(params) {
|
|
67
|
+
const x = params[0]
|
|
68
|
+
this._pivotX = x
|
|
69
|
+
this._updateTransformOrigin()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setPivotY(params) {
|
|
73
|
+
const y = params[0]
|
|
74
|
+
this._pivotY = y
|
|
75
|
+
this._updateTransformOrigin()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
resetPivot(params) {
|
|
79
|
+
this._pivotX = null
|
|
80
|
+
this._pivotY = null
|
|
81
|
+
this._updateTransformOrigin()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_updateTransformOrigin() {
|
|
85
|
+
const target = this._getAnimationTarget()
|
|
86
|
+
if (this._pivotX !== null && this._pivotY !== null) {
|
|
87
|
+
target.style.transformOrigin = `${this._pivotX}px ${this._pivotY}px`
|
|
88
|
+
} else {
|
|
89
|
+
target.style.transformOrigin = ''
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Reset all animators
|
|
94
|
+
resetAnimators(params) {
|
|
95
|
+
this._animators.clear()
|
|
96
|
+
this._animatorSets.clear()
|
|
97
|
+
this.cancelAllAnimations()
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
reset(params) {
|
|
101
|
+
this.resetAnimators(params)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Cancel all running animations
|
|
105
|
+
cancelAllAnimations() {
|
|
106
|
+
this._runningAnimations.forEach((animation) => {
|
|
107
|
+
try {
|
|
108
|
+
animation.cancel()
|
|
109
|
+
} catch (e) {
|
|
110
|
+
// Ignore errors
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
this._runningAnimations.clear()
|
|
114
|
+
|
|
115
|
+
// Reset transform and opacity
|
|
116
|
+
const target = this._getAnimationTarget()
|
|
117
|
+
target.style.transform = ''
|
|
118
|
+
target.style.opacity = ''
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Create an animator
|
|
122
|
+
// Note: callUIFunction passes params as an array
|
|
123
|
+
animator(params) {
|
|
124
|
+
const [id, valueType, propertyName, ...valuesAndRest] = params
|
|
125
|
+
|
|
126
|
+
// Find where values end and other params start
|
|
127
|
+
// values are followed by: duration, repeatMode, repeatCount, listenAnimator, listenAnimatorValue, interpolator
|
|
128
|
+
// The number of values depends on the method called (objectAnimator1, objectAnimator2, etc.)
|
|
129
|
+
// For now, assume the last 6 params are: duration, repeatMode, repeatCount, listenAnimator, listenAnimatorValue, interpolator
|
|
130
|
+
const values = valuesAndRest.slice(0, -6)
|
|
131
|
+
const [duration, repeatMode, repeatCount, listenAnimator, listenAnimatorValue, interpolator] =
|
|
132
|
+
valuesAndRest.slice(-6)
|
|
133
|
+
|
|
134
|
+
console.log('[QtAnimationView] animator called:', {
|
|
135
|
+
id,
|
|
136
|
+
valueType,
|
|
137
|
+
propertyName,
|
|
138
|
+
values,
|
|
139
|
+
duration,
|
|
140
|
+
repeatMode,
|
|
141
|
+
repeatCount,
|
|
142
|
+
interpolator,
|
|
143
|
+
})
|
|
144
|
+
const config = {
|
|
145
|
+
id,
|
|
146
|
+
propertyName,
|
|
147
|
+
values,
|
|
148
|
+
duration,
|
|
149
|
+
repeatMode,
|
|
150
|
+
repeatCount,
|
|
151
|
+
interpolator,
|
|
152
|
+
}
|
|
153
|
+
this._animators.set(id, config)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Create an animator set
|
|
157
|
+
animatorSet(params) {
|
|
158
|
+
const [id, duration, listenAnimator] = params
|
|
159
|
+
this._animatorSets.set(id, {
|
|
160
|
+
id,
|
|
161
|
+
duration,
|
|
162
|
+
listenAnimator,
|
|
163
|
+
animators: [],
|
|
164
|
+
relationType: 'together',
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Play an animator
|
|
169
|
+
play(params) {
|
|
170
|
+
const [animatorSetId, animatorId] = params
|
|
171
|
+
const animatorSet = this._animatorSets.get(animatorSetId)
|
|
172
|
+
if (animatorSet) {
|
|
173
|
+
animatorSet.animators = [{ id: animatorId, type: 'play' }]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Play with another animator
|
|
178
|
+
playWith(params) {
|
|
179
|
+
const [animatorSetId, animatorId] = params
|
|
180
|
+
const animatorSet = this._animatorSets.get(animatorSetId)
|
|
181
|
+
if (animatorSet && animatorSet.animators.length > 0) {
|
|
182
|
+
animatorSet.animators.push({ id: animatorId, type: 'with' })
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Play before another animator
|
|
187
|
+
playBefore(params) {
|
|
188
|
+
const [animatorSetId, animatorId] = params
|
|
189
|
+
const animatorSet = this._animatorSets.get(animatorSetId)
|
|
190
|
+
if (animatorSet && animatorSet.animators.length > 0) {
|
|
191
|
+
animatorSet.animators.push({ id: animatorId, type: 'before' })
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Play after another animator
|
|
196
|
+
playAfter(params) {
|
|
197
|
+
const [animatorSetId, animatorId] = params
|
|
198
|
+
const animatorSet = this._animatorSets.get(animatorSetId)
|
|
199
|
+
if (animatorSet && animatorSet.animators.length > 0) {
|
|
200
|
+
animatorSet.animators.push({ id: animatorId, type: 'after' })
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Play animators sequentially
|
|
205
|
+
playSequentially(params) {
|
|
206
|
+
const animatorSetId = params[0]
|
|
207
|
+
const animatorIds = params.slice(1)
|
|
208
|
+
const animatorSet = this._animatorSets.get(animatorSetId)
|
|
209
|
+
if (animatorSet) {
|
|
210
|
+
animatorSet.animators = animatorIds.map((id) => ({ id, type: 'sequence' }))
|
|
211
|
+
animatorSet.relationType = 'sequence'
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
playSequentially1(params) {
|
|
216
|
+
this.playSequentially([params[0], params[1]])
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
playSequentially2(params) {
|
|
220
|
+
this.playSequentially([params[0], params[1], params[2]])
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
playSequentially3(params) {
|
|
224
|
+
this.playSequentially([params[0], params[1], params[2], params[3]])
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
playSequentially4(params) {
|
|
228
|
+
this.playSequentially([params[0], params[1], params[2], params[3], params[4]])
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
playSequentially5(params) {
|
|
232
|
+
this.playSequentially([params[0], params[1], params[2], params[3], params[4], params[5]])
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Play animators together
|
|
236
|
+
playTogether(params) {
|
|
237
|
+
const animatorSetId = params[0]
|
|
238
|
+
const animatorIds = params.slice(1)
|
|
239
|
+
const animatorSet = this._animatorSets.get(animatorSetId)
|
|
240
|
+
if (animatorSet) {
|
|
241
|
+
animatorSet.animators = animatorIds.map((id) => ({ id, type: 'together' }))
|
|
242
|
+
animatorSet.relationType = 'together'
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
playTogether1(params) {
|
|
247
|
+
this.playTogether([params[0], params[1]])
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
playTogether2(params) {
|
|
251
|
+
this.playTogether([params[0], params[1], params[2]])
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
playTogether3(params) {
|
|
255
|
+
this.playTogether([params[0], params[1], params[2], params[3]])
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
playTogether4(params) {
|
|
259
|
+
this.playTogether([params[0], params[1], params[2], params[3], params[4]])
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
playTogether5(params) {
|
|
263
|
+
this.playTogether([params[0], params[1], params[2], params[3], params[4], params[5]])
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Start an animator or animator set
|
|
267
|
+
start(params) {
|
|
268
|
+
const animatorId = Array.isArray(params) ? params[0] : params
|
|
269
|
+
console.log('[QtAnimationView] start called with animatorId:', animatorId)
|
|
270
|
+
console.log('[QtAnimationView] available animators:', Array.from(this._animators.keys()))
|
|
271
|
+
console.log('[QtAnimationView] available animatorSets:', Array.from(this._animatorSets.keys()))
|
|
272
|
+
this._startAnimation(animatorId)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
startDelay(params) {
|
|
276
|
+
const animatorId = params[0]
|
|
277
|
+
const delay = params[1]
|
|
278
|
+
setTimeout(() => {
|
|
279
|
+
this._startAnimation(animatorId)
|
|
280
|
+
}, delay)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Pause animation
|
|
284
|
+
pause(params) {
|
|
285
|
+
const animatorId = params[0]
|
|
286
|
+
const animation = this._runningAnimations.get(animatorId)
|
|
287
|
+
if (animation) {
|
|
288
|
+
animation.pause()
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Resume animation
|
|
293
|
+
resume(params) {
|
|
294
|
+
const animatorId = params[0]
|
|
295
|
+
const animation = this._runningAnimations.get(animatorId)
|
|
296
|
+
if (animation) {
|
|
297
|
+
animation.play()
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Cancel animation
|
|
302
|
+
cancel(params) {
|
|
303
|
+
const animatorId = params[0]
|
|
304
|
+
const animation = this._runningAnimations.get(animatorId)
|
|
305
|
+
if (animation) {
|
|
306
|
+
animation.cancel()
|
|
307
|
+
this._runningAnimations.delete(animatorId)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Reverse animation
|
|
312
|
+
reverse(params) {
|
|
313
|
+
const animatorId = params[0]
|
|
314
|
+
const animation = this._runningAnimations.get(animatorId)
|
|
315
|
+
if (animation) {
|
|
316
|
+
animation.reverse()
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Internal method to start animation
|
|
321
|
+
_startAnimation(animatorId) {
|
|
322
|
+
// Check if it's an animator set
|
|
323
|
+
let animatorSet = this._animatorSets.get(animatorId)
|
|
324
|
+
if (animatorSet) {
|
|
325
|
+
this._runAnimatorSet(animatorSet)
|
|
326
|
+
return
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Check if it's a single animator
|
|
330
|
+
let animator = this._animators.get(animatorId)
|
|
331
|
+
if (animator) {
|
|
332
|
+
this._runAnimator(animator)
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Run a single animator
|
|
337
|
+
_runAnimator(config) {
|
|
338
|
+
console.log('[QtAnimationView] _runAnimator called with config:', config)
|
|
339
|
+
const target = this._getAnimationTarget()
|
|
340
|
+
console.log('[QtAnimationView] animation target:', target)
|
|
341
|
+
|
|
342
|
+
const { propertyName, values, duration, repeatCount, interpolator } = config
|
|
343
|
+
|
|
344
|
+
const easing = EasingMap[interpolator?.type] || 'linear'
|
|
345
|
+
const iterations = repeatCount === -1 ? Infinity : repeatCount || 1
|
|
346
|
+
const direction = config.repeatMode === 2 ? 'alternate' : 'normal'
|
|
347
|
+
|
|
348
|
+
// Build keyframes
|
|
349
|
+
const keyframes = this._buildKeyframes(propertyName, values)
|
|
350
|
+
console.log('[QtAnimationView] keyframes:', keyframes)
|
|
351
|
+
|
|
352
|
+
// Create animation
|
|
353
|
+
const animation = target.animate(keyframes, {
|
|
354
|
+
duration,
|
|
355
|
+
easing,
|
|
356
|
+
iterations,
|
|
357
|
+
direction,
|
|
358
|
+
fill: 'forwards',
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
console.log('[QtAnimationView] animation created:', animation)
|
|
362
|
+
|
|
363
|
+
this._runningAnimations.set(config.id, animation)
|
|
364
|
+
|
|
365
|
+
animation.onfinish = () => {
|
|
366
|
+
this._runningAnimations.delete(config.id)
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Run an animator set
|
|
371
|
+
_runAnimatorSet(animatorSet) {
|
|
372
|
+
const { animators, relationType } = animatorSet
|
|
373
|
+
|
|
374
|
+
if (relationType === 'together') {
|
|
375
|
+
// Run all together
|
|
376
|
+
animators.forEach((item) => {
|
|
377
|
+
const config = this._animators.get(item.id)
|
|
378
|
+
if (config) {
|
|
379
|
+
this._runAnimator(config)
|
|
380
|
+
}
|
|
381
|
+
})
|
|
382
|
+
} else if (relationType === 'sequence') {
|
|
383
|
+
// Run sequentially
|
|
384
|
+
this._runSequentially(animators, 0)
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Run animators sequentially
|
|
389
|
+
_runSequentially(animators, index) {
|
|
390
|
+
if (index >= animators.length) return
|
|
391
|
+
|
|
392
|
+
const item = animators[index]
|
|
393
|
+
const config = this._animators.get(item.id)
|
|
394
|
+
if (!config) {
|
|
395
|
+
this._runSequentially(animators, index + 1)
|
|
396
|
+
return
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const target = this._getAnimationTarget()
|
|
400
|
+
const { propertyName, values, duration, repeatCount, interpolator } = config
|
|
401
|
+
|
|
402
|
+
const easing = EasingMap[interpolator?.type] || 'linear'
|
|
403
|
+
const iterations = repeatCount === -1 ? Infinity : repeatCount || 1
|
|
404
|
+
const direction = config.repeatMode === 2 ? 'alternate' : 'normal'
|
|
405
|
+
|
|
406
|
+
const keyframes = this._buildKeyframes(propertyName, values)
|
|
407
|
+
|
|
408
|
+
const animation = target.animate(keyframes, {
|
|
409
|
+
duration,
|
|
410
|
+
easing,
|
|
411
|
+
iterations,
|
|
412
|
+
direction,
|
|
413
|
+
fill: 'forwards',
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
this._runningAnimations.set(config.id, animation)
|
|
417
|
+
|
|
418
|
+
animation.onfinish = () => {
|
|
419
|
+
this._runningAnimations.delete(config.id)
|
|
420
|
+
this._runSequentially(animators, index + 1)
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Build keyframes for Web Animations API
|
|
425
|
+
_buildKeyframes(propertyName, values) {
|
|
426
|
+
const cssProperty = PropertyNameMap[propertyName] || propertyName
|
|
427
|
+
|
|
428
|
+
if (values.length === 0) {
|
|
429
|
+
return []
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// For transform properties, we need to build transform string
|
|
433
|
+
const transformProps = [
|
|
434
|
+
'rotate',
|
|
435
|
+
'rotateX',
|
|
436
|
+
'rotateY',
|
|
437
|
+
'rotateZ',
|
|
438
|
+
'scaleX',
|
|
439
|
+
'scaleY',
|
|
440
|
+
'translateX',
|
|
441
|
+
'translateY',
|
|
442
|
+
]
|
|
443
|
+
|
|
444
|
+
if (transformProps.includes(cssProperty)) {
|
|
445
|
+
return values.map((value, index) => {
|
|
446
|
+
const progress = values.length === 1 ? 1 : index / (values.length - 1)
|
|
447
|
+
const frame = {}
|
|
448
|
+
|
|
449
|
+
switch (cssProperty) {
|
|
450
|
+
case 'rotate':
|
|
451
|
+
frame.transform = `rotate(${value}deg)`
|
|
452
|
+
break
|
|
453
|
+
case 'rotateX':
|
|
454
|
+
frame.transform = `rotateX(${value}deg)`
|
|
455
|
+
break
|
|
456
|
+
case 'rotateY':
|
|
457
|
+
frame.transform = `rotateY(${value}deg)`
|
|
458
|
+
break
|
|
459
|
+
case 'rotateZ':
|
|
460
|
+
frame.transform = `rotateZ(${value}deg)`
|
|
461
|
+
break
|
|
462
|
+
case 'scaleX':
|
|
463
|
+
frame.transform = `scaleX(${value})`
|
|
464
|
+
break
|
|
465
|
+
case 'scaleY':
|
|
466
|
+
frame.transform = `scaleY(${value})`
|
|
467
|
+
break
|
|
468
|
+
case 'translateX':
|
|
469
|
+
frame.transform = `translateX(${value}px)`
|
|
470
|
+
break
|
|
471
|
+
case 'translateY':
|
|
472
|
+
frame.transform = `translateY(${value}px)`
|
|
473
|
+
break
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return frame
|
|
477
|
+
})
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// For opacity
|
|
481
|
+
if (cssProperty === 'opacity') {
|
|
482
|
+
return values.map((value) => ({
|
|
483
|
+
opacity: value,
|
|
484
|
+
}))
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// Default case
|
|
488
|
+
return values.map((value) => ({
|
|
489
|
+
[cssProperty]: value,
|
|
490
|
+
}))
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Legacy method names for compatibility
|
|
494
|
+
startAnimator(params) {
|
|
495
|
+
const animatorId = Array.isArray(params) ? params[0] : params
|
|
496
|
+
this._startAnimation(animatorId)
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
startAnimatorDelay(params) {
|
|
500
|
+
const animatorId = Array.isArray(params) ? params[0] : params
|
|
501
|
+
const delay = Array.isArray(params) ? params[1] : 0
|
|
502
|
+
setTimeout(() => {
|
|
503
|
+
this._startAnimation(animatorId)
|
|
504
|
+
}, delay)
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
pauseAnimator(params) {
|
|
508
|
+
const animatorId = Array.isArray(params) ? params[0] : params
|
|
509
|
+
const animation = this._runningAnimations.get(animatorId)
|
|
510
|
+
if (animation) {
|
|
511
|
+
animation.pause()
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
resumeAnimator(params) {
|
|
516
|
+
const animatorId = Array.isArray(params) ? params[0] : params
|
|
517
|
+
const animation = this._runningAnimations.get(animatorId)
|
|
518
|
+
if (animation) {
|
|
519
|
+
animation.play()
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
cancelAnimator(params) {
|
|
524
|
+
const animatorId = Array.isArray(params) ? params[0] : params
|
|
525
|
+
const animation = this._runningAnimations.get(animatorId)
|
|
526
|
+
if (animation) {
|
|
527
|
+
animation.cancel()
|
|
528
|
+
this._runningAnimations.delete(animatorId)
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
reverseAnimator(params) {
|
|
533
|
+
const animatorId = Array.isArray(params) ? params[0] : params
|
|
534
|
+
const animation = this._runningAnimations.get(animatorId)
|
|
535
|
+
if (animation) {
|
|
536
|
+
animation.reverse()
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Object animator methods for different value counts
|
|
541
|
+
// Note: callUIFunction passes params as an array, so we accept an array and extract values
|
|
542
|
+
objectAnimator1(params) {
|
|
543
|
+
const [
|
|
544
|
+
id,
|
|
545
|
+
valueType,
|
|
546
|
+
propertyName,
|
|
547
|
+
value1,
|
|
548
|
+
duration,
|
|
549
|
+
repeatMode,
|
|
550
|
+
repeatCount,
|
|
551
|
+
listenAnimator,
|
|
552
|
+
listenAnimatorValue,
|
|
553
|
+
interpolator,
|
|
554
|
+
] = params
|
|
555
|
+
const config = {
|
|
556
|
+
id,
|
|
557
|
+
propertyName,
|
|
558
|
+
values: [value1],
|
|
559
|
+
duration,
|
|
560
|
+
repeatMode,
|
|
561
|
+
repeatCount,
|
|
562
|
+
interpolator,
|
|
563
|
+
}
|
|
564
|
+
console.log('[QtAnimationView] objectAnimator1:', config)
|
|
565
|
+
this._animators.set(id, config)
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
objectAnimator2(params) {
|
|
569
|
+
const [
|
|
570
|
+
id,
|
|
571
|
+
valueType,
|
|
572
|
+
propertyName,
|
|
573
|
+
value1,
|
|
574
|
+
value2,
|
|
575
|
+
duration,
|
|
576
|
+
repeatMode,
|
|
577
|
+
repeatCount,
|
|
578
|
+
listenAnimator,
|
|
579
|
+
listenAnimatorValue,
|
|
580
|
+
interpolator,
|
|
581
|
+
] = params
|
|
582
|
+
const config = {
|
|
583
|
+
id,
|
|
584
|
+
propertyName,
|
|
585
|
+
values: [value1, value2],
|
|
586
|
+
duration,
|
|
587
|
+
repeatMode,
|
|
588
|
+
repeatCount,
|
|
589
|
+
interpolator,
|
|
590
|
+
}
|
|
591
|
+
console.log('[QtAnimationView] objectAnimator2:', config)
|
|
592
|
+
this._animators.set(id, config)
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
objectAnimator3(params) {
|
|
596
|
+
const [
|
|
597
|
+
id,
|
|
598
|
+
valueType,
|
|
599
|
+
propertyName,
|
|
600
|
+
value1,
|
|
601
|
+
value2,
|
|
602
|
+
value3,
|
|
603
|
+
duration,
|
|
604
|
+
repeatMode,
|
|
605
|
+
repeatCount,
|
|
606
|
+
listenAnimator,
|
|
607
|
+
listenAnimatorValue,
|
|
608
|
+
interpolator,
|
|
609
|
+
] = params
|
|
610
|
+
const config = {
|
|
611
|
+
id,
|
|
612
|
+
propertyName,
|
|
613
|
+
values: [value1, value2, value3],
|
|
614
|
+
duration,
|
|
615
|
+
repeatMode,
|
|
616
|
+
repeatCount,
|
|
617
|
+
interpolator,
|
|
618
|
+
}
|
|
619
|
+
this._animators.set(id, config)
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
objectAnimator4(params) {
|
|
623
|
+
const [
|
|
624
|
+
id,
|
|
625
|
+
valueType,
|
|
626
|
+
propertyName,
|
|
627
|
+
value1,
|
|
628
|
+
value2,
|
|
629
|
+
value3,
|
|
630
|
+
value4,
|
|
631
|
+
duration,
|
|
632
|
+
repeatMode,
|
|
633
|
+
repeatCount,
|
|
634
|
+
listenAnimator,
|
|
635
|
+
listenAnimatorValue,
|
|
636
|
+
interpolator,
|
|
637
|
+
] = params
|
|
638
|
+
const config = {
|
|
639
|
+
id,
|
|
640
|
+
propertyName,
|
|
641
|
+
values: [value1, value2, value3, value4],
|
|
642
|
+
duration,
|
|
643
|
+
repeatMode,
|
|
644
|
+
repeatCount,
|
|
645
|
+
interpolator,
|
|
646
|
+
}
|
|
647
|
+
this._animators.set(id, config)
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
objectAnimator5(params) {
|
|
651
|
+
const [
|
|
652
|
+
id,
|
|
653
|
+
valueType,
|
|
654
|
+
propertyName,
|
|
655
|
+
value1,
|
|
656
|
+
value2,
|
|
657
|
+
value3,
|
|
658
|
+
value4,
|
|
659
|
+
value5,
|
|
660
|
+
duration,
|
|
661
|
+
repeatMode,
|
|
662
|
+
repeatCount,
|
|
663
|
+
listenAnimator,
|
|
664
|
+
listenAnimatorValue,
|
|
665
|
+
interpolator,
|
|
666
|
+
] = params
|
|
667
|
+
const config = {
|
|
668
|
+
id,
|
|
669
|
+
propertyName,
|
|
670
|
+
values: [value1, value2, value3, value4, value5],
|
|
671
|
+
duration,
|
|
672
|
+
repeatMode,
|
|
673
|
+
repeatCount,
|
|
674
|
+
interpolator,
|
|
675
|
+
}
|
|
676
|
+
this._animators.set(id, config)
|
|
677
|
+
}
|
|
678
|
+
}
|