Created
February 27, 2016 20:16
-
-
Save stsdc/4d77c0ea9e8124ab5fd5 to your computer and use it in GitHub Desktop.
Oblicza o ile pixeli przesunąć blok
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
// 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