Skip to content

Commit 53e1eca

Browse files
msagerydTrancever
authored andcommitted
fix: animation speed for checkbox on Android (#1471)
1 parent be29674 commit 53e1eca

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/CheckboxAndroid.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ type State = {
3737
scaleAnim: Animated.Value;
3838
};
3939

40+
// From https://material.io/design/motion/speed.html#duration
41+
const ANIMATION_DURATION = 100;
42+
4043
/**
4144
* Checkboxes allow the selection of multiple options from a set.
4245
* This component follows platform guidelines for Android.
@@ -65,14 +68,18 @@ class CheckboxAndroid extends React.Component<Props, State> {
6568
}
6669

6770
const checked = this.props.status === 'checked';
71+
const { animation } = this.props.theme;
72+
6873
Animated.sequence([
6974
Animated.timing(this.state.scaleAnim, {
7075
toValue: 0.85,
71-
duration: checked ? 200 : 0,
76+
duration: checked ? ANIMATION_DURATION * animation.scale : 0,
7277
}),
7378
Animated.timing(this.state.scaleAnim, {
7479
toValue: 1,
75-
duration: checked ? 200 : 350,
80+
duration: checked
81+
? ANIMATION_DURATION * animation.scale
82+
: ANIMATION_DURATION * animation.scale * 1.75,
7683
}),
7784
]).start();
7885
}

0 commit comments

Comments
 (0)