Skip to content

Commit

Permalink
fix: remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mournfulCoroner committed Dec 11, 2024
1 parent 63677b1 commit 1c7d2a0
Showing 1 changed file with 5 additions and 43 deletions.
48 changes: 5 additions & 43 deletions src/components/Sheet/SheetContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import React from 'react';

import debounce from 'lodash/debounce';

import {Platform, withMobile} from '../mobile';
import type {History, Location, MobileContextProps} from '../mobile';

Expand Down Expand Up @@ -78,12 +76,6 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
observer: ResizeObserver | null = null;
resizeWindowTimer: number | null = null;

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

textLog = '';

state: SheetContentState = {
startScrollTop: 0,
startY: 0,
Expand All @@ -96,14 +88,9 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
inWindowResizeScope: false,
};

debouncedOnResize = debounce(() => this.onResize(), WINDOW_RESIZE_TIMEOUT);

componentDidMount() {
this.addListeners();
this.show();
// this.needHide = false;
// this.isResizing = false;
// this.isMounted = true;

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

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

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

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

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

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

private hide = () => {
// this.textLog += 'hide there\n';
this.setState({isAnimating: true}, () => {
this.setStyles({status: 'hiding'});
this.removeHash();
Expand Down Expand Up @@ -363,15 +346,13 @@ 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 @@ -407,15 +388,8 @@ class SheetContent extends React.Component<SheetContentInnerProps, SheetContentS
};

private onVeilClick = () => {
// 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';
};

private onVeilTransitionEnd = () => {
Expand All @@ -435,35 +409,29 @@ 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`;
if (this.state.isAnimating) {
return;
}

this.setState({inWindowResizeScope: true});

if (this.resizeWindowTimer) {
window.clearTimeout(this.resizeWindowTimer);
}

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

this.debouncedOnResize();
this.resizeWindowTimer = window.setTimeout(() => {
this.onResize();
}, WINDOW_RESIZE_TIMEOUT);
};

private onResize = () => {
if (!this.sheetRef.current || !this.sheetScrollContainerRef.current) {
return;
}

// this.isResizing = true;

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

const sheetContentHeight = this.sheetContentHeight;

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

Expand All @@ -476,13 +444,7 @@ 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.setState({prevSheetHeight: sheetContentHeight, inWindowResizeScope: false});
};

private addListeners() {
Expand Down

0 comments on commit 1c7d2a0

Please sign in to comment.