Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent window from dragging in ios5 mobile browser

I'm working on an iPad browser games and can't seem to lock the window. I've prevented scroll bars using typical overflow techniques, but the entire window still drags up and down (the new rubberband - type effect)

Is there a way to remove this window dragging?

Thannks

like image 519
bmanderscheid Avatar asked Feb 22 '23 22:02

bmanderscheid


1 Answers

Bind to touchmove and preventDefault action which is scrolling

document.body.addEventListener('touchmove', function (ev) { 
  ev.preventDefault();
});

Or with jQuery

$('body').bind('touchmove', function (ev) { 
  ev.preventDefault();
});

EDIT: I've actually come across another solution that may be even easier, try this

body { overflow: hidden; }
like image 170
sciritai Avatar answered Mar 06 '23 04:03

sciritai