diff --git a/index.d.ts b/index.d.ts index dcd7d90..9b16f7b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -31,6 +31,7 @@ declare module 'react-native-switch' { switchWidthMultiplier?: number; switchBorderRadius?: number; testID?: string; + useNativeDriver?: boolean; } export class Switch extends Component {} diff --git a/lib/Switch.js b/lib/Switch.js index e11575f..6803e76 100644 --- a/lib/Switch.js +++ b/lib/Switch.js @@ -1,12 +1,9 @@ import React, { Component } from "react"; import { - View, Text, StyleSheet, Animated, - PanResponder, TouchableWithoutFeedback, - ViewPropTypes } from "react-native"; import PropTypes from "prop-types"; @@ -39,7 +36,8 @@ export class Switch extends Component { switchLeftPx: PropTypes.number, switchRightPx: PropTypes.number, switchWidthMultiplier: PropTypes.number, - switchBorderRadius: PropTypes.number + switchBorderRadius: PropTypes.number, + useNativeDriver: PropTypes.bool }; static defaultProps = { @@ -68,6 +66,7 @@ export class Switch extends Component { switchRightPx: 2, switchWidthMultiplier: 2, switchBorderRadius: null, + useNativeDriver: false, testID: null }; @@ -131,22 +130,22 @@ export class Switch extends Component { toValue: value ? this.props.circleSize / this.props.switchLeftPx : -this.props.circleSize / this.props.switchRightPx, - useNativeDriver: false + useNativeDriver: this.props.useNativeDriver }), Animated.timing(this.state.backgroundColor, { toValue: value ? 75 : -75, duration: 200, - useNativeDriver: false + useNativeDriver: this.props.useNativeDriver }), Animated.timing(this.state.circleColor, { toValue: value ? 75 : -75, duration: 200, - useNativeDriver: false + useNativeDriver: this.props.useNativeDriver }), Animated.timing(this.state.circleBorderColor, { toValue: value ? 75 : -75, duration: 200, - useNativeDriver: false + useNativeDriver: this.props.useNativeDriver }) ]).start(cb); };