From e2cce0cd43ddff41111c641d13f6a53935579732 Mon Sep 17 00:00:00 2001 From: Philipp Eschenbach Date: Sun, 7 Nov 2021 13:04:46 +0100 Subject: [PATCH 1/2] fix #93 add a new prop to define whether or not to use nativeDriver --- lib/Switch.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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); }; From 78d5a51441b69d93c17586c6794b86de49e7902a Mon Sep 17 00:00:00 2001 From: Philipp Eschenbach Date: Mon, 22 Nov 2021 09:28:32 +0100 Subject: [PATCH 2/2] Update index.d.ts add missing attribute --- index.d.ts | 1 + 1 file changed, 1 insertion(+) 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 {}