Skip to content
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

improve: Better mouse position handling #5773

Merged
merged 6 commits into from
Aug 31, 2020
Merged

Conversation

iosamuel
Copy link
Contributor

@iosamuel iosamuel commented Jan 31, 2019

Description

It is an enhancement for mouse position handling, this will fix the issues when you scale the elements using transform instead of the default font-size scaling provided by videojs, it will work since we will use the local offset position of an element.

Specific Changes proposed

  • We use offsetX and offsetY of the event, so we get the local position of the element, this way we can transform:scale elements without worrying that the position will change drastically.
  • In the stylesheet we make the mouse events on the progress-holder children go off, because we wanna work only with the position of the progress itself, this way we avoid issues getting the offset of the inner elements, such as vjs-load-progress and such.

Requirements Checklist

  • Feature implemented / Bug fixed
  • Change has been verified in an actual browser (Chome, Firefox, IE)
  • Unit Tests updated or fixed
  • Reviewed by Two Core Contributors

@welcome
Copy link

welcome bot commented Jan 31, 2019

💖 Thanks for opening this pull request! 💖

Things that will help get your PR across the finish line:

  • Run npm run lint -- --errors locally to catch formatting errors earlier.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And more discussion over in slack :)

src/css/components/_progress.scss Outdated Show resolved Hide resolved
@iosamuel
Copy link
Contributor Author

Hey @gkatsev, do you have any comment on this one?

@stale
Copy link

stale bot commented Jun 18, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the outdated Things closed automatically by stalebot label Jun 18, 2019
@gkatsev gkatsev removed the outdated Things closed automatically by stalebot label Jun 18, 2019
@gkatsev gkatsev self-assigned this Jun 18, 2019
@stale
Copy link

stale bot commented Aug 17, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the outdated Things closed automatically by stalebot label Aug 17, 2019
@gkatsev gkatsev removed the outdated Things closed automatically by stalebot label Aug 19, 2019
@stale
Copy link

stale bot commented Oct 18, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the outdated Things closed automatically by stalebot label Oct 18, 2019
@stale stale bot closed this Oct 25, 2019
@gkatsev gkatsev reopened this Nov 21, 2019
@stale stale bot removed the outdated Things closed automatically by stalebot label Nov 21, 2019
@stale
Copy link

stale bot commented Jan 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the outdated Things closed automatically by stalebot label Jan 21, 2020
@gkatsev gkatsev removed the outdated Things closed automatically by stalebot label Jan 27, 2020
@stale
Copy link

stale bot commented Mar 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the outdated Things closed automatically by stalebot label Mar 21, 2020
@gkatsev gkatsev removed the outdated Things closed automatically by stalebot label Mar 24, 2020
@stale
Copy link

stale bot commented May 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the outdated Things closed automatically by stalebot label May 20, 2020
@stale stale bot closed this May 30, 2020
@gkatsev gkatsev reopened this Aug 6, 2020
@stale stale bot removed the outdated Things closed automatically by stalebot label Aug 6, 2020
@gkatsev
Copy link
Member

gkatsev commented Aug 28, 2020

It's been a while. Seems to be working fine. Would be great if we can figure out how to fix mobile but this is an improvement still. I'll figure out how to fix the conflict and merge.

@gkatsev gkatsev changed the base branch from master to main August 28, 2020 19:20
@gkatsev gkatsev added needs: LGTM Needs an additional approval and removed needs: testing labels Aug 28, 2020
@gkatsev
Copy link
Member

gkatsev commented Aug 28, 2020

This fixes #6726 and #1102 and the caveat is that it still doesn't work with touch events.

@gkatsev gkatsev merged commit 0b425be into videojs:main Aug 31, 2020
@gkatsev
Copy link
Member

gkatsev commented Aug 31, 2020

Oops, the commit has the wrong issue number.

gkatsev pushed a commit that referenced this pull request Aug 31, 2020
This uses offsetX and offsetY on the MouseEvents which helps account for transforms on the player. Unfortunately, this isn't available on TouchEvents, so, while this helps desktop devices with using a mouse, it doesn't help mobile devices using touch.

Fixes #6726, fixes #1102.
@gkatsev
Copy link
Member

gkatsev commented Aug 31, 2020

Fixed it.

gkatsev added a commit that referenced this pull request Oct 1, 2020
From my understand, in the changes #5773, the Y position of all the
boxes is already calculated and accounted for in the offsetY value we
get. However, because the HTML coordinate system has Y=0 at the top,
when we do offsetY/boxH, we get a position relative to the top of the
element. However, we expect that position relative to the "start" of the
slider, or the bottom of it. Therefore, we want to get the inverse
value, which is '1 - clamp(offsetY/boxH)'.

Fixes #6863
gkatsev added a commit that referenced this pull request Oct 1, 2020
From my understand, in the changes #5773, the Y position of all the
boxes is already calculated and accounted for in the offsetY value we
get. However, because the HTML coordinate system has Y=0 at the top,
when we do offsetY/boxH, we get a position relative to the top of the
element. However, we expect that position relative to the "start" of the
slider, or the bottom of it. Therefore, we want to get the inverse
value, which is '1 - clamp(offsetY/boxH)'.

Fixes #6863
@misteroneill misteroneill removed the needs: LGTM Needs an additional approval label May 23, 2023
edirub pushed a commit to edirub/video.js that referenced this pull request Jun 8, 2023
This uses offsetX and offsetY on the MouseEvents which helps account for transforms on the player. Unfortunately, this isn't available on TouchEvents, so, while this helps desktop devices with using a mouse, it doesn't help mobile devices using touch.

Fixes videojs#6726, fixes videojs#1102.
edirub pushed a commit to edirub/video.js that referenced this pull request Jun 8, 2023
From my understand, in the changes videojs#5773, the Y position of all the
boxes is already calculated and accounted for in the offsetY value we
get. However, because the HTML coordinate system has Y=0 at the top,
when we do offsetY/boxH, we get a position relative to the top of the
element. However, we expect that position relative to the "start" of the
slider, or the bottom of it. Therefore, we want to get the inverse
value, which is '1 - clamp(offsetY/boxH)'.

Fixes videojs#6863
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants