-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TouchableOpacity] Reset opacity to the inactiveValue rather than always 1.0 #977
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
var NativeMethodsMixin = require('NativeMethodsMixin'); | ||
var POPAnimationMixin = require('POPAnimationMixin'); | ||
var StyleSheetRegistry = require('StyleSheetRegistry'); | ||
var React = require('React'); | ||
var Touchable = require('Touchable'); | ||
var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); | ||
|
@@ -105,12 +106,17 @@ var TouchableOpacity = React.createClass({ | |
}, | ||
|
||
touchableHandleActivePressOut: function() { | ||
this.setOpacityTo(1.0); | ||
var childStyle = this.refs[CHILD_REF].props.style; | ||
|
||
if (typeof childStyle === 'number') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You want to use |
||
childStyle = StyleSheetRegistry.getStyleByID(childStyle); | ||
} | ||
|
||
this.setOpacityTo(childStyle && childStyle.opacity || 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You cannot use || here. Otherwise if opacity is set to 0, it's going to be 1. You need childStyle.opacity === undefined ? 1 : childStyle.opacity There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, that falsey 0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JavaScript ❤️ |
||
this.props.onPressOut && this.props.onPressOut(); | ||
}, | ||
|
||
touchableHandlePress: function() { | ||
this.setOpacityTo(1.0); | ||
this.props.onPress && this.props.onPress(); | ||
}, | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove