]> source.dussan.org Git - jquery-ui.git/commitdiff
Effects.transfer: check the target is fixed or not, and consider scrolling. Fixed...
authortomykaira <tomykaira@gmail.com>
Fri, 10 Jun 2011 20:52:27 +0000 (15:52 -0500)
committergnarf <gnarf@gnarf.net>
Fri, 10 Jun 2011 20:52:27 +0000 (15:52 -0500)
ui/jquery.effects.transfer.js

index 17d23c5fab27b2f31b74012ee2d17df85a6ef520..f0f9d9fd4bbabf30233a7e51e23de9ecd9579e27 100644 (file)
@@ -17,10 +17,14 @@ $.effects.effect.transfer = function( o ) {
        return this.queue( function() {
                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 = {
-                               top: endPosition.top,
-                               left: endPosition.left,
+                               top: endPosition.top - fixTop ,
+                               left: endPosition.left - fixLeft ,
                                height: target.innerHeight(),
                                width: target.innerWidth()
                        },
@@ -29,11 +33,11 @@ $.effects.effect.transfer = function( o ) {
                                .appendTo( document.body )
                                .addClass( o.className )
                                .css({
-                                       top: startPosition.top,
-                                       left: startPosition.left,
+                                       top: startPosition.top - fixTop ,
+                                       left: startPosition.left - fixLeft ,
                                        height: elem.innerHeight(),
                                        width: elem.innerWidth(),
-                                       position: 'absolute'
+                                       position: targetFixed ? "fixed" : "absolute"
                                })
                                .animate( animation, o.duration, o.easing, function() {
                                        transfer.remove();