How can we use HypeGesturePhaseCancel

Are there any examples of using the GesturePhaseCancel option in Hype? I looked at a posting at the regular Hype forum that has a sample script…

if (event[‘hypeGesturePhase’] == hypeDocument.kHypeGesturePhaseEnd || event[‘hypeGesturePhase’] == hypeDocument.kHypeGesturePhaseCancel) {
hypeDocument.startTimelineNamed(‘Restore Position’);

but it seems to works just as well if you leave out the…

|| event[‘hypeGesturePhase’] == hypeDocument.kHypeGesturePhaseCancel

part of the script.

Is hypeDocument.kHypeGesturePhaseCancel the same as hypeDocument.kHypeGesturePhaseEnd? How can we cancel a drag?

I’m confused :blush:

this is working for playing another timeline at the end:

if (event['hypeGesturePhase'] == hypeDocument.kHypeGesturePhaseStart) {hypeDocument.playTimelineNamed("brachio");} else if (event['hypeGesturePhase'] == hypeDocument.kHypeGesturePhaseEnd) {hypeDocument.playTimelineNamed("brachio_out");}
1 Like

Thanks, that is useful.

I don’t really get what it is for… Any practical example ?

My understanding is that hypeDocument.kHypeGesturePhaseEnd occurs when a touchend event was detected (the finger was released from the element being dragged) and hypeDocument.kHypeGesturePhaseCancel occurs when another event interrupts the drag but a specific finger gesture wasn’t the cause.

The Cancel event occurs when you attempt to drag an element out of an iframe.

Listening for both events is smart because it covers all your bases – either the gesture has been intentionally exited, or something weird (like Mobile Safari detecting the beginning of a Swipe from the left, which it think means you want to go ‘Back’) has occurred.

1 Like

Ah, that helps, thanks Daniel.