Vertical scrolling and horizontal swipe in one field?

Moderators: LCNeil, heatherlaine, kevinmiller, elanorb

Post Reply
nower
Posts: 47
Joined: Wed May 22, 2013 11:02 pm

Vertical scrolling and horizontal swipe in one field?

Post by nower » Mon Mar 24, 2014 2:49 am

Is it possible to control both vertical scrolling for a text that's longer than the current screen, and horizontal swipe to put the next text into the same field (assuming I have a list of texts I want to switch between, and each one can be more than one screen)?
The issue I see is that it seems the horizontal swipe should occur at the end of the touch gesture, while the vertical scroll should occur while the gesture is still continuing.

My stack works for the horizontal swipe by taking action at the touchEnd event if the gesture was left or right, but I am not sure how I can combine that with handling a scroll up or down. Especially as both gestures might not be completely straight but contain a bit of movement into the other direction. For example, the gesture for vertical scroll might contain a bit of horizontal movement.

Can you point to any example for supporting both gestures for the same field/card? I have seen examples for scroll, or pinch or zoom, but not the combination I am trying to implement.

Thanks,
Werner

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Vertical scrolling and horizontal swipe in one field?

Post by LCNeil » Mon Mar 24, 2014 4:02 pm

Hi Werner,
swipe andscroll.livecode.zip
(2.32 KiB) Downloaded 142 times
Please find attached a quick sample stack that I put together that incorporates the swipe gestures found in the the livecode stock check application here-

http://lessons.runrev.com/s/3527/m/4069 ... r-the-ipad

and the native scroller explained here-

http://lessons.runrev.com/s/3527/m/4069 ... ll-a-field

In my sample stack, a swipe left to right or right to left places the contents of the lower fields into the upper most field. The ability to scroll the upper field vertically is still possible as a native scroller has been created for this purpose.

Is this the behaviour that you are wishing to occur?

In regards to pinch to zoom and scrolling, there have been a few LiveCode users attempt such a functionality and the solution that users seem happy with is with the use of a native mobile browser that loads a document from a local directory (e.g. engine or documents folder). A forum post, with example script, can be found here-

http://forums.runrev.com/viewtopic.php?f=49&t=11229

A native browser has the in-built ability of panning and pinch to zoom, so no direct scripting would be needed for such a feature.

I hope the above gives you some leads.

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

nower
Posts: 47
Joined: Wed May 22, 2013 11:02 pm

Re: Vertical scrolling and horizontal swipe in one field?

Post by nower » Sun Mar 30, 2014 4:00 pm

Hi Neil,

thank you for your response and the sample stack.

I finally got around to trying to incorporate it into my app, and I am having issues with the native scroller. The touch gestures already worked before adding the native scroller.

My tests are primarily on the Android simulator, using LC 6.5.2 and an AVD with Android 4.1.2.
I have also done a few tests on an iPhone simulator, and the issues are the same.

Here are the issues I am having:
- The scrollerDidScroll method does not get activated each time a scroll gesture is done. Sometimes it takes several attempts, sometimes only one, very irregular. I don't change the way I do the gesture.
- Debug code shows that the vOffset passed to the scrollerDidScroll method is always 44 (when it registers at all). It doesn't matter how long my gesture is, and whether it is up or down or left or right, vOffset is always 44.
- When scrolling works at all, I can only scroll down, never back up. Which is logical, as the vOffset is always 44, and never negative.
- hOffset has different values, but they are very rarely negative, no matter whether I scroll from left to right or right to left.
- Sometimes the native scroller seems to interfere with the swipe gestures to move between texts. I haven't found a clear pattern when it does and when not.

As some kind of workaround, I am now handling all gestures in touchEnd, even though that means handling the scrolling after the gesture ends.
I don't know whether that might get me in trouble when submitting the app to the app stores, as it is not really a native scrolling.

Any insights into these odd behaviors of the native scroller? Do you want me to send you my app to have a look?

Thank you,
Werner

Post Reply

Return to “idea2app and Coding School”