Last active
November 9, 2017 03:31
-
-
Save aichholzer/fe7b2f1d24254a7ebee05cd3dc12d483 to your computer and use it in GitHub Desktop.
Element animator for jQuery
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
/** | |
* Element fadeIn plugin for jQuery. | |
* @author Stefan Aichholzer <https://github.com/aichholzer> | |
* @param options -Object defining the animation's end result. | |
* | |
* { | |
* opacity: 1, | |
* marginBottom: 5, | |
* duration: 50 | |
* } | |
*/ | |
(function ($) { | |
$.fn.animator = function animator(options = null) { | |
if (!options) { | |
return this; | |
} | |
this.toArray() | |
.map(item => () => $(item).animate(options, options.duration).promise()) | |
.reduce((current, next) => current.then(next), $().promise()); | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment