mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-29 17:12:37 +00:00
[fix] Touchable to avoid touch delay
According to MDN, "touch-action:manipulation" enables "…panning and pinch zoom gestures, but disables additional non-standard gestures such as double-tap to zoom. Disabling double-tap to zoom removes the need for browsers to delay the generation of click events when the user taps the screen."
This commit is contained in:
@@ -263,7 +263,7 @@ const TouchableHighlight = createReactClass({
|
|||||||
onResponderTerminationRequest={this.touchableHandleResponderTerminationRequest}
|
onResponderTerminationRequest={this.touchableHandleResponderTerminationRequest}
|
||||||
onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
|
onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
|
||||||
ref={this._setUnderlayRef}
|
ref={this._setUnderlayRef}
|
||||||
style={[styles.root, this.props.disabled && styles.disabled, this.state.underlayStyle]}
|
style={[styles.root, !this.props.disabled && styles.actionable, this.state.underlayStyle]}
|
||||||
>
|
>
|
||||||
{React.cloneElement(React.Children.only(this.props.children), {
|
{React.cloneElement(React.Children.only(this.props.children), {
|
||||||
ref: this._setChildRef
|
ref: this._setChildRef
|
||||||
@@ -283,11 +283,11 @@ const INACTIVE_UNDERLAY_PROPS = {
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
root: {
|
root: {
|
||||||
cursor: 'pointer',
|
|
||||||
userSelect: 'none'
|
userSelect: 'none'
|
||||||
},
|
},
|
||||||
disabled: {
|
actionable: {
|
||||||
cursor: 'default'
|
cursor: 'pointer',
|
||||||
|
touchAction: 'manipulate'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ const TouchableOpacity = createReactClass({
|
|||||||
onResponderTerminate={this.touchableHandleResponderTerminate}
|
onResponderTerminate={this.touchableHandleResponderTerminate}
|
||||||
onResponderTerminationRequest={this.touchableHandleResponderTerminationRequest}
|
onResponderTerminationRequest={this.touchableHandleResponderTerminationRequest}
|
||||||
onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
|
onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
|
||||||
style={[styles.root, this.props.disabled && styles.disabled, this.props.style]}
|
style={[styles.root, !this.props.disabled && styles.actionable, this.props.style]}
|
||||||
>
|
>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
{Touchable.renderDebugView({ color: 'blue', hitSlop: this.props.hitSlop })}
|
{Touchable.renderDebugView({ color: 'blue', hitSlop: this.props.hitSlop })}
|
||||||
@@ -198,13 +198,13 @@ const TouchableOpacity = createReactClass({
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
root: {
|
root: {
|
||||||
cursor: 'pointer',
|
|
||||||
transitionProperty: 'opacity',
|
transitionProperty: 'opacity',
|
||||||
transitionDuration: '0.15s',
|
transitionDuration: '0.15s',
|
||||||
userSelect: 'none'
|
userSelect: 'none'
|
||||||
},
|
},
|
||||||
disabled: {
|
actionable: {
|
||||||
cursor: 'default'
|
cursor: 'pointer',
|
||||||
|
touchAction: 'manipulate'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -179,8 +179,8 @@ const TouchableWithoutFeedback = createReactClass({
|
|||||||
}
|
}
|
||||||
const style =
|
const style =
|
||||||
Touchable.TOUCH_TARGET_DEBUG && child.type && child.type.displayName === 'Text'
|
Touchable.TOUCH_TARGET_DEBUG && child.type && child.type.displayName === 'Text'
|
||||||
? [styles.root, this.props.disabled && styles.disabled, child.props.style, { color: 'red' }]
|
? [!this.props.disabled && styles.actionable, child.props.style, { color: 'red' }]
|
||||||
: [styles.root, this.props.disabled && styles.disabled, child.props.style];
|
: [!this.props.disabled && styles.actionable, child.props.style];
|
||||||
return (React: any).cloneElement(child, {
|
return (React: any).cloneElement(child, {
|
||||||
...other,
|
...other,
|
||||||
accessible: this.props.accessible !== false,
|
accessible: this.props.accessible !== false,
|
||||||
@@ -199,11 +199,9 @@ const TouchableWithoutFeedback = createReactClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
root: {
|
actionable: {
|
||||||
cursor: 'pointer'
|
cursor: 'pointer',
|
||||||
},
|
touchAction: 'manipulate'
|
||||||
disabled: {
|
|
||||||
cursor: 'default'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user