-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
animation.js
33 lines (31 loc) · 985 Bytes
/
animation.js
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
(function() {
'use strict';
if (globalThis.hasOwnProperty('Animation') && ! Animation.prototype.hasOwnProperty('finished')) {
Object.defineProperty(Animation.prototype, 'finished', {
get: function() {
return new Promise((resolve, reject) => {
if (this.playState === 'finished') {
resolve(this);
} else {
this.addEventListener('finish', () => resolve(this), { once: true });
this.addEventListener('error', event => reject(event), { once: true });
}
});
}
});
}
if (globalThis.hasOwnProperty('Animation') && ! Animation.prototype.hasOwnProperty('ready')) {
Object.defineProperty(Animation.prototype, 'ready', {
get: function() {
return new Promise((resolve, reject) => {
if (! this.pending) {
resolve(this);
} else {
this.addEventListener('ready', () => resolve(this), { once: true });
this.addEventListener('error', event => reject(event), { once: true });
}
});
}
});
}
})();