mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-16 17:46:17 -08:00
add Artplayer.USE_RAF
This commit is contained in:
1 parent
6fc1532ada
commit
9ba838aa52
10 files changed
+105
-11
No files matched your search
@@ -0,0 +1,19 @@
|
||||
export default function updateInit(art) {
|
||||
if (art.constructor.USE_RAF) {
|
||||
let timer = null;
|
||||
|
||||
(function update() {
|
||||
if (art.playing) {
|
||||
art.emit('raf');
|
||||
}
|
||||
|
||||
if (!art.isDestroy) {
|
||||
timer = requestAnimationFrame(update);
|
||||
}
|
||||
})();
|
||||
|
||||
art.on('destroy', () => {
|
||||
cancelAnimationFrame(timer);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user