mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Send layout events on shadow queue
Summary: We currently wait until after views have been updated on the main thread before sending layout events. This means that any code that relies on those events to update the UI will lag the atual layout by at least one frame. This changes the RCTUIManager to send the event immediately after layout has occured on the shadow thread. This noticably improves the respinsiveness of the layout example in UIExplorer, which now updates the dimension labels immediately instead of waiting until after the layout animation has completed.
This commit is contained in:
@@ -85,8 +85,7 @@ var LayoutEventExample = React.createClass({
|
||||
return (
|
||||
<View style={this.state.containerStyle}>
|
||||
<Text>
|
||||
onLayout events are called on mount and whenever layout is updated,
|
||||
including after layout animations complete.{' '}
|
||||
layout events are called on mount and whenever layout is recalculated. Note that the layout event will typically be received <Text style={styles.italicText}>before</Text> the layout has updated on screen, especially when using layout animations.{' '}
|
||||
<Text style={styles.pressText} onPress={this.animateViewLayout}>
|
||||
Press here to change layout.
|
||||
</Text>
|
||||
@@ -136,6 +135,9 @@ var styles = StyleSheet.create({
|
||||
pressText: {
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
italicText: {
|
||||
fontStyle: 'italic',
|
||||
},
|
||||
});
|
||||
|
||||
exports.title = 'Layout Events';
|
||||
|
||||
Reference in New Issue
Block a user