Skip to content

Instantly share code, notes, and snippets.

@elm4ward
Last active October 22, 2021 21:19
Show Gist options
  • Save elm4ward/8425581 to your computer and use it in GitHub Desktop.
Save elm4ward/8425581 to your computer and use it in GitHub Desktop.
handle CSS animation programmatically via promise
// 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