iPad Gestures: Magazine-style Page Swipes, etc...

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
digitalcargo
Posts: 2
Joined: Thu Jun 02, 2011 7:00 pm

iPad Gestures: Magazine-style Page Swipes, etc...

Post by digitalcargo » Fri Jun 03, 2011 7:05 pm

Hi, all.

I'm just getting started with LiveCode and very excited about the possibilities for iPad apps. I'm specifically looking to swipe from card to card (both horizontally and vertically, if possible) as is done in most iPad magazine apps to navigate from page to page.

I found "visual effect push right fast" which is pretty close, but there isn't any "snappiness" to it. Perhaps done with tweening...?

Also, is there a specific library available for iOS gestures? I'm sure I'll be looking for more of them, too.

Many thanks in advance.

Digitalcargo

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: iPad Gestures: Magazine-style Page Swipes, etc...

Post by Mark » Sun Jun 05, 2011 1:33 am

Hi,

I think there are some visual effects that you can use. Really ought to read the manual.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: iPad Gestures: Magazine-style Page Swipes, etc...

Post by jacque » Sun Jun 05, 2011 6:28 am

Yes, you can do it. You need to use a touchStart handler to store the initial touch location. Then in a touchEnd handler, compare the current location with the stored one. If the horizontal direction is more than so-many pixels (I've seen 10 as an example, but you may want more) then it is considered a swipe. At that point you use the "push left" or "push right" visual effects to move to the next card.

Here is a slightly modified excerpt from the teaching stack we used at the recent RevLive conference. It uses "mouse" handlers instead of "touch" handlers, mostly because they work on both desktop and mobile. You could use either one.

Code: Select all

## Handlers to detect swipe gestures

local hStart,hEnd,vStart
   
on mouseDown   
   # store coords for comparison in mouseUp later:
   put the clickH into hStart
   put the clickH into hEnd
   put the clickV into vStart
end mouseDown

on mouseMove x, y
   put x into hEnd
end mouseMove

on mouseRelease
   mouseUp
end mouseRelease

on mouseUp
   put hEnd - hStart into tDifference
   if tDifference > 10 then
      ## Swipe right
      -- change cards here with "push right"
   else if tDifference < -10 then then
      ## Swipe left
      -- change cards with "push left"
   else
      ## Tap
     -- if you need a tap gesture, the action goes here
   end if
end mouseUp
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

digitalcargo
Posts: 2
Joined: Thu Jun 02, 2011 7:00 pm

Re: iPad Gestures: Magazine-style Page Swipes, etc...

Post by digitalcargo » Sun Jun 05, 2011 6:07 pm

Thanks, Jacqueline! I'll give that a try... looks like exactly what I need.

digitalcargo

Post Reply