touchable-scale-btk
Version:
touchable scale with double tab safe property
26 lines (23 loc) • 614 B
JavaScript
import React, { Component } from 'react';
import TS from './ts.js';
class PreventDoubleTap extends Component {
disabled = false;
onPress = (...args) => {
if(this.disabled) return;
this.disabled = true;
setTimeout(()=>{
this.disabled = false;
}, 1000);
this.props.onPress && this.props.onPress(...args);
}
}
export default class TouchableScale extends PreventDoubleTap {
render() {
return (
<TS
{...this.props}
onPress={this.onPress}
/>
);
}
}