NativeScript gesture state name to corresponding number


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?


GestureStateTypes are defined like this

export enum GestureStateTypes {
     * Gesture canceled.
     * Gesture began.
     * Gesture changed.
     * Gesture 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.