Skip to content

Commit

Permalink
Fix incorrect detection on zooming
Browse files Browse the repository at this point in the history
  • Loading branch information
h-kanazawa committed Aug 18, 2021
1 parent 8a78a9f commit 5621d4a
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/DetectableOverflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const defaultStyle: object = {
};

export class DetectableOverflow extends React.Component<Props, States> {

private ref: React.RefObject<HTMLElement>;

constructor(props: Props) {
Expand All @@ -45,8 +44,8 @@ export class DetectableOverflow extends React.Component<Props, States> {
}

const newState =
this.ref.current.offsetWidth !== this.ref.current.scrollWidth ||
this.ref.current.offsetHeight !== this.ref.current.scrollHeight;
this.ref.current.offsetWidth < this.ref.current.scrollWidth ||
this.ref.current.offsetHeight < this.ref.current.scrollHeight;

if (newState === this.state.isOverflowed) {
return;
Expand All @@ -65,17 +64,15 @@ export class DetectableOverflow extends React.Component<Props, States> {

return (
<ReactResizeDetector handleWidth onResize={this.updateState} targetRef={this.ref}>
{
React.createElement(
tag,
{
style,
className,
ref: this.ref,
},
this.props.children,
)
}
{React.createElement(
tag,
{
style,
className,
ref: this.ref,
},
this.props.children
)}
</ReactResizeDetector>
);
}
Expand Down

0 comments on commit 5621d4a

Please sign in to comment.