Skip to content

Commit 5a60eb2

Browse files
Noemi RozparaTrancever
authored andcommitted
feat: support animation scale in FAB, Snackbar and Banner (#1593)
1 parent e1a5f5a commit 5a60eb2

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

src/components/Banner.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,17 @@ class Banner extends React.Component<Props, State> {
147147
};
148148

149149
private show = () => {
150+
const { scale } = this.props.theme.animation;
150151
Animated.timing(this.state.position, {
151-
duration: 250,
152+
duration: 250 * scale,
152153
toValue: 1,
153154
}).start();
154155
};
155156

156157
private hide = () => {
158+
const { scale } = this.props.theme.animation;
157159
Animated.timing(this.state.position, {
158-
duration: 200,
160+
duration: 200 * scale,
159161
toValue: 0,
160162
}).start();
161163
};

src/components/FAB/FAB.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,21 @@ class FAB extends React.Component<Props, State> {
110110
};
111111

112112
componentDidUpdate(prevProps: Props) {
113+
const { scale } = this.props.theme.animation;
113114
if (this.props.visible === prevProps.visible) {
114115
return;
115116
}
116117

117118
if (this.props.visible) {
118119
Animated.timing(this.state.visibility, {
119120
toValue: 1,
120-
duration: 200,
121+
duration: 200 * scale,
121122
useNativeDriver: true,
122123
}).start();
123124
} else {
124125
Animated.timing(this.state.visibility, {
125126
toValue: 0,
126-
duration: 150,
127+
duration: 150 * scale,
127128
useNativeDriver: true,
128129
}).start();
129130
}

src/components/FAB/FABGroup.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,21 @@ class FABGroup extends React.Component<Props, State> {
152152
return;
153153
}
154154

155+
const { scale } = this.props.theme.animation;
155156
if (this.props.open) {
156157
Animated.parallel([
157158
Animated.timing(this.state.backdrop, {
158159
toValue: 1,
159-
duration: 250,
160+
duration: 250 * scale,
160161
useNativeDriver: true,
161162
}),
162163
Animated.stagger(
163-
50,
164+
50 * scale,
164165
this.state.animations
165166
.map(animation =>
166167
Animated.timing(animation, {
167168
toValue: 1,
168-
duration: 150,
169+
duration: 150 * scale,
169170
useNativeDriver: true,
170171
})
171172
)
@@ -176,13 +177,13 @@ class FABGroup extends React.Component<Props, State> {
176177
Animated.parallel([
177178
Animated.timing(this.state.backdrop, {
178179
toValue: 0,
179-
duration: 200,
180+
duration: 200 * scale,
180181
useNativeDriver: true,
181182
}),
182183
...this.state.animations.map(animation =>
183184
Animated.timing(animation, {
184185
toValue: 0,
185-
duration: 150,
186+
duration: 150 * scale,
186187
useNativeDriver: true,
187188
})
188189
),

src/components/Snackbar.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ class Snackbar extends React.Component<Props, State> {
166166
this.setState({
167167
hidden: false,
168168
});
169+
const { scale } = this.props.theme.animation;
169170
Animated.timing(this.state.opacity, {
170171
toValue: 1,
171-
duration: 200,
172+
duration: 200 * scale,
172173
useNativeDriver: true,
173174
}).start(({ finished }) => {
174175
if (finished) {
@@ -188,10 +189,10 @@ class Snackbar extends React.Component<Props, State> {
188189
if (this.hideTimeout) {
189190
clearTimeout(this.hideTimeout);
190191
}
191-
192+
const { scale } = this.props.theme.animation;
192193
Animated.timing(this.state.opacity, {
193194
toValue: 0,
194-
duration: 100,
195+
duration: 100 * scale,
195196
useNativeDriver: true,
196197
}).start(({ finished }) => {
197198
if (finished) {

0 commit comments

Comments
 (0)