Code Help for Swiping between cards

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
cbeethjr
Posts: 3
Joined: Mon Mar 20, 2017 6:53 pm

Code Help for Swiping between cards

Post by cbeethjr » Wed Apr 26, 2017 6:20 pm

Hey y'all,

Still a complete beginner in terms of coding and I'm having some trouble figuring out how to swipe between cards. I would like to be able to touch anywhere except for a border along the top and bottom and be able to swipe left or right. Any code or help is greatly appreciated!

Thanks,
Clanton

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: Code Help for Swiping between cards

Post by ittarter » Sat Apr 29, 2017 2:49 pm

Hey,

Is this what you're looking for?

Code: Select all

global sStartH
on mouseDown
   put the mouseH into sStartH
end mouseDown

on mouseUp
   if abs(the mouseH - sStartH) > 50 then
       if the mouseH < sStartH then
           goNext
       else
           goPrev
       end if
   end if
end mouseUp

command goNext
   go next cd
end goNext

command goPrev
   go prev cd
end goPrev
Let me know if it works as I'd like to use it myself when I modify my app to be compatible with touchscreen.

Regards,

Ivan

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Code Help for Swiping between cards

Post by MaxV » Wed May 10, 2017 8:44 pm

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply