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

Commit c8a4257

Browse files
committed
Add PiP move threshold
1 parent 918f151 commit c8a4257

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/components/structures/PictureInPictureDragger.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export default class PictureInPictureDragger extends React.Component<IProps> {
7070
() => this.animationCallback(),
7171
() => requestAnimationFrame(() => this.scheduledUpdate.trigger()),
7272
);
73+
private startingPositionX = 0;
74+
private startingPositionY = 0;
7375

7476
private _moving = false;
7577
public get moving(): boolean {
@@ -192,11 +194,19 @@ export default class PictureInPictureDragger extends React.Component<IProps> {
192194
event.stopPropagation();
193195

194196
this.mouseHeld = true;
197+
this.startingPositionX = event.pageX;
198+
this.startingPositionY = event.pageY;
195199
};
196200

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

204+
if (Math.abs(this.startingPositionX - event.pageX) < 5 && Math.abs(this.startingPositionY - event.pageY) < 5) {
205+
// User needs to move the widget by at least five pixels.
206+
// Improves click detection when using a touchpad or with nervous hands.
207+
return;
208+
}
209+
200210
event.preventDefault();
201211
event.stopPropagation();
202212

0 commit comments

Comments
 (0)