Add PiP move threshold (#10040)
This commit is contained in:
parent
c6f6fa62f7
commit
7feb5b1f6b
2 changed files with 46 additions and 22 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue