Skip to content

Commit

Permalink
Revert "fix: comment extra code"
Browse files Browse the repository at this point in the history
This reverts commit 848c35f.
  • Loading branch information
mournfulCoroner committed Dec 10, 2024
1 parent 52f9821 commit 1921817
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions src/components/Sheet/SheetContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
observer: ResizeObserver | null = null;
resizeWindowTimer: number | null = null;

// isMounted = false;
// isResizing = false;
// needHide = false;
isMounted = false;
isResizing = false;
needHide = false;

// textLog = '';
textLog = '';

state: SheetContentState = {
startScrollTop: 0,
Expand All @@ -101,9 +101,9 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
componentDidMount() {
this.addListeners();
this.show();
// this.needHide = false;
// this.isResizing = false;
// this.isMounted = true;
this.needHide = false;
this.isResizing = false;
this.isMounted = true;

const initialHeight = this.getAvailableContentHeight(this.sheetContentHeight);

Expand All @@ -121,7 +121,7 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
}

if ((prevProps.visible && !visible) || this.shouldClose(prevProps)) {
// this.textLog += 'componentDidupdate';
this.textLog += 'componentDidupdate';
this.hide();
}

Expand All @@ -132,8 +132,8 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS

componentWillUnmount() {
this.removeListeners();
// this.isMounted = false;
// alert(this.textLog);
this.isMounted = false;
alert(this.textLog);
}

render() {
Expand Down Expand Up @@ -276,7 +276,7 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
};

private hide = () => {
// this.textLog += 'hide there\n';
this.textLog += 'hide there\n';
this.setState({isAnimating: true}, () => {
this.setStyles({status: 'hiding'});
this.removeHash();
Expand Down Expand Up @@ -363,13 +363,15 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
const accelerationY = this.velocityTracker.getYAcceleration();

if (this.sheetHeight <= deltaY) {
alert('< delte hide sheet');
this.props.hideSheet();
} else if (
(deltaY > HIDE_THRESHOLD &&
accelerationY <= ACCELERATION_Y_MAX &&
accelerationY >= ACCELERATION_Y_MIN) ||
accelerationY > ACCELERATION_Y_MAX
) {
alert('> delte hide');
this.hide();
} else if (deltaY !== 0) {
this.show();
Expand Down Expand Up @@ -405,15 +407,15 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
};

private onVeilClick = () => {
// this.textLog += `${this.isResizing} is resizing\n`;
// if (this.isResizing) {
// this.needHide = true;
// return;
// }
this.textLog += `${this.isResizing} is resizing\n`;
if (this.isResizing) {
this.needHide = true;
return;
}
this.setState({veilTouched: true});
this.hide();

// this.textLog += 'veil touched hide\n';
this.textLog += 'veil touched hide\n';
};

private onVeilTransitionEnd = () => {
Expand All @@ -433,8 +435,8 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
};

private onResizeWindow = () => {
// this.textLog += `${this.state.veilTouched} this.state.veilTouched\n`;
// this.textLog += `${this.isMounted} this.state.inWindowResizeScope\n`;
this.textLog += `${this.state.veilTouched} this.state.veilTouched\n`;
this.textLog += `${this.isMounted} this.state.inWindowResizeScope\n`;
if (this.state.veilTouched) {
return;
}
Expand All @@ -444,7 +446,7 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
window.clearTimeout(this.resizeWindowTimer);
}

// this.textLog += 'onResizeWindow\n';
this.textLog += 'onResizeWindow\n';

this.debouncedOnResize();
};
Expand All @@ -454,14 +456,14 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
return;
}

// this.isResizing = true;
this.isResizing = true;

// this.textLog += 'onResize\n';
this.textLog += 'onResize\n';

const sheetContentHeight = this.sheetContentHeight;

if (sheetContentHeight === this.state.prevSheetHeight && !this.state.inWindowResizeScope) {
// this.isResizing = false;
this.isResizing = false;
return;
}

Expand All @@ -475,11 +477,11 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
this.sheetScrollContainerRef.current.style.height = `${availableContentHeight}px`;
this.sheetRef.current.style.transform = `translate3d(0, -${availableContentHeight + this.sheetTopHeight}px, 0)`;
this.setState({prevSheetHeight: sheetContentHeight, inWindowResizeScope: false}, () => {
// this.isResizing = false;
// if (this.needHide) {
// this.textLog += 'needHide\n';
// this.onVeilClick();
// }
this.isResizing = false;
if (this.needHide) {
this.textLog += 'needHide\n';
this.onVeilClick();
}
});
};

Expand Down

0 comments on commit 1921817

Please sign in to comment.