Gestures

Gesture recognizers can be added to any visual element.

Tap Gestures

The tap gesture is used for tap detection. For example, here is a TapGestureRecognizer:

View.Frame(
    hasShadow = true,
    gestureRecognizers = [ View.TapGestureRecognizer(command=(fun () -> dispatch FrameTapped)) ]
)

See also:

Pan Gestures

The pan gesture is used for detecting dragging. A common scenario for the pan gesture is to horizontally and vertically drag an image, so that all of the image content can be viewed when it’s being displayed in a viewport smaller than the image dimensions. This is accomplished by moving the image within the viewport, and is demonstrated in this article.

Here is an example of a PanGestureRecognizer used to recognize panning touch movements:

View.Frame(
    hasShadow = true,
    gestureRecognizers = [
        View.PanGestureRecognizer(touchPoints=1, panUpdated=(fun panArgs ->
                if panArgs.StatusType = GestureStatus.Running then
                    dispatch (PanGesture panArgs)))
    ]
)

See also:

Pinch Gestures

The pinch gesture is used for performing interactive zoom. A common scenario for the pinch gesture is to perform interactive zoom of an image at the pinch location. This is accomplished by scaling the content of the viewport, and is demonstrated in this article.

Here is an example of a PinchGestureRecognizer used to recognize pinch-or-expand touch movements:

View.Frame(
    hasShadow=true,
    gestureRecognizers= [
        View.PinchGestureRecognizer(pinchUpdated=(fun pinchArgs ->
            dispatch (UpdateSize (pinchArgs.Scale, pinchArgs.Status))))
    ]
)

See also: