[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/jquery/ui/ -> effect-shake.js (source)

   1  /*!
   2   * jQuery UI Effects Shake 1.13.1
   3   * http://jqueryui.com
   4   *
   5   * Copyright jQuery Foundation and other contributors
   6   * Released under the MIT license.
   7   * http://jquery.org/license
   8   */
   9  
  10  //>>label: Shake Effect
  11  //>>group: Effects
  12  //>>description: Shakes an element horizontally or vertically n times.
  13  //>>docs: http://api.jqueryui.com/shake-effect/
  14  //>>demos: http://jqueryui.com/effect/
  15  
  16  ( function( factory ) {
  17      "use strict";
  18  
  19      if ( typeof define === "function" && define.amd ) {
  20  
  21          // AMD. Register as an anonymous module.
  22          define( [
  23              "jquery",
  24              "./effect"
  25          ], factory );
  26      } else {
  27  
  28          // Browser globals
  29          factory( jQuery );
  30      }
  31  } )( function( $ ) {
  32  "use strict";
  33  
  34  return $.effects.define( "shake", function( options, done ) {
  35  
  36      var i = 1,
  37          element = $( this ),
  38          direction = options.direction || "left",
  39          distance = options.distance || 20,
  40          times = options.times || 3,
  41          anims = times * 2 + 1,
  42          speed = Math.round( options.duration / anims ),
  43          ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  44          positiveMotion = ( direction === "up" || direction === "left" ),
  45          animation = {},
  46          animation1 = {},
  47          animation2 = {},
  48  
  49          queuelen = element.queue().length;
  50  
  51      $.effects.createPlaceholder( element );
  52  
  53      // Animation
  54      animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  55      animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  56      animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  57  
  58      // Animate
  59      element.animate( animation, speed, options.easing );
  60  
  61      // Shakes
  62      for ( ; i < times; i++ ) {
  63          element
  64              .animate( animation1, speed, options.easing )
  65              .animate( animation2, speed, options.easing );
  66      }
  67  
  68      element
  69          .animate( animation1, speed, options.easing )
  70          .animate( animation, speed / 2, options.easing )
  71          .queue( done );
  72  
  73      $.effects.unshift( element, queuelen, anims + 1 );
  74  } );
  75  
  76  } );


Generated: Sun Dec 22 01:00:02 2024 Cross-referenced by PHPXref 0.7.1