-
Notifications
You must be signed in to change notification settings - Fork 122
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
feat: ability to associate timestamps with movements #124
Conversation
Thanks for the PR! If I understand correctly, this is only showing the timestamps, not actually using it, right? Maybe we should change the puppeteer |
That's correct it's just for show. However, I wouldn't be against digging more into the |
@Niek just checking back in so I don't lose track of this pr. Did you want me to make any changes? |
In my opinion this only makes sense if the timestamps are used, meaning we need to switch to manual |
Honestly, I don't really see any scenario where this would work unless I'm also making changes to functions like const tracePath = async (
- vectors: Iterable<Vector>,
+ vectors: Iterable<Vector | TimedVector>,
abortOnMove: boolean = false
): Promise<void> => {
...
- await page.mouse.move(v.x, v.y)
+ if ('timestamp' in v) {
+ await getCDPClient(page).send('Input.dispatchMouseEvent', {
+ type: 'mouseMoved',
+ x: v.x,
+ y: v.y,
+ timestamp: v.timestamp
+ })
+ } else {
+ await page.mouse.move(v.x, v.y)
+ }
... Or, we could always use the dispatchMouseEvent with something more along the lines of: const tracePath = async (
- vectors: Iterable<Vector>,
+ vectors: Iterable<Vector | TimedVector>,
abortOnMove: boolean = false
): Promise<void> => {
...
- await page.mouse.move(v.x, v.y)
+ const dispatchParams: Protocol.Input.DispatchMouseEventRequest = {
+ type: 'mouseMoved',
+ x: v.x,
+ y: v.y,
+ }
+
+ if ('timestamp' in v) dispatchParams.timestamp = v.timestamp
+
+ await getCDPClient(page).send('Input.dispatchMouseEvent', dispatchParams)
... |
Yes, this is what I was thinking of. Although it's probably better to have the CDP client initialised once in order to avoid creating thousands of clients. |
Good call, my brain didn't even process that I was calling that in a loop when I sent that code block |
Awesome, thanks! This LGTM, but @bvandercar-vt can you review this as well? |
Not sure what happened there with the merge conflicts not getting all the changes the first time around and with the whitespace changes on the second one (husky ran properly), if one of you could fix the whitespace I'd appreciate it. |
Did you run |
Yeah that was post |
Ah yeah Definitely a downside of Update: Not sure if the repo owners will go for it, but I wanted to see how it looked-- made a prettier PR: #142 |
super annoying, still a little what caused the whitespace to begin with as I turned off any formatters I have when working in this repo but not sure what else I can do besides manually fix it |
Should be good now, really odd but oh well |
@aw1875 PR looks good! Thanks for implementing those changes! |
Thanks a lot, merged now! |
Take two on a PR I did a few years ago (#42).
This version does essentially the same thing as the original PR but with a more elegant approach by utilizing the options that can be passed to the path function and calculating the time to take using the Trapezoidal rule.
I'm open to any suggestions/changes so please let me know.