Skip to content

Commit

Permalink
Enable useNativeDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklam718 committed Mar 28, 2019
1 parent 989cd4b commit 480419f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
37 changes: 22 additions & 15 deletions src/DualShock4.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,43 @@ export default class DualShock4 extends Component {
Animated.parallel([
Animated.timing(this.cardSize.x, {
toValue: CARD_WIDTH,
duration: 200
duration: 200,
useNativeDriver: false,
}),
Animated.timing(this.cardSize.y, {
toValue: CARD_HEIGHT,
duration: 200
duration: 200,
useNativeDriver: false,
}),
Animated.spring(this.titleTranslateX, {
toValue: 0,
friction: 4.5,
tension: 0.5,
useNativeDriver: true,
}),
Animated.spring(this.imageTranslateY, {
toValue: 0,
useNativeDriver: true,
}),
Animated.timing(this.imageRotate, {
toValue: 0,
duration: 200,
useNativeDriver: true,
}),
Animated.spring(this.footerImageScale, {
toValue: 0,
useNativeDriver: true,
}),
Animated.timing(this.activeTextOpacity, {
toValue: 0,
duration: 0,
useNativeDriver: false,
}),
Animated.timing(this.previewTextOpacity, {
toValue: 1,
duration: 200,
delay: 300,
useNativeDriver: true,
}),
]).start();
});
Expand All @@ -128,46 +136,45 @@ export default class DualShock4 extends Component {
Animated.parallel([
Animated.timing(this.cardSize.x, {
toValue: DEVICE_WIDTH,
duration: 200
duration: 200,
useNativeDriver: false,
}),
Animated.timing(this.cardSize.y, {
toValue: DEVIC_HEIGHT,
duration: 200
duration: 200,
useNativeDriver: false,
}),
Animated.spring(this.titleTranslateX, {
toValue: DEVIC_HEIGHT,
// friction: 1,
// tension: 1,
// speed: 12,
friction: 4.5,
tension: 0.5,
useNativeDriver: true,
}),
Animated.spring(this.imageTranslateY, {
toValue: DEVIC_HEIGHT/2,
// friction: 4,
// tension: 15,
// speed: 1,
useNativeDriver: true,
}),
Animated.timing(this.imageRotate, {
toValue: 1,
duration: 200,
useNativeDriver: true,
}),
Animated.spring(this.footerImageScale, {
toValue: 1,
// friction: 4,
// tension: 1,
friction: 5.5,
tension: 10
// speed: 12,
tension: 10,
useNativeDriver: true,
}),
Animated.timing(this.activeTextOpacity, {
toValue: 1,
duration: 200,
delay: 300,
useNativeDriver: false,
}),
Animated.timing(this.previewTextOpacity, {
toValue: 0,
duration: 0,
useNativeDriver: true,
}),
]).start();
});
Expand Down Expand Up @@ -203,7 +210,7 @@ export default class DualShock4 extends Component {
top: 90,
position: 'absolute',
opacity: this.previewTextOpacity,
height: 40,
// height: 40,
transform: [{
translateX: this.props.scrollX.interpolate({
inputRange: this.inputRange,
Expand Down
18 changes: 15 additions & 3 deletions src/Indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ const styles = StyleSheet.create({
},
dot: {
borderRadius: 10 / 2,
margin: 6,
marginLeft: 8,
marginRight: 8,
},
dotInner: {
borderRadius: 10 / 2,
backgroundColor: '#fff',
width: 1,
height: 1,
}
});

Expand All @@ -33,9 +39,15 @@ export default function Indicator({ scrollX, count, style }) {
style={StyleSheet.flatten([
styles.dot,
{ opacity },
{ width: size, height: size },
{
transform: [{
scale: size,
}]
}
])}
/>
>
<View style={styles.dotInner} />
</Animated.View>
));
}
return (
Expand Down
2 changes: 1 addition & 1 deletion src/ProductCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class ProductCarousel extends Component {
},
],
{
useNativeDriver: false,
useNativeDriver: true,
}
)}
>
Expand Down

0 comments on commit 480419f

Please sign in to comment.