Last active
October 22, 2021 21:19
-
-
Save elm4ward/8425581 to your computer and use it in GitHub Desktop.
handle CSS animation programmatically via promise
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
// attention: needs when.js, jquery and checks only for webkit | |
var transformTo = function ($e, css, property) { | |
var deferred = when.defer(); | |
$e.on('webkitTransitionEnd', function (e) { | |
if (!!property && property !== e.originalEvent.propertyName) { | |
return; | |
} | |
$e.off('webkitTransitionEnd'); | |
deferred.resolve(); | |
}).css(css); | |
return deferred.promise; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment