jquery.ui.effect-transfer.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*!
  2. * jQuery UI Effects Transfer v1.9 stable
  3. * http://jqueryui.com
  4. *
  5. * Copyright 2012 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. * Depends:
  12. * jquery.ui.effect.js
  13. */
  14. (function( $, undefined ) {
  15. $.effects.effect.transfer = function( o, done ) {
  16. var elem = $( this ),
  17. target = $( o.to ),
  18. targetFixed = target.css( "position" ) === "fixed",
  19. body = $("body"),
  20. fixTop = targetFixed ? body.scrollTop() : 0,
  21. fixLeft = targetFixed ? body.scrollLeft() : 0,
  22. endPosition = target.offset(),
  23. animation = {
  24. top: endPosition.top - fixTop ,
  25. left: endPosition.left - fixLeft ,
  26. height: target.innerHeight(),
  27. width: target.innerWidth()
  28. },
  29. startPosition = elem.offset(),
  30. transfer = $( '<div class="ui-effects-transfer"></div>' )
  31. .appendTo( document.body )
  32. .addClass( o.className )
  33. .css({
  34. top: startPosition.top - fixTop ,
  35. left: startPosition.left - fixLeft ,
  36. height: elem.innerHeight(),
  37. width: elem.innerWidth(),
  38. position: targetFixed ? "fixed" : "absolute"
  39. })
  40. .animate( animation, o.duration, o.easing, function() {
  41. transfer.remove();
  42. done();
  43. });
  44. };
  45. })(jQuery);