Jump to content

Stopping all scrolling


wongadob

Recommended Posts

Hi y'all, I am stuggling with preventing scrolling when a pop up comes on screen. I want to prevent all background scrolling behind the pop up. This is for a mobile application (on blackberry). I have the following function that detects if a variable scrollOn is false (i.e. scroll is off) and then prevents propagation. The problem I have is finding what the ###### to bind it to. I have bound it to body, document, 'body,html', window etc etc none of which are stopping the ontouchmove events (because its still scrolling on touch move);. What should I be binding it to. here is the example of what I have got now. It is bound to body direct via HTML

<body id="bodyID" onkeypress = "checkTBkeypress(event)" ontouchmove = "shouldIScroll(event)">

And the function is simply this

function shouldIScroll(event){if (scrollOn){  return true;}else{  console.log("you moved and I got it ");  console.log("scrollOn = ",scrollOn);  event.stopPropagation;  return false;}}

I am getting the correct messages I should when it should be switched on and off, but it is not preventing the scroll? I guess becuase the ontouchmove event is being triggered lower down the chain, Can you globally bind so ANY ontoucmove event trigger my code. The code should stop the propagation. Problem is the rest of the page is made up of many many elements. Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...