Skip to content

Instantly share code, notes, and snippets.

@max107
Created June 1, 2016 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max107/83ebe5e4c01cca4618b4e577bc5bb747 to your computer and use it in GitHub Desktop.
Save max107/83ebe5e4c01cca4618b4e577bc5bb747 to your computer and use it in GitHub Desktop.
fly.js
import $ from 'jquery';
export default (src, dst) => {
let divider = 3,
$src = $(src),
$dst = $(dst),
$srcClone = $($src.clone());
$srcClone.css({
'position': 'absolute',
'top': $src.offset().top + "px",
'left': $src.offset().left + "px",
'opacity': 1,
'z-index': 1000
});
$('body').append($srcClone);
let gotoX = $dst.offset().left + ($dst.width() / 2) - ($dst.width() / divider) / 2,
gotoY = $dst.offset().top + ($dst.height() / 2) - ($dst.height() / divider) / 2,
options = {
opacity: 0.4,
left: gotoX,
top: gotoY,
width: $src.width() / divider,
height: $src.height() / divider
};
$srcClone.animate(options, 'normal', () => {
$srcClone.fadeOut('fast', () => {
$srcClone.remove();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment