Add PiP move threshold (#10040)

This commit is contained in:
Michael Weimann 2023-02-01 13:55:10 +01:00 committed by GitHub
parent c6f6fa62f7
commit 7feb5b1f6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 22 deletions

View file

@ -70,6 +70,8 @@ export default class PictureInPictureDragger extends React.Component<IProps> {
() => this.animationCallback(),
() => requestAnimationFrame(() => this.scheduledUpdate.trigger()),
);
private startingPositionX = 0;
private startingPositionY = 0;
private _moving = false;
public get moving(): boolean {
@ -192,11 +194,22 @@ export default class PictureInPictureDragger extends React.Component<IProps> {
event.stopPropagation();
this.mouseHeld = true;
this.startingPositionX = event.clientX;
this.startingPositionY = event.clientY;
};
private onMoving = (event: MouseEvent): void => {
if (!this.mouseHeld) return;
if (
Math.abs(this.startingPositionX - event.clientX) < 5 &&
Math.abs(this.startingPositionY - event.clientY) < 5
) {
// User needs to move the widget by at least five pixels.
// Improves click detection when using a touchpad or with nervous hands.
return;
}
event.preventDefault();
event.stopPropagation();