Skip to content

Commit

Permalink
fix(Sheet): remove animation lags when closing in some browsers (#1984)
Browse files Browse the repository at this point in the history
  • Loading branch information
mournfulCoroner authored Dec 11, 2024
1 parent 7a6f596 commit 555b186
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/components/Sheet/SheetContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ACCELERATION_Y_MAX = 0.08;
const ACCELERATION_Y_MIN = -0.02;
// 90% from viewport
const MAX_CONTENT_HEIGHT_FROM_VIEWPORT_COEFFICIENT = 0.9;
const WINDOW_RESIZE_TIMEOUT = 25;
const WINDOW_RESIZE_TIMEOUT = 50;

let hashHistory: string[] = [];

Expand Down Expand Up @@ -123,21 +123,14 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
render() {
const {content, contentClassName, swipeAreaClassName, hideTopBar, title} = this.props;

const {
deltaY,
swipeAreaTouched,
contentTouched,
veilTouched,
isAnimating,
inWindowResizeScope,
} = this.state;
const {deltaY, swipeAreaTouched, contentTouched, veilTouched, isAnimating} = this.state;

const veilTransitionMod = {
'with-transition': !deltaY || veilTouched,
};

const sheetTransitionMod = {
'with-transition': !inWindowResizeScope && veilTransitionMod['with-transition'],
'with-transition': veilTransitionMod['with-transition'],
};

const contentMod = {
Expand Down Expand Up @@ -416,6 +409,10 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
};

private onResizeWindow = () => {
if (this.state.isAnimating) {
return;
}

this.setState({inWindowResizeScope: true});

if (this.resizeWindowTimer) {
Expand Down

0 comments on commit 555b186

Please sign in to comment.