disable scrolling

1,614 views
Skip to first unread message

Jaco Smit

unread,
Feb 3, 2011, 3:28:30 AM2/3/11
to phonegap
hi

i have a app that runs animation by using a image sequence, the images
are just a bit larger than some android screens, when the user scrolls
the page then the whole thing stalls, i want to disable screen
scrolling, how can i do that?

André Fiedler

unread,
Feb 3, 2011, 3:30:12 AM2/3/11
to phon...@googlegroups.com
document.addEventListener('touchstart', function(e){ e.preventDefault(); }, false);


2011/2/3 Jaco Smit <icephi...@gmail.com>
--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

Jaco Smit

unread,
Feb 3, 2011, 3:34:04 AM2/3/11
to phon...@googlegroups.com
let me try this thanks!

Jaco Smit

unread,
Feb 3, 2011, 4:20:40 AM2/3/11
to phon...@googlegroups.com
ok this works well, is there a way to just disable scrolling but still allow click touch commands?

On Thu, Feb 3, 2011 at 10:30 AM, André Fiedler <fiedle...@googlemail.com> wrote:

Jaco Smit

unread,
Feb 3, 2011, 4:24:04 AM2/3/11
to phon...@googlegroups.com
basically i only want to stop ontouchmove

because now the user cant click on anything

On Thu, Feb 3, 2011 at 10:30 AM, André Fiedler <fiedle...@googlemail.com> wrote:

Tue Topholm

unread,
Feb 3, 2011, 4:24:51 AM2/3/11
to phon...@googlegroups.com
use touchmove instead..

But it mentioned in the index.html:

// If you want to prevent dragging, uncomment this section
function preventBehavior(e) 
      e.preventDefault(); 
    };
document.addEventListener("touchmove", preventBehavior, false);

--

Med venlig hilsen / Kind regards

Tue Topholm
Sugee
Tlf: +45 32 13 32 32
W: http://www.sugee.dk


2011/2/3 Jaco Smit <icephi...@gmail.com>

Giacomo Balli

unread,
Feb 3, 2011, 4:25:47 AM2/3/11
to phonegap
use touchmove instead of touchstart

On Feb 3, 10:20 am, Jaco Smit <icephixia2...@gmail.com> wrote:
> ok this works well, is there a way to just disable scrolling but still allow
> click touch commands?
>
> On Thu, Feb 3, 2011 at 10:30 AM, André Fiedler <fiedler.an...@googlemail.com
>
>
>
> > wrote:
> > document.addEventListener('touchstart', function(e){ e.preventDefault(); },
> > false);
>
> > 2011/2/3 Jaco Smit <icephixia2...@gmail.com>
>
> > hi
>
> >> i have a app that runs animation by using a image sequence, the images
> >> are just a bit larger than some android screens, when the user scrolls
> >> the page then the whole thing stalls, i want to disable screen
> >> scrolling, how can i do that?
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "phonegap" group.
> >> To post to this group, send email to phon...@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> phonegap+u...@googlegroups.com<phonegap%2Bunsubscribe@googlegroups.c om>
> >> For more options, visit this group at
> >>http://groups.google.com/group/phonegap?hl=en?hl=en
>
> >> For more info on PhoneGap or to download the code go towww.phonegap.com
>
> >  --
> > You received this message because you are subscribed to the Google
> > Groups "phonegap" group.
> > To post to this group, send email to phon...@googlegroups.com
> > To unsubscribe from this group, send email to
> > phonegap+u...@googlegroups.com<phonegap%2Bunsubscribe@googlegroups.c om>

Jaco Smit

unread,
Feb 3, 2011, 6:28:21 AM2/3/11
to phon...@googlegroups.com
tried that didnt work, it still scrolls, also tried this code

document.ontouchmove = function(e) {
e.preventDefault(); 
}


also didnt work

Erik Maas

unread,
Feb 3, 2011, 6:30:07 AM2/3/11
to phon...@googlegroups.com
In your css add:

body {
overflow: hidden;
}

2011/2/3 Jaco Smit <icephi...@gmail.com>

André Fiedler

unread,
Feb 3, 2011, 6:33:52 AM2/3/11
to phon...@googlegroups.com
use "ontouchstart" and register an event listener via javascript on every button. So you can handle all "click" events and it didn´t scroll anymore. You can only disable default behavior (no scrolling, no clicking, ...) and do it your self or not. Mixing isn´t possible as far as i know.

2011/2/3 Erik Maas <saam...@gmail.com>

Jaco Smit

unread,
Feb 3, 2011, 6:53:24 AM2/3/11
to phon...@googlegroups.com
this sounds great

how would i register a event listener specific to a button?

say i have a button and the id=''a''    how would i add a event listener

André Fiedler

unread,
Feb 3, 2011, 7:33:01 AM2/3/11
to phon...@googlegroups.com
Try this: http://jsfiddle.net/SunboX/eXemN/1/

I havn´t tested it! Greetings André

2011/2/3 Jaco Smit <icephi...@gmail.com>

Jaco Smit

unread,
Feb 3, 2011, 7:36:06 AM2/3/11
to phon...@googlegroups.com
thanks!! will do

Jaco Smit

unread,
Feb 4, 2011, 2:37:16 AM2/4/11
to phon...@googlegroups.com
none of these sollutions are really working, because as soon as you add a event listener on a link for instance you can scroll the page when you put your finger on that link, everywhere else is dead which is ok, but users sometimes press wrong on the link and it gets detected as a scroll and then everything breaks on my page

André Fiedler

unread,
Feb 4, 2011, 8:17:36 AM2/4/11
to phon...@googlegroups.com
have you tried e.preventDefault() on that link "touch" listener?!


2011/2/4 Jaco Smit <icephi...@gmail.com>

Jaco Smit

unread,
Feb 4, 2011, 8:31:10 AM2/4/11
to phon...@googlegroups.com
hi thanks, can you perhaps give me an example of such a link?

if i implement e.preventDefault it prevents all actions then the user cant do anything

André Fiedler

unread,
Feb 4, 2011, 8:40:33 AM2/4/11
to phon...@googlegroups.com
NOT TESTED, but i think it should work:



2011/2/4 Jaco Smit <icephi...@gmail.com>

Jaco Smit

unread,
Feb 4, 2011, 8:30:30 PM2/4/11
to phon...@googlegroups.com
cool! going to try this in the morning! thanks for the help!!!

>>>>>>>>>>> > >> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>>>>>>>>>> <phonegap%2Bunsubscribe@googlegroups.c om>
>>>>>>>>>>> > >> For more options, visit this group at
>>>>>>>>>>> > >>http://groups.google.com/group/phonegap?hl=en?hl=en
>>>>>>>>>>> >
>>>>>>>>>>> > >> For more info on PhoneGap or to download the code go
>>>>>>>>>>> towww.phonegap.com
>>>>>>>>>>> >
>>>>>>>>>>> > > --
>>>>>>>>>>> > > You received this message because you are subscribed to the
>>>>>>>>>>> Google
>>>>>>>>>>> > > Groups "phonegap" group.
>>>>>>>>>>> > > To post to this group, send email to
>>>>>>>>>>> phon...@googlegroups.com
>>>>>>>>>>> > > To unsubscribe from this group, send email to

>>>>>>>>>>> > > phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>>>>>>>>>> <phonegap%2Bunsubscribe@googlegroups.c om>
>>>>>>>>>>> > > For more options, visit this group at
>>>>>>>>>>> > >http://groups.google.com/group/phonegap?hl=en?hl=en
>>>>>>>>>>> >
>>>>>>>>>>> > > For more info on PhoneGap or to download the code go
>>>>>>>>>>> towww.phonegap.com
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>> Google
>>>>>>>>>>> Groups "phonegap" group.
>>>>>>>>>>> To post to this group, send email to phon...@googlegroups.com
>>>>>>>>>>> To unsubscribe from this group, send email to

>>>>>>>>>>> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>>>>>>>>>> For more options, visit this group at
>>>>>>>>>>> http://groups.google.com/group/phonegap?hl=en?hl=en
>>>>>>>>>>>
>>>>>>>>>>> For more info on PhoneGap or to download the code go to
>>>>>>>>>>> www.phonegap.com
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>>> Groups "phonegap" group.
>>>>>>>>>> To post to this group, send email to phon...@googlegroups.com
>>>>>>>>>> To unsubscribe from this group, send email to

>>>>>>>>>> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>>>>>>>>> For more options, visit this group at
>>>>>>>>>> http://groups.google.com/group/phonegap?hl=en?hl=en
>>>>>>>>>>
>>>>>>>>>> For more info on PhoneGap or to download the code go to
>>>>>>>>>> www.phonegap.com
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "phonegap" group.
>>>>>>>>> To post to this group, send email to phon...@googlegroups.com
>>>>>>>>> To unsubscribe from this group, send email to

>>>>>>>>> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>>>>>>>> For more options, visit this group at
>>>>>>>>> http://groups.google.com/group/phonegap?hl=en?hl=en
>>>>>>>>>
>>>>>>>>> For more info on PhoneGap or to download the code go to
>>>>>>>>> www.phonegap.com
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "phonegap" group.
>>>>>>>> To post to this group, send email to phon...@googlegroups.com
>>>>>>>> To unsubscribe from this group, send email to

>>>>>>>> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>>>>>>> For more options, visit this group at
>>>>>>>> http://groups.google.com/group/phonegap?hl=en?hl=en
>>>>>>>>
>>>>>>>> For more info on PhoneGap or to download the code go to
>>>>>>>> www.phonegap.com
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "phonegap" group.
>>>>>>> To post to this group, send email to phon...@googlegroups.com
>>>>>>> To unsubscribe from this group, send email to

>>>>>>> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/group/phonegap?hl=en?hl=en
>>>>>>>
>>>>>>> For more info on PhoneGap or to download the code go to
>>>>>>> www.phonegap.com
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "phonegap" group.
>>>>>> To post to this group, send email to phon...@googlegroups.com
>>>>>> To unsubscribe from this group, send email to

>>>>>> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/phonegap?hl=en?hl=en
>>>>>>
>>>>>> For more info on PhoneGap or to download the code go to
>>>>>> www.phonegap.com
>>>>>>
>>>>>
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "phonegap" group.
>>>> To post to this group, send email to phon...@googlegroups.com
>>>> To unsubscribe from this group, send email to

>>>> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>>> For more options, visit this group at
>>>> http://groups.google.com/group/phonegap?hl=en?hl=en
>>>>
>>>> For more info on PhoneGap or to download the code go to www.phonegap.com
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "phonegap" group.
>>> To post to this group, send email to phon...@googlegroups.com
>>> To unsubscribe from this group, send email to

>>> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>


>>> For more options, visit this group at
>>> http://groups.google.com/group/phonegap?hl=en?hl=en
>>>
>>> For more info on PhoneGap or to download the code go to www.phonegap.com
>>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "phonegap" group.
>> To post to this group, send email to phon...@googlegroups.com
>> To unsubscribe from this group, send email to

>> phonegap+u...@googlegroups.com<phonegap%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages