Created
October 2, 2012 04:31
-
-
Save ScottMaclure/3816175 to your computer and use it in GitHub Desktop.
Gutter clicks on page
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
$("body").off("click"); | |
$("body").on("click", function(event) { | |
console.log("body click pageX: " + event.pageX + " pageY: " + event.pageY); | |
if (typeof event.pageX === "undefined" || typeof event.pageY === "undefined") { | |
console.log("Not a user-originated click event, aborting."); | |
return; | |
} | |
if (event.pageX === 0 && event.pageY === 0) { | |
console.log("Not a user-originated click event, aborting."); | |
return; | |
} | |
var globalHeaderWidth = $("#global_header").width() | |
// Gutter width is window width, less the main content area, divided by 2 (we have left/right gutters). | |
var gutterWidth = ($(window).width() - globalHeaderWidth) / 2; | |
if (event.pageX < gutterWidth) { | |
console.log("left gutter click"); | |
} else if (event.pageX > gutterWidth + globalHeaderWidth) { | |
console.log("right gutter click"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment