Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
const ActionButton = props => {
const [, setResetToken] = useState(props.resetToken);
const [active, setActive] = useState(props.active);
const useNativeDriver = props.useNativeDriver || false;
const anim = useRef(new Animated.Value(props.active ? 1 : 0));
const timeout = useRef(null);
const mounted = useRef(false);
Expand All @@ -35,13 +36,13 @@ const ActionButton = props => {

useEffect(() => {
if (props.active) {
Animated.spring(anim.current, { toValue: 1 }).start();
Animated.spring(anim.current, { toValue: 1, useNativeDriver }).start();
setActive(true);
setResetToken(props.resetToken);
} else {
props.onReset && props.onReset();

Animated.spring(anim.current, { toValue: 0 }).start();
Animated.spring(anim.current, { toValue: 0, useNativeDriver }).start();
timeout.current = setTimeout(() => {
setActive(false);
setResetToken(props.resetToken);
Expand Down Expand Up @@ -254,7 +255,7 @@ const ActionButton = props => {
if (active) return reset(animate);

if (animate) {
Animated.spring(anim.current, { toValue: 1 }).start();
Animated.spring(anim.current, { toValue: 1, useNativeDriver }).start();
} else {
anim.current.setValue(1);
}
Expand All @@ -266,7 +267,7 @@ const ActionButton = props => {
if (props.onReset) props.onReset();

if (animate) {
Animated.spring(anim.current, { toValue: 0 }).start();
Animated.spring(anim.current, { toValue: 0, useNativeDriver }).start();
} else {
anim.current.setValue(0);
}
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface ActionButtonProperties extends ViewProperties {
activeOpacity?: number,

useNativeFeedback?: boolean,
useNativeDriver?: boolean,
fixNativeFeedbackRadius?: boolean,
nativeFeedbackRippleColor?: string
}
Expand Down