Skip to content

Commit 20d0659

Browse files
when widget is about to be shown it should not animate slide down
1 parent b425a04 commit 20d0659

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

packages/core/src/js/feedback/FeedbackWidgetManager.tsx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { logger } from '@sentry/core';
22
import * as React from 'react';
3-
import { Animated, Dimensions, KeyboardAvoidingView, Modal, PanResponder, Platform } from 'react-native';
3+
import { Animated, Dimensions, Easing, KeyboardAvoidingView, Modal, PanResponder, Platform } from 'react-native';
44

55
import { FeedbackWidget } from './FeedbackWidget';
66
import { modalBackground, modalSheetContainer, modalWrapper } from './FeedbackWidget.styles';
@@ -10,7 +10,7 @@ import { isModalSupported } from './utils';
1010

1111
const PULL_DOWN_CLOSE_THREESHOLD = 200;
1212
const PULL_DOWN_ANDROID_ACTIVATION_HEIGHT = 150;
13-
const SLIDE_ANIMATION_DURATION = 150;
13+
const SLIDE_ANIMATION_DURATION = 200;
1414
const BACKGROUND_ANIMATION_DURATION = 200;
1515

1616
class FeedbackWidgetManager {
@@ -104,11 +104,13 @@ class FeedbackWidgetProvider extends React.Component<FeedbackWidgetProviderProps
104104
toValue: 1,
105105
duration: BACKGROUND_ANIMATION_DURATION,
106106
useNativeDriver: true,
107+
easing: Easing.in(Easing.quad),
107108
}),
108109
Animated.timing(this.state.panY, {
109110
toValue: 0,
110111
duration: SLIDE_ANIMATION_DURATION,
111112
useNativeDriver: true,
113+
easing: Easing.in(Easing.quad),
112114
})
113115
]).start(() => {
114116
logger.info('FeedbackWidgetProvider componentDidUpdate');
@@ -164,22 +166,31 @@ class FeedbackWidgetProvider extends React.Component<FeedbackWidgetProviderProps
164166
}
165167

166168
private _setVisibilityFunction = (visible: boolean): void => {
167-
Animated.parallel([
168-
Animated.timing(this.state.panY, {
169-
toValue: Dimensions.get('screen').height,
170-
duration: SLIDE_ANIMATION_DURATION,
171-
useNativeDriver: true,
172-
}),
173-
Animated.timing(this.state.backgroundOpacity, {
174-
toValue: 0,
175-
duration: BACKGROUND_ANIMATION_DURATION,
176-
useNativeDriver: true,
177-
})
178-
]).start(() => {
179-
// Change of the state unmount the component
180-
// which would cancel the animation
169+
const updateState = (): void => {
181170
this.setState({ isVisible: visible });
182-
});
171+
};
172+
if (!visible) {
173+
Animated.parallel([
174+
Animated.timing(this.state.panY, {
175+
toValue: Dimensions.get('screen').height,
176+
duration: SLIDE_ANIMATION_DURATION,
177+
useNativeDriver: true,
178+
easing: Easing.out(Easing.quad),
179+
}),
180+
Animated.timing(this.state.backgroundOpacity, {
181+
toValue: 0,
182+
duration: BACKGROUND_ANIMATION_DURATION,
183+
useNativeDriver: true,
184+
easing: Easing.out(Easing.quad),
185+
})
186+
]).start(() => {
187+
// Change of the state unmount the component
188+
// which would cancel the animation
189+
updateState();
190+
});
191+
} else {
192+
updateState();
193+
}
183194
};
184195

185196
private _handleClose = (): void => {

0 commit comments

Comments
 (0)