mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-23 22:01:20 -08:00
refactor(core): CORE-17 type input events and own interaction lifetimes
This commit is contained in:
1 parent
88aef830df
commit
a842058136
72 files changed
+31156
-1219
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import type { RafEvents, RafHost } from './scheduling-types'
|
||||
import { getScope, isClosing } from '../lifecycle/instance'
|
||||
import { animationFrame } from '../lifecycle/resources'
|
||||
import { eventSubscriptions } from './subscriptions'
|
||||
|
||||
export default function updateInit(art: RafHost): void {
|
||||
if (!art.constructor.USE_RAF)
|
||||
return
|
||||
const scope = getScope(art)
|
||||
let cancel = () => {}
|
||||
const update = () => {
|
||||
if (isClosing(art))
|
||||
return
|
||||
if (art.playing)
|
||||
art.emit('raf')
|
||||
if (!isClosing(art))
|
||||
cancel = animationFrame(scope, update)
|
||||
}
|
||||
update()
|
||||
eventSubscriptions<RafEvents>(art)('destroy', () => cancel())
|
||||
}
|
||||
Reference in new issue
Block a user