Skip to content

Commit

Permalink
fix(player): releasing slider should not trigger other elements
Browse files Browse the repository at this point in the history
closes #1226
  • Loading branch information
mihar-22 committed Apr 22, 2024
1 parent e7e5d65 commit 5548a15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class SliderEventsController extends ViewController<
private _attachPointerListeners() {
if (this._delegate._isDisabled() || !this.$state.dragging()) return;

listenEvent(document, 'pointerup', this._onDocumentPointerUp.bind(this));
listenEvent(document, 'pointerup', this._onDocumentPointerUp.bind(this), { capture: true });
listenEvent(document, 'pointermove', this._onDocumentPointerMove.bind(this));
listenEvent(document, 'touchmove', this._onDocumentTouchMove.bind(this), {
passive: false,
Expand Down Expand Up @@ -359,6 +359,10 @@ export class SliderEventsController extends ViewController<

private _onDocumentPointerUp(event: PointerEvent) {
if (event.button !== 0) return;

event.preventDefault();
event.stopImmediatePropagation();

const value = this._getPointerValue(event);
this._updatePointerValue(value, event);
this._onStopDragging(value, event);
Expand Down
2 changes: 1 addition & 1 deletion packages/vidstack/src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function onPress(
handler: (event: PointerEvent | KeyboardEvent) => void,
) {
listenEvent(target, 'pointerup', (event) => {
if (event.button === 0) handler(event);
if (event.button === 0 && !event.defaultPrevented) handler(event);
});
listenEvent(target, 'keydown', (event) => {
if (isKeyboardClick(event)) handler(event);
Expand Down

0 comments on commit 5548a15

Please sign in to comment.