Skip to content

Commit

Permalink
fix(Sheet): fix incorrect behavior if allowHideOnContentScroll is ena…
Browse files Browse the repository at this point in the history
…bled (#2053)
  • Loading branch information
mournfulCoroner authored Jan 22, 2025
1 parent 3fdc5bb commit 3075beb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/Sheet/SheetContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ interface SheetContentState {
veilTouched: boolean;
isAnimating: boolean;
inWindowResizeScope: boolean;
delayedResize: boolean;
}

class SheetContent extends React.Component<SheetContentInnerProps, SheetContentState> {
Expand Down Expand Up @@ -86,6 +87,7 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
veilTouched: false,
isAnimating: false,
inWindowResizeScope: false,
delayedResize: false,
};

componentDidMount() {
Expand Down Expand Up @@ -333,12 +335,14 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
y: e.nativeEvent.touches[0].clientY,
});

this.setState({deltaY: delta});

// if allowHideOnContentScroll is true and delta <= 0, it's a content scroll
// animation is not needed
if (delta <= 0) {
this.setState({deltaY: 0});
return;
}

this.setState({deltaY: delta});
this.setStyles({status: 'showing', deltaHeight: delta});
};

Expand Down Expand Up @@ -397,6 +401,12 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS

if (this.veilOpacity === '0') {
this.props.hideSheet();
return;
}

if (this.state.delayedResize) {
this.onResizeWindow();
this.setState({delayedResize: false});
}
};

Expand All @@ -410,6 +420,7 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS

private onResizeWindow = () => {
if (this.state.isAnimating) {
this.setState({delayedResize: true});
return;
}

Expand Down

0 comments on commit 3075beb

Please sign in to comment.