New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix only left click draggable bar #4613
Changes from 20 commits
29a6397
5dfdb93
4b48eef
e9b8702
6fb77b8
58c3c79
0dd359f
46be3eb
98bcfc7
f5094c3
c18b4a2
8eb5477
aa11f77
e9e6e46
f21b766
7f6eed1
71267ce
cf380a5
0c11dcb
58438f8
db0a1f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,10 @@ class SeekBar extends Slider { | |
* @listens mousedown | ||
*/ | ||
handleMouseDown(event) { | ||
if (!Dom.isSingleLeftClick(event)) { | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could potentially do something like: // only allow left-click seeking
if (
// touch screen, not apply, do nothing
!(event.button === undefined && event.buttons === undefined) &&
// touch screen, safari on ios
!(event.button === 0 && event.buttons === undefined) &&
(event.button !== 0 || event.buttons !== 1)
) {
return;
} Also, we probably should pull this out into a tester function because keeping this copied between the two places is bound to cause issues down the line. Maybe moved to dom.js as a if (isNotLeftClick(event)) {
return;
} |
||
|
||
this.player_.scrubbing(true); | ||
|
||
this.videoWasPlaying = !this.player_.paused(); | ||
|
@@ -130,6 +134,10 @@ class SeekBar extends Slider { | |
* @listens mousemove | ||
*/ | ||
handleMouseMove(event) { | ||
if (!Dom.isSingleLeftClick(event)) { | ||
return; | ||
} | ||
|
||
let newTime = this.calculateDistance(event) * this.player_.duration(); | ||
|
||
// Don't let video end while scrubbing. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -727,6 +727,52 @@ export function insertContent(el, content) { | |
return appendContent(emptyEl(el), content); | ||
} | ||
|
||
/** | ||
* Check if event was a single left click | ||
* | ||
* @param {EventTarget~Event} event | ||
* Event object | ||
* | ||
* @return {boolean} | ||
* - True if a left click | ||
* - False if not a left click | ||
*/ | ||
export function isSingleLeftClick(event) { | ||
/* Note: if you create something draggable, be sure to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor stylistic concern, but could we stick to using |
||
call it on both `mousedown` and `mousemove` event, | ||
otherwise `mousedown` should be enough for a button */ | ||
|
||
if (event.button === undefined && event.buttons === undefined) { | ||
/* Why do we need `butttons` ? | ||
Because, middle mouse sometimes have this: | ||
e.button === 0 and e.buttons === 4 | ||
Furthermore, we want to prevent combination click, something like | ||
HOLD middlemouse then left click, that would be | ||
e.button === 0, e.buttons === 5 | ||
just `button` is not gonna work | ||
|
||
Alright, then what this block does ? | ||
this is for chrome `simulate mobile devices` | ||
I want to support this as well */ | ||
|
||
return true; | ||
} else if (event.button === 0 && event.buttons === undefined) { | ||
// Touch screen, sometimes on some specific device, `buttons` | ||
// doesn't have anything (safari on ios, blackberry...) | ||
|
||
return true; | ||
} else if (event.button !== 0 || event.buttons !== 1) { | ||
/* This is the reason we have those if else block above | ||
if any special case we can catch and let it slide | ||
we do it above, when get to here, this definitely | ||
is-not-left-click */ | ||
|
||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Finds a single DOM element matching `selector` within the optional | ||
* `context` of another DOM element (defaulting to `document`). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this series of
if
blocks confusing. Can it be simplified to:Does that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know :/, what I did was trial by combat, didn't have device to test right now, think I will stick with what work, maybe change to that later if I have device to test (or yours)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beside, I think if we do the current style, we have a chance to handle/explain what is going on with particular device, OS or stuff