Last active
December 10, 2017 13:08
-
-
Save AdaRoseCannon/1f1c86cc8d390e5760fc029793b8db22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}}); | |
} |
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
Test: http://jsbin.com/qiciyuboqo/edit?html,js,output