Skip to content

Commit 3e0d3c9

Browse files
tomykairagnarf
authored andcommitted
Effects.transfer: check the target is fixed or not, and consider scrolling. Fixed #5547 - Transfer effect to fixed positioned element.
1 parent 154c5e5 commit 3e0d3c9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

ui/jquery.effects.transfer.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ $.effects.effect.transfer = function( o ) {
1717
return this.queue( function() {
1818
var elem = $( this ),
1919
target = $( o.to ),
20+
targetFixed = target.css( "position" ) === "fixed",
21+
body = $("body"),
22+
fixTop = targetFixed ? body.scrollTop() : 0,
23+
fixLeft = targetFixed ? body.scrollLeft() : 0,
2024
endPosition = target.offset(),
2125
animation = {
22-
top: endPosition.top,
23-
left: endPosition.left,
26+
top: endPosition.top - fixTop ,
27+
left: endPosition.left - fixLeft ,
2428
height: target.innerHeight(),
2529
width: target.innerWidth()
2630
},
@@ -29,11 +33,11 @@ $.effects.effect.transfer = function( o ) {
2933
.appendTo( document.body )
3034
.addClass( o.className )
3135
.css({
32-
top: startPosition.top,
33-
left: startPosition.left,
36+
top: startPosition.top - fixTop ,
37+
left: startPosition.left - fixLeft ,
3438
height: elem.innerHeight(),
3539
width: elem.innerWidth(),
36-
position: 'absolute'
40+
position: targetFixed ? "fixed" : "absolute"
3741
})
3842
.animate( animation, o.duration, o.easing, function() {
3943
transfer.remove();

0 commit comments

Comments
 (0)