Created
October 15, 2014 06:42
-
-
Save bitIO/33fc778405de217fc59b to your computer and use it in GitHub Desktop.
Screen/Window/Viewport Width & Mouse event coordinates;
This file contains hidden or 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
// SOURCE : http://xahlee.info/js/js_viewport_dimension.html | |
// CSS PIXELS: http://xahlee.info/js/web_design_screen_density.html | |
// user's physical screen dimension/size (Result is in physical pixels) | |
console.log( screen.width, screen.height ); | |
// user's window size (Result is in CSS pixels) | |
console.log( window.innerWidth, window.innerHeight ); | |
// viewport size (Result is in CSS pixels) | |
console.log( | |
document.documentElement.clientWidth, document.documentElement.clientHeight ); | |
// find scroll amount | |
console.log( | |
document.documentElement.offsetWidth, document.documentElement.offsetHeight); | |
// mouse event coordinates | |
pageX; pageY; // relative to the HTML element in CSS pixels. | |
clientX; clientY; // the coordinates relative to the viewport. | |
screenX; screenY; // the coordinates relative to the screen. In physical pixels. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment