Skip to content

Commit

Permalink
Revert "fix: add additional check before running animate in `compon…
Browse files Browse the repository at this point in the history
…entDidUpdate` (#10871)"

This reverts commit b9fb2d1.
  • Loading branch information
kacperkapusciak committed Oct 27, 2022
1 parent a2e5f45 commit 7d8f748
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions packages/stack/src/views/Stack/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ type Props = ViewProps & {
contentStyle?: StyleProp<ViewStyle>;
};

type State = {
pointerEvents: ViewProps['pointerEvents'];
};

const GESTURE_VELOCITY_IMPACT = 0.3;

const TRUE = 1;
Expand All @@ -93,7 +89,7 @@ const hasOpacityStyle = (style: any) => {
return false;
};

export default class Card extends React.Component<Props, State> {
export default class Card extends React.Component<Props> {
static defaultProps = {
shadowEnabled: false,
gestureEnabled: true,
Expand All @@ -108,10 +104,6 @@ export default class Card extends React.Component<Props, State> {
) : null,
};

state: State = {
pointerEvents: 'auto',
};

componentDidMount() {
this.animate({ closing: this.props.closing });
this.isCurrentlyMounted = true;
Expand All @@ -136,12 +128,11 @@ export default class Card extends React.Component<Props, State> {
const toValue = this.getAnimateToValue(this.props);

if (
closing !== prevProps.closing &&
(this.getAnimateToValue(prevProps) !== toValue ||
this.lastToValue !== toValue)
this.getAnimateToValue(prevProps) !== toValue ||
this.lastToValue !== toValue
) {
// We need to trigger the animation when route was closed
// The route might have been closed by a `POP` action or by a gesture
// Thr route might have been closed by a `POP` action or by a gesture
// When route was closed due to a gesture, the animation would've happened already
// It's still important to trigger the animation so that `onClose` is called
// If `onClose` is not called, cleanup step won't be performed for gestures
Expand Down Expand Up @@ -251,7 +242,7 @@ export default class Card extends React.Component<Props, State> {
private setPointerEventsEnabled = (enabled: boolean) => {
const pointerEvents = enabled ? 'box-none' : 'none';

this.setState({ pointerEvents });
this.contentRef.current?.setNativeProps({ pointerEvents });
};

private handleStartInteraction = () => {
Expand Down Expand Up @@ -434,6 +425,8 @@ export default class Card extends React.Component<Props, State> {
}
}

private contentRef = React.createRef<View>();

render() {
const {
styleInterpolator,
Expand Down Expand Up @@ -562,7 +555,7 @@ export default class Card extends React.Component<Props, State> {
/>
) : null}
<CardSheet
pointerEvents={this.state.pointerEvents}
ref={this.contentRef}
enabled={pageOverflowEnabled}
layout={layout}
style={contentStyle}
Expand Down

0 comments on commit 7d8f748

Please sign in to comment.