UNPKG

react-native-gesture-handler

Version:

Declarative API exposing native platform touch and gesture system to React Native

38 lines (37 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PressableStateMachine = void 0; class PressableStateMachine { constructor(steps) { this.states = steps; this.currentStepIndex = 0; this.eventPayload = null; } reset() { this.currentStepIndex = 0; this.eventPayload = null; } handleEvent(eventName, eventPayload) { const step = this.states[this.currentStepIndex]; this.eventPayload = eventPayload || this.eventPayload; if (step.eventName !== eventName) { if (this.currentStepIndex > 0) { // retry with position at index 0 this.reset(); this.handleEvent(eventName, eventPayload); } return; } if (this.eventPayload && step.callback) { step.callback(this.eventPayload); } this.currentStepIndex++; if (this.currentStepIndex === this.states.length) { this.reset(); } } } exports.PressableStateMachine = PressableStateMachine; //# sourceMappingURL=StateMachine.js.map