effect-transfer.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*!
  2. * jQuery UI Effects Transfer 1.11.4
  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. * http://api.jqueryui.com/transfer-effect/
  10. */
  11. (function( factory ) {
  12. if ( typeof define === "function" && define.amd ) {
  13. // AMD. Register as an anonymous module.
  14. define([
  15. "jquery",
  16. "./effect"
  17. ], factory );
  18. } else {
  19. // Browser globals
  20. factory( jQuery );
  21. }
  22. }(function( $ ) {
  23. return $.effects.effect.transfer = function( o, done ) {
  24. var elem = $( this ),
  25. target = $( o.to ),
  26. targetFixed = target.css( "position" ) === "fixed",
  27. body = $("body"),
  28. fixTop = targetFixed ? body.scrollTop() : 0,
  29. fixLeft = targetFixed ? body.scrollLeft() : 0,
  30. endPosition = target.offset(),
  31. animation = {
  32. top: endPosition.top - fixTop,
  33. left: endPosition.left - fixLeft,
  34. height: target.innerHeight(),
  35. width: target.innerWidth()
  36. },
  37. startPosition = elem.offset(),
  38. transfer = $( "<div class='ui-effects-transfer'></div>" )
  39. .appendTo( document.body )
  40. .addClass( o.className )
  41. .css({
  42. top: startPosition.top - fixTop,
  43. left: startPosition.left - fixLeft,
  44. height: elem.innerHeight(),
  45. width: elem.innerWidth(),
  46. position: targetFixed ? "fixed" : "absolute"
  47. })
  48. .animate( animation, o.duration, o.easing, function() {
  49. transfer.remove();
  50. done();
  51. });
  52. };
  53. }));