effect-scale.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*!
  2. * jQuery UI Effects Scale 1.14.1
  3. * https://jqueryui.com
  4. *
  5. * Copyright OpenJS Foundation and other contributors
  6. * Released under the MIT license.
  7. * https://jquery.org/license
  8. */
  9. //>>label: Scale Effect
  10. //>>group: Effects
  11. //>>description: Grows or shrinks an element and its content.
  12. //>>docs: https://api.jqueryui.com/scale-effect/
  13. //>>demos: https://jqueryui.com/effect/
  14. ( function( factory ) {
  15. "use strict";
  16. if ( typeof define === "function" && define.amd ) {
  17. // AMD. Register as an anonymous module.
  18. define( [
  19. "jquery",
  20. "../version",
  21. "../effect",
  22. "./effect-size"
  23. ], factory );
  24. } else {
  25. // Browser globals
  26. factory( jQuery );
  27. }
  28. } )( function( $ ) {
  29. "use strict";
  30. return $.effects.define( "scale", function( options, done ) {
  31. // Create element
  32. var el = $( this ),
  33. mode = options.mode,
  34. percent = parseInt( options.percent, 10 ) ||
  35. ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
  36. newOptions = $.extend( true, {
  37. from: $.effects.scaledDimensions( el ),
  38. to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
  39. origin: options.origin || [ "middle", "center" ]
  40. }, options );
  41. // Fade option to support puff
  42. if ( options.fade ) {
  43. newOptions.from.opacity = 1;
  44. newOptions.to.opacity = 0;
  45. }
  46. $.effects.effect.size.call( this, newOptions, done );
  47. } );
  48. } );