Skip to content

Instantly share code, notes, and snippets.

@yagopv
Created August 19, 2016 13:17
Show Gist options
  • Save yagopv/197803ef637d7d047b6cc9ff8594f6bd to your computer and use it in GitHub Desktop.
Save yagopv/197803ef637d7d047b6cc9ff8594f6bd to your computer and use it in GitHub Desktop.
animate source to target
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