You can use the pageX property rather than the pageY of the event object, try the following:
The position of the mouse relative to the left edge of the document.
$(document).click(function(e){ // or $(document).on('mousemove', function(e){ var mp = e.pageX; var w = $(window).width() / 2; if (mp < w) { $('#slideshow').animate({scrollLeft: "+=400"}); } else { $('#slideshow').animate({scrollLeft: "-=400"}); } })
Please note that there is a syntax error in your code, you missed it ) :
if (mouseY<(pwidth/2) {
it should be:
if ( mouseY < (pwidth/2) ) {
source share