Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
mpridham
Posts: 2
Registered: ‎03-08-2012
My Device: Developer

Prevent scrolling in JavaScript on BB7 browserfield2

[ Edited ]

Hi,

 

I was wondering if anyones knows how to stop the screen from scrolling in the JavaScript?  I'm trying to use a web based spinning wheel and the whole screen scrolls.  The spinning wheel can be found here:

http://cubiq.org/spinning-wheel-on-webkit-for-iphone-ipod-touch

 

The root cause seems to be stopping the page scrolling so only the wheel can spin.  This is done using the touchstart and touchmove events and seems to be inline with what the knowledge base suggests:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/How-to-prevent-default-touch-and...

 

You can see this scrolling issue by modifing the sample browserfield2demo index.html:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function loaded() {
document.addEventListener('touchstart', function(e){ e.preventDefault(); e.stopPropagation(); });
document.addEventListener('touchmove', function(e){ e.preventDefault(); e.stopPropagation(); });
}
function touchMove(e) {
// Prevent scrolling on this element
e.preventDefault();
e.stopPropagation();
}
</script>
</HEAD>
<BODY onload="loaded();">
<div id="container" ontouchmove="touchMove(event);">
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
<H1> BLAH </H1>
</div>
</BODY>
</HTML>

 

What is really weird is if you copy the index.html to the SDCard and load it in bb7 browser it works(no scrolling!).  This issue only happens with the browserfield.  I tried playing around with the navigation mode and layout manager for the browser field and nothing helps.  Does anyone have any ideas???

 

I was using the following simulator: 7.1.0.137 (9900)

 

Retired
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Prevent scrolling in JavaScript on BB7 browserfield2

It sounds like the JavaScript itself is not being executed from within the context of the BrowserField. This is certainly not expected.

 

Sanity check - does it work on other simulators (maybe a 9900 running 7.0)?

 

If so, we have a bug in the 7.1 sim. Otherwise can you confirm the onload event is firing as expected, and the e.preventDefault statement is not throwing an exception?

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
New Contributor
mpridham
Posts: 2
Registered: ‎03-08-2012
My Device: Developer

Re: Prevent scrolling in JavaScript on BB7 browserfield2

[ Edited ]

I borrowed someones 9900 device and it happens there also so it is not just a simulator issue.  I just  tried on a 7.0.0.598 (9810) simulator and the issue is there also.

 

I created a JIRA issue for the problem:

https://www.blackberry.com/jira/browse/WEBAPI-226