buttons and sliding your finger off them

You must Login before you can answer or comment on any questions.

Hey

so i have a touchstart event applied to a button - when the user presses on the button i'd like the button to change size and add a drop shadow.

however, if the user should slide their finger off the button, then i'd like the button to size back to normal. And if they were to then slide their finger back on said button, to add the drop shadow etc again.

To this end i created a touchend event, which sized the button back to normal. This combination works fine if the user merely presses on and then releases the button - but does not work if the finger slides off the button. When that happens, the touchend apparently does not fire, and the button is maintained at the enlarged size. If the user finger is released while not on the button, the button is still in the enlarged size.

Is there some sort of idiom I am meant to apply?

2 Answers

Not 100% sure of what you're trying to achieve (its been a long day and its late)

but from what I understand - you want to have two different events, the click event t detect clicks and a swipe event to detect sliding of finger

I would listen for the touchMove event and see if x/y are greater than the Button.size.height/width

— answered 8 months ago by Shannon Hicks
answer permalink
2 Comments
  • this doesn't work - the touchmove event stops firing once i leave the view that it first fired on (so touch on button, slide off button, touchmove fires until you leave the button. thereafter it is useless)

    — commented 8 months ago by lord bharal

  • I would put a listener on your button for every touch related event, and see if one fires when you need it. if touchmove stops, then I'd think touchcancel or touchend would be what you need.

    — commented 8 months ago by Shannon Hicks

Your Answer

Think you can help? Login to answer this question!