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

testing timeSlider offset #1076

Merged
merged 2 commits into from
May 8, 2024
Merged

testing timeSlider offset #1076

merged 2 commits into from
May 8, 2024

Conversation

moontrip
Copy link
Contributor

@moontrip moontrip commented May 7, 2024

This is a test to consider the inherent timeSlider's offset, 2 pixels.

Copy link
Member

@bobular bobular left a comment

Choose a reason for hiding this comment

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

Code looks good (one suggestion).

I tested it by dragging a selection. Taking a screenshot. Refreshing the page. Taking another screenshot, and then comparing the screenshots.

Before this PR: the selection expands slightly.
After this PR: the selection is rock-solid.

:-)

// and 'species collection start date' variable,
// such a 2 pixel results in about 4 months
const brushOffset =
xBrushScale.invert(2).getTime() - xBrushScale.domain()[0].getTime();
Copy link
Member

Choose a reason for hiding this comment

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

I prefer this for readability and also just in case the domain doesn't start at zero one day!
I've tested it and it works fine.

Suggested change
xBrushScale.invert(2).getTime() - xBrushScale.domain()[0].getTime();
xBrushScale.invert(2).getTime() - xBrushScale.invert(0).getTime();

Copy link
Member

@bobular bobular May 7, 2024

Choose a reason for hiding this comment

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

Oh, and we should add a comment referring to the SAFE_PIXEL constant in the visx source code
https://github.com/airbnb/visx/blob/86a851cb3bf622b013b186f02f955bcd6548a87f/packages/visx-brush/src/Brush.tsx#L14
(Shame they don't export it...)

And remove the console.logs before merging. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bobular Thank you for your tests and reviews 👍 Sounds great it works! I followed your comments and made a new commit. Also, changed this PR to a regular one.

@moontrip moontrip marked this pull request as ready for review May 7, 2024 21:30
@bobular
Copy link
Member

bobular commented May 7, 2024

I'll merge it if you won't!
Actually I won't. But just pointing out that I've already approved. :-)

@moontrip
Copy link
Contributor Author

moontrip commented May 7, 2024

Thanks @bobular I was just gauging whether it should be merged or not because of the release date 😅 Certainly you can merge it if you think it is okay :)

@bobular
Copy link
Member

bobular commented May 8, 2024

Thanks for the consideration. The release already went out so all is good. Merging now. Thanks for tackling this proactively!

@bobular bobular merged commit 886aab8 into main May 8, 2024
1 check passed
@bobular bobular deleted the timeslider-offset branch May 8, 2024 08:50
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.

2 participants