Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(region): Refactor creator to modify rect directly during draw #490

Merged
merged 4 commits into from
May 20, 2020

Conversation

jstoffan
Copy link
Collaborator

@jstoffan jstoffan commented May 19, 2020

Same thing as before, just 2-3x faster.

Todo

  • Fix RegionCreator unit tests

@jstoffan jstoffan force-pushed the perf-region-draw branch from 76614cd to 6350163 Compare May 19, 2020 02:50
src/region/RegionCreator.tsx Outdated Show resolved Hide resolved
src/region/RegionCreator.tsx Show resolved Hide resolved
@jstoffan jstoffan force-pushed the perf-region-draw branch from d25df48 to 093a74b Compare May 19, 2020 20:45
@jstoffan jstoffan marked this pull request as ready for review May 19, 2020 20:46
@jstoffan jstoffan requested a review from a team as a code owner May 19, 2020 20:46
mxiao6
mxiao6 previously approved these changes May 19, 2020

expect(instance.getPosition(100, 100)).toEqual([85, 85]);
simulateDrawStart(wrapper);
simulateDrawMove(50, 50);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot expect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, on second look it's just a dead test. I misread the diff even after your comment. Nice catch, will fix.

ConradJChan
ConradJChan previously approved these changes May 19, 2020
export function AutoScroller(props: Props, ref: React.Ref<Element>): JSX.Element {
const { as: Element = 'div', children, enabled, intensity = 0.2, onScroll = noop, size = 50, ...rest } = props;
export default function useAutoScroll(options: Options): void {
const { enabled, intensity = 0.2, onScroll = noop, reference, size = 50 } = options;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we destructure them out in the function arguments above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can, but it breaks the function declaration onto multiple lines in an unpleasant way.

Comment on lines +168 to +172
regionRect.setAttribute('height', `${height}`);
regionRect.setAttribute('width', `${width}`);
regionRect.setAttribute('x', `${x}`);
regionRect.setAttribute('y', `${y}`);
regionDirtyRef.current = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

mickr
mickr previously approved these changes May 19, 2020
@jstoffan jstoffan dismissed stale reviews from mickr, ConradJChan, and mxiao6 via c742b3e May 19, 2020 23:39
@jstoffan jstoffan merged commit a838a9e into box:master May 20, 2020
@jstoffan jstoffan deleted the perf-region-draw branch May 20, 2020 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants