From 7a836cb0075afddd66daf0a253124992e8f13662 Mon Sep 17 00:00:00 2001 From: artpi Date: Wed, 27 Jan 2016 12:43:33 -0500 Subject: [PATCH] Disable rubberband scroll for OSX --- public_desktop/desktop-app.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/public_desktop/desktop-app.js b/public_desktop/desktop-app.js index b409d2151..465c67d33 100644 --- a/public_desktop/desktop-app.js +++ b/public_desktop/desktop-app.js @@ -90,6 +90,15 @@ function startDesktopApp() { } } + function preventScrollBounceOSX( e ) { + if ( + ( e.deltaY < 0 && document.body.scrollTop === 0 ) || + ( e.deltaY > 0 && document.body.scrollTop === document.body.scrollHeight - window.innerHeight ) + ) { + e.preventDefault() + } + } + debug = gGebug( 'desktop:browser' ); // Everything is ready, start Calypso @@ -102,6 +111,10 @@ function startDesktopApp() { document.addEventListener( 'keydown', keyboardHandler ); document.addEventListener( 'click', preventNewWindow ); + + if ( window.navigator.userAgent.indexOf( 'Macintosh' ) !== -1 ) { + document.body.addEventListener( 'mousewheel', preventScrollBounceOSX ); + } } // This is called by Calypso