Skip to content
Merged
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
11 changes: 9 additions & 2 deletions src/components/CheckboxAndroid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type State = {
scaleAnim: Animated.Value;
};

// From https://material.io/design/motion/speed.html#duration
const ANIMATION_DURATION = 100;

/**
* Checkboxes allow the selection of multiple options from a set.
* This component follows platform guidelines for Android.
Expand Down Expand Up @@ -65,14 +68,18 @@ class CheckboxAndroid extends React.Component<Props, State> {
}

const checked = this.props.status === 'checked';
const { animation } = this.props.theme;

Animated.sequence([
Animated.timing(this.state.scaleAnim, {
toValue: 0.85,
duration: checked ? 200 : 0,
duration: checked ? ANIMATION_DURATION * animation.scale : 0,
}),
Animated.timing(this.state.scaleAnim, {
toValue: 1,
duration: checked ? 200 : 350,
duration: checked
? ANIMATION_DURATION * animation.scale
: ANIMATION_DURATION * animation.scale * 1.75,
}),
]).start();
}
Expand Down