import { Component } from 'react';
const kOnPressDelayMS = 200;
export class TouchableDelay extends Component {
    constructor() {
        super(...arguments);
        this.handleScroll = (event) => {
            if (this.onPressDelayTimer) {
                clearTimeout(this.onPressDelayTimer);
                this.onPressDelayTimer = null;
                window.removeEventListener('scroll', this.handleScroll);
            }
        };
        this.handleOnPress = (event) => {
            const { onPress } = this.props;
            if (onPress) {
                if (!this.onPressDelayTimer) {
                    window.addEventListener('scroll', this.handleScroll);
                    this.onPressDelayTimer = setTimeout(() => {
                        this.onPressDelayTimer = null;
                        window.removeEventListener('scroll', this.handleScroll);
                        return onPress(event);
                    }, kOnPressDelayMS);
                }
                event.preventDefault();
            }
        };
    }
    componentWillUnmount() {
        window.removeEventListener('scroll', this.handleScroll);
    }
}
//# sourceMappingURL=TouchableDelay.web.js.map