Skip to content

Instantly share code, notes, and snippets.

@AdaRoseCannon
Last active December 10, 2017 13:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AdaRoseCannon/1f1c86cc8d390e5760fc029793b8db22 to your computer and use it in GitHub Desktop.
Save AdaRoseCannon/1f1c86cc8d390e5760fc029793b8db22 to your computer and use it in GitHub Desktop.
if (document.body.animate && typeof Animation === 'undefined') {
window.Animation = document.body.animate({}).constructor;
}
if (typeof Animation !== 'undefined' && Animation.prototype.finished === undefined) {
Object.defineProperty(Animation.prototype, 'finished', {get: function () {
if (this.__finishPromise) return this.__finishPromise;
if (this.playState === 'finished') {
this.__finishPromise = Promise.resolve();
} else {
this.__finishPromise = new Promise(function (resolve) {
this.addEventListener('finish', resolve, {once: true});
}.bind(this));
}
return this.__finishPromise;
}});
}
@AdaRoseCannon
Copy link
Author

@AdaRoseCannon
Copy link
Author

Thanks Šime Vidas for the Chrome fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment