chore: wheel input in bidi (#32499)

This commit is contained in:
Yury Semikhatsky 2024-09-06 17:10:14 -07:00 committed by GitHub
parent 37bc485827
commit f3ada9c654
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -76,7 +76,7 @@ export class RawMouseImpl implements input.RawMouse {
} }
async move(x: number, y: number, button: types.MouseButton | 'none', buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, forClick: boolean): Promise<void> { async move(x: number, y: number, button: types.MouseButton | 'none', buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, forClick: boolean): Promise<void> {
// TODO: bidi throws when x/y are not integers. // Bidi throws when x/y are not integers.
x = Math.round(x); x = Math.round(x);
y = Math.round(y); y = Math.round(y);
await this._performActions([{ type: 'pointerMove', x, y }]); await this._performActions([{ type: 'pointerMove', x, y }]);
@ -91,6 +91,19 @@ export class RawMouseImpl implements input.RawMouse {
} }
async wheel(x: number, y: number, buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, deltaX: number, deltaY: number): Promise<void> { async wheel(x: number, y: number, buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, deltaX: number, deltaY: number): Promise<void> {
// Bidi throws when x/y are not integers.
x = Math.round(x);
y = Math.round(y);
await this._session.send('input.performActions', {
context: this._session.sessionId,
actions: [
{
type: 'wheel',
id: 'pw_mouse_wheel',
actions: [{ type: 'scroll', x, y, deltaX, deltaY }],
}
]
});
} }
private async _performActions(actions: bidi.Input.PointerSourceAction[]) { private async _performActions(actions: bidi.Input.PointerSourceAction[]) {