Created
August 19, 2016 13:17
-
-
Save yagopv/197803ef637d7d047b6cc9ff8594f6bd to your computer and use it in GitHub Desktop.
animate source to target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $start = $($('img')[2]).clone(); | |
var $end = $('img')[0]; | |
var rectStart = $($('img')[2])[0].getBoundingClientRect(); | |
var rectEnd = $end.getBoundingClientRect(); | |
$start.css({ | |
position: 'absolute', | |
top: rectStart.top + window.scrollY, | |
left: rectStart.left, | |
bottom: rectStart.bottom, | |
height: rectStart.height, | |
width: rectStart.width, | |
right: rectStart.right, | |
opacity: 0 | |
}).appendTo($('body')); | |
$start.animate({ | |
top: rectEnd.top + window.scrollY, | |
left: rectEnd.left, | |
bottom: rectEnd.bottom, | |
height: rectEnd.height, | |
width: rectEnd.width, | |
right: rectEnd.right, | |
opacity: 1 | |
},{ | |
duration: 666, | |
complete: function () { | |
$start.remove(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment