Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add PiP move threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
weeman1337 committed Feb 1, 2023
1 parent 918f151 commit c8a4257
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/structures/PictureInPictureDragger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -192,11 +194,19 @@ export default class PictureInPictureDragger extends React.Component<IProps> {
event.stopPropagation();

this.mouseHeld = true;
this.startingPositionX = event.pageX;
this.startingPositionY = event.pageY;
};

private onMoving = (event: MouseEvent): void => {
if (!this.mouseHeld) return;

if (Math.abs(this.startingPositionX - event.pageX) < 5 && Math.abs(this.startingPositionY - event.pageY) < 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();

Expand Down

0 comments on commit c8a4257

Please sign in to comment.