Page 1 of 1

go to next card or previous card

Posted: Wed Jun 20, 2012 6:50 am
by prexsoccer
i have here a problem on detecting if swiping to the left will go to the next card or to the left to the right card.
and swiping down will go to a specific card.

anyone has a sample codes for this? or anyone can please help me.
let me know if you get my point or not.

thank you.
best regards
mike :)

Re: go to next card or previous card

Posted: Wed Jun 20, 2012 8:25 am
by Dixie
Mike...

Are you wanting to do this on a mobile device ?

be well

Dixie

Re: go to next card or previous card

Posted: Wed Jun 20, 2012 12:43 pm
by prexsoccer
hi dixie,

I want this to work on iPad, I need to know that im sliding down,up,left or right.

thank you for your help.

Re: go to next card or previous card

Posted: Wed Jun 20, 2012 12:58 pm
by Dixie
mike...

I have attached a stack that will help you get started... it allows you to swipe 'left & right'...

be well

Dixie

Re: go to next card or previous card

Posted: Wed Jun 20, 2012 1:37 pm
by prexsoccer
thank you for this stack dixie,
do you have down and up?

I have hard time getting down and up :(

but left and right is not that hard :)

tnx anyways :)

Re: go to next card or previous card

Posted: Wed Jun 20, 2012 2:30 pm
by sturgis
You'll need to differentiate between the 2 swipes. Dixie has shown how to get the offset (absolute value) for horizontal swipe. You'll need to do the same for the vertical movement of the swipe (item 2 of mouseloc designates y position, item 1 is x)

If you compare the 2 values to see which is larger, you'll know if its a left/right vs up/down so you can act accordingly. (You'll of course have to add a vdiff and vdiffoffset local variable) Then just modify your code so that
if abs(hdiff - hdiffoffset) > abs(vdiff - vdiffoffset) then
--code for left right swipe goes here
else
-- code for up/down swipe goes here
end if

Re: go to next card or previous card

Posted: Wed Jun 20, 2012 5:13 pm
by Dixie
Mike...

modified 'swipes' stack... left & right and up & down..

be well

Dixie

Re: go to next card or previous card

Posted: Wed Jun 20, 2012 8:05 pm
by sturgis
Hmm. I can't seem to get it to work. The code is cool. (I can modify it to use mouse events and swipe on the desktop to my hearts content) My kindle just says no! In fact just putting "go next card" in a button isn't working on the kindle fire either.

On the desktop I moved some things around and did the check for which offset is greater (because i'm a clumsy swiper and can get 2 card switches to fire with a single swipe... I'm just that good)

Any clue at all why me and my kindle fire can't make this work? I added a field to each card, then put something into the field right before the go card line to check and make sure I didn't mess up the IF statements. Nope, value is placed in the field, card never changes. (also removed the visual affects stuff just to test) That is when I placed a button with "go next card" in it (all by its lonesome) and still can't get the kf to jump cards.
Dixie wrote:Mike...

modified 'swipes' stack... left & right and up & down..

be well

Dixie

Re: go to next card or previous card

Posted: Wed Jun 20, 2012 8:22 pm
by Dixie
Sturgis...

I'm afraid I can't help you as I only use the iphone simulator and an iphone... the 'swipes' work well both in the sim and on the device.

be well

Dixie

Re: go to next card or previous card

Posted: Wed Jun 20, 2012 8:43 pm
by sturgis
Hmm. Surely there is something i'm doing wrong since I can't get a card switch to occur from a simple button press. Must be nap time! (sleep fixes everything)
Dixie wrote:Sturgis...

I'm afraid I can't help you as I only use the iphone simulator and an iphone... the 'swipes' work well both in the sim and on the device.

be well

Dixie

Re: go to next card or previous card

Posted: Thu Jun 21, 2012 1:31 am
by prexsoccer
hi dixie,

thank you for this stack, I till try it now. hope this will work :)

thank you very much for the help.

Re: go to next card or previous card

Posted: Thu Jun 21, 2012 3:25 am
by prexsoccer
I have problem on the stack,

if flips 2 card in one swipe. did i mess something up?

give me a quote please :)

gracias :D

Re: go to next card or previous card

Posted: Thu Jun 21, 2012 12:19 pm
by Dixie
prexsoccer...

There are three cars in the stack... The numbers 1, 2 or 3 are displayed in the middle of the card... however, when you get to the third card (3), you will then be taken to card 1 (1).. so perhaps that is why you say it is 'flipping' two cards...:-)

be well

Dixie