-
Notifications
You must be signed in to change notification settings - Fork 13
fix(mover): Pass drag delta to dragger.onDrag in pixels
#599
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
Conversation
0607f32 to
6ebb919
Compare
Change the signature of sendKeyAndWait: - Export it, so it can be used directly by tests. - Allow multiple keys to be specified. - Make times parameter optional (default 1).
This test currently fails due to issue RaspberryPiFoundation#446.
BenHenning
left a comment
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.
Thanks @cpcallen! Seems like a really nice fix. Just had some nits and one core design consideration, but otherwise the PR LGTM.
| info.dragger.onDrag( | ||
| info.fakePointerEvent('pointermove', direction), | ||
| info.totalDelta, | ||
| info.totalDelta.clone().scale(workspace.scale), |
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.
This makes me wonder if we should have distinct types for different coordinate spaces, e.g. ScreenCoordinate and WorkspaceCoordinate. It's not obvious from code that scaling performs the space conversion, or what coordinate system we're currently in at this point (since if totalDelta is already in screen space then scaling again would be wrong).
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.
This would be a great idea; I've filed RaspberryPiFoundation/blockly#9156 for future consideration.
Relatedly, one of the things I somewhat dislike about TypeScript (and also Go) is duck typing: it should be possible to give different names to the same type specification and have the compiler flag any mixed use (absent explicit casts). For object types it's pretty easy to make things different shapes (adding a dummy method to the class definition changes the type without changing the actuals shape of the objects in memory), but a classic use of nominal typing is to distinguish between strings containing HTML and ones containing plain text, and enforce calling a function to do escaping when converting the latter to the former. TypeScript doesn't let you do that—you'd have to use subclasses of the String object type rather than plain strings.
There was an error in the initial implementation of
DragMover(in PR #317), where the drag delta was being passed in workspace coordinates instead of pixels. This lead to various problems, notably #446.Fixes #446.