Skip to content

Commit

Permalink
Workaround onLayout triggered constantly on some devices, fixes jeanr…
Browse files Browse the repository at this point in the history
…egisser#50

This was observed reliably on a Nexus 5X with React Native 0.31+
onLayout would be triggered constantly with slightly different width and
height for the thumb size when its position changes.
As a result it triggered a re-render constantly.
This will need to be investigated on the React Native side as it's not
an expected behavior.
  • Loading branch information
jeanregisser committed Aug 22, 2016
1 parent 15f6b42 commit fbd7e56
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,15 @@ var Slider = React.createClass({
<Animated.View
onLayout={this._measureThumb}
style={[
{backgroundColor: thumbTintColor, marginTop: -(trackSize.height + thumbSize.height) / 2},
mainStyles.thumb, thumbStyle, {left: thumbLeft, ...valueVisibleStyle}
{backgroundColor: thumbTintColor},
mainStyles.thumb, thumbStyle,
{
transform: [
{ translateX: thumbLeft },
{ translateY: -(trackSize.height + thumbSize.height) / 2 }
],
...valueVisibleStyle
}
]}
/>
<View
Expand Down

0 comments on commit fbd7e56

Please sign in to comment.