Skip to content

Instantly share code, notes, and snippets.

@stsdc
Created February 27, 2016 20:16
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 stsdc/4d77c0ea9e8124ab5fd5 to your computer and use it in GitHub Desktop.
Save stsdc/4d77c0ea9e8124ab5fd5 to your computer and use it in GitHub Desktop.
Oblicza o ile pixeli przesunąć blok
// Oblicza o ile pixeli przesunąć kartę
function pixelsToCenter(block) {
var viewCenterX = Math.floor(window.innerWidth / 2);
var viewCenterY = Math.floor(window.innerHeight / 2);
var offset = block.offset();
return {
x: function() {
return viewCenterX - Math.floor(offset.left + block.outerWidth() / 2);
},
y: function() {
return viewCenterY - Math.floor(offset.top + block.outerHeight() / 2);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment