I\'m trying out phone gap and I want my application to not scroll up and down when the user drags their finger across the screen. This is my code. Can anyone tell me why it\
At first what you have to do is you should add the event listener in body unload method.
simply put this line in the touch move method.
it won't scroll document.addEventListener("touchstart/touchmove/touchend"). Any one of these 3.
function touchMove (event e) {
e.preventDefault;
}
in your config file use
<preference name="webviewbounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
Go native and add this line to the AppDelegate.m file
self.viewController.webView.scrollView.scrollEnabled = false;
Drop it in the - (BOOL)application:(UIApplication)application didFinishLaunchingWithOptions* section.
You didn't say if this is a native app or a web app.
If this is a native app you can turn off scrolling on the webview
UIScrollView* scroll; //
for(UIView* theWebSubView in self.webView.subviews){ // where self.webView is the webview you want to stop scrolling.
if([theWebSubView isKindOfClass:[UIScrollView class] ]){
scroll = (UIScrollView*) theWebSubView;
scroll.scrollEnabled = false;
scroll.bounces = false;
}
}
otherwise here is a link on the phonegap wiki for preventing scrolling. http://wiki.phonegap.com/w/page/16494815/Preventing-Scrolling-on-iPhone-Phonegap-Applications
Changed UIWebViewBounce to DisallowOverscroll in 2.6.0
For me it work's perfect, when i use the body-selector with jquery. Otherwise i was not able to open external links with Phonegap.
$('body').on('touchmove', function(evt) {
evt.preventDefault();
})