-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix(classifier): smooth image dragging for pan/zoom #6065
base: master
Are you sure you want to change the base?
Conversation
941e8c0
to
da4a793
Compare
NB. I'm testing this (and recording the screen video) on a very-much overpowered M3 MacBook Pro. It'd be useful to get tests from machines that are more in line with what typical volunteers use. I might be seeing smooth dragging movement simply because I'm using a fast machine. |
1aef573
to
7614043
Compare
7614043
to
e77a536
Compare
0fdf304
to
7c42250
Compare
...onents/Classifier/components/SubjectViewer/components/SingleImageViewer/SingleImageViewer.js
Outdated
Show resolved
Hide resolved
<svg | ||
ref={canvasLayer} | ||
viewBox={viewBox} | ||
> | ||
{children} | ||
{enableInteractionLayer && ( | ||
<InteractionLayer | ||
frame={frame} | ||
height={height} | ||
scale={scale} | ||
subject={subject} | ||
width={width} | ||
/> | ||
)} | ||
</svg> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that the image is cropped if you try to drag it outside a rotated view box, even though there’s visibly available space in the browser viewport. I’m not sure if that would be a blocker. To reproduce that, rotate an image by 90° or 270°, then drag it left or right. The width of the rotated view box (the actual height of the image) is narrower than the width of the subject viewer. EDIT: fixed by styling the nested |
d014044
to
1aed5f9
Compare
Here's a screen recording from Chrome 124, also running on an M3 MacBook. Screen.Recording.2024-05-02.at.17.24.35.mov |
3d70251
to
3febd39
Compare
3febd39
to
025b97b
Compare
025b97b
to
03a0883
Compare
- Refactor `SVGPanZoom` to use a ref for `zoom`, rather than component state. Hopefully, this will lead to fewer rerenders when dragging a zoomed image, and smoother performance. - Use a ref to store pointer coordinates in the `draggable` decorator, to avoid unnecessary rerenders. - Move the cropped SVG viewbox into a nested SVG, for better performance when dragging a zoomed image. - Remove the `1.5` easing factor on dragged images, so that they 'stick' to the pointer when dragged. - Use `focus-visible` so that focus rings are only shown for keyboard interactions.
- remove unused variables. - use a ref to remember the current pointerId across renders. - clean up pointer capture.
03a0883
to
665d5b0
Compare
SVGPanZoom
to use a ref forzoom
, rather than component state. Hopefully, this will lead to fewer rerenders when dragging a zoomed image, and smoother performance.draggable
decorator, to avoid unnecessary rerenders.1.5
easing factor on dragged images, so that they 'stick' to the pointer when dragged.focus-visible
so that focus rings are only shown for keyboard interactions.useKeyZoom
hook to support rotated images.Screen recordings from Firefox 125 running on an M3 MacBook (Sonoma 14.4.1.)
Pan and zoom with a trackpad:
Screen.Recording.2024-04-30.at.09.35.20.mov
Pan and zoom with a trackpad at a very high zoom level:
Screen.Recording.2024-04-30.at.10.18.27.mov
Keyboard focus with Tab and shift-Tab:
Screen.Recording.2024-04-30.at.09.43.05.mov
Package
Linked Issue and/or Talk Post
How to Review
Zoom and pan an image in the dev classifier, using both the keyboard and a trackpad/mouse to pan the zoomed image.
You can test the focus styling by tabbing through the page, to check that drawn marks have focus styling when focused (WCAG Success Criterion 2.4.7: focus visible.) When a mark has keyboard focus, Enter will open any associated subtask popup, which should also be fully keyboard accessible. Backspace will delete the focused mark (WCAG Success Criterion 2.1.1: Keyboard.)
Checklist
PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.
General
yarn panic && yarn bootstrap
ordocker-compose up --build
and FEM works as expectedGeneral UX
Example Staging Project: i-fancy-cats
Bug Fix