NativeScript gesture state name to corresponding number

Issue

I want to use gestures in my nativescript-angular app. When I log this:

console.log("Pinch scale: " + args.scale + " state: " + args.state);

args.state gives me numbers (1,2,3), but in the docs they referred to names such as: began or cancelled. Waht is the corresponding name to each number?

Solution

GestureStateTypes are defined like this

export enum GestureStateTypes {
    /**
     * Gesture canceled.
     */
    cancelled,
    /**
     * Gesture began.
     */
    began,
    /**
     * Gesture changed.
     */
    changed,
    /**
     * Gesture ended.
     */
    ended
}

As per enum nature in TS first elemnet will auto assigned 0 if it is not assigned any value and then it will be auto incremented .

so final result will be cancelled=0,began=1,changed=2 and ended=3. but you should avoid directly checking to its value like args.state==1 and instead should use args.state==GestureStateTypes.began.

Answered By – bhavin jalodara

Answer Checked By – Senaida (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.