jquery-ui/ui/effect-transfer.js

63 lines
1.5 KiB
JavaScript
Raw Normal View History

/*!
* jQuery UI Effects Transfer @VERSION
2012-07-04 13:08:08 +00:00
* http://jqueryui.com
*
2014-01-29 03:25:02 +00:00
* Copyright 2014 jQuery Foundation and other contributors
2012-08-09 14:13:24 +00:00
* Released under the MIT license.
* http://jquery.org/license
*/
//>>label: Transfer Effect
//>>group: Effects
//>>description: Displays a transfer effect from one element to another.
//>>docs: http://api.jqueryui.com/transfer-effect/
//>>demos: http://jqueryui.com/effect/
(function( factory ) {
if ( typeof define === "function" && define.amd ) {
2008-06-04 02:34:33 +00:00
// AMD. Register as an anonymous module.
define([
"jquery",
"./effect"
], factory );
} else {
// Browser globals
factory( jQuery );
}
}(function( $ ) {
return $.effects.effect.transfer = function( o, done ) {
var elem = $( this ),
target = $( o.to ),
targetFixed = target.css( "position" ) === "fixed",
body = $("body"),
fixTop = targetFixed ? body.scrollTop() : 0,
fixLeft = targetFixed ? body.scrollLeft() : 0,
endPosition = target.offset(),
animation = {
2013-10-16 18:43:09 +00:00
top: endPosition.top - fixTop,
left: endPosition.left - fixLeft,
height: target.innerHeight(),
width: target.innerWidth()
},
startPosition = elem.offset(),
transfer = $( "<div class='ui-effects-transfer'></div>" )
.appendTo( document.body )
.addClass( o.className )
.css({
2013-10-16 18:43:09 +00:00
top: startPosition.top - fixTop,
left: startPosition.left - fixLeft,
height: elem.innerHeight(),
width: elem.innerWidth(),
position: targetFixed ? "fixed" : "absolute"
})
.animate( animation, o.duration, o.easing, function() {
transfer.remove();
done();
});
};
2008-06-04 02:34:33 +00:00
}));