Skip to content

Instantly share code, notes, and snippets.

@aichholzer
Last active November 9, 2017 03:31
Show Gist options
  • Select an option

  • Save aichholzer/fe7b2f1d24254a7ebee05cd3dc12d483 to your computer and use it in GitHub Desktop.

Select an option

Save aichholzer/fe7b2f1d24254a7ebee05cd3dc12d483 to your computer and use it in GitHub Desktop.

Revisions

  1. aichholzer revised this gist Nov 9, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions jquery.animator.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    /**
    * Element fadeIn plugin for jQuery.
    * @author Stefan Aichholzer <https://github.com/aichholzer>
    * @param options -Object defining the animation's end result.
    *
    * {
  2. aichholzer created this gist Nov 9, 2017.
    21 changes: 21 additions & 0 deletions jquery.animator.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    /**
    * Element fadeIn plugin for jQuery.
    * @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));