Skip to content

Commit

Permalink
new(vx-responsive): add leading option to resize debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
Pringels committed Jun 18, 2020
1 parent cb802d1 commit 6cb347c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/vx-responsive/src/components/ParentSize.tsx
Expand Up @@ -66,7 +66,7 @@ export default class ParentSize extends React.Component<

resize = debounce(({ width, height, top, left }: ParentSizeState) => {
this.setState(() => ({ width, height, top, left }));
}, this.props.debounceTime);
}, this.props.debounceTime, { leading: true });

setTarget = (ref: HTMLDivElement | null) => {
this.target = ref;
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-responsive/src/enhancers/withParentSize.tsx
Expand Up @@ -63,7 +63,7 @@ export default function withParentSize<BaseComponentProps extends WithParentSize
parentWidth: width,
parentHeight: height,
});
}, this.props.debounceTime);
}, this.props.debounceTime, { leading: true });

render() {
const { parentWidth, parentHeight } = this.state;
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-responsive/src/enhancers/withScreenSize.tsx
Expand Up @@ -45,7 +45,7 @@ export default function withScreenSize<BaseComponentProps extends WithScreenSize
screenHeight: window.innerHeight,
};
});
}, this.props.windowResizeDebounceTime);
}, this.props.windowResizeDebounceTime, { leading: true });

render() {
const { screenWidth, screenHeight } = this.state;
Expand Down

0 comments on commit 6cb347c

Please sign in to comment.