Skip to content

fix(youtube): support click+hold interactions as user-intentional rate-changes#1555

Open
Tredecate wants to merge 1 commit into
igrigorik:masterfrom
Tredecate:Tredecate/fix/1554-click-and-hold-interaction
Open

fix(youtube): support click+hold interactions as user-intentional rate-changes#1555
Tredecate wants to merge 1 commit into
igrigorik:masterfrom
Tredecate:Tredecate/fix/1554-click-and-hold-interaction

Conversation

@Tredecate

Copy link
Copy Markdown

What

This PR adjusts the handling of user gesture tracking in the EventManager class to support click-and-hold interactions with site controls. Fixes #1554

Why

YouTube allows users to click-and-hold for a temporary 2x speed boost, but handleRateChange() was overriding the update due to lastUserInteractionAt only using click events to detect mouse interactions.

As click only fires after an entire mouse-down -> mouse-up cycle completes, lastUserInteractionAt wasn't being set until after the user released the button press. Now, clickHandler is called on pointerdown, too, setting lastUserInteractionAt and updating a new isClickHeld flag that is included in handleRateChange()'s logic.

How

  • Added an isClickHeld property to EventManager to track whether the most recent mouse interaction is currently held down.
    • The value of isClickHeld is updated based on the most recent event.type received by clickHandler.
  • Added a pointerdown event listener to pair with the existing click listener for clickHandler.
  • Modified the logic for determining if a playback rate change is a user gesture.
    • Now considers either a recent interaction or an ongoing click-and-hold as valid user gestures.

YouTube supports click-and-hold to set a temporary speed, but fight-back
overrode the change due to lastUserInteractionAt using click events.

Now clickHandler fires on pointerdown too, setting lastUserInteractionAt
and a new isClickHeld flag that is checked alongside timeSinceGesture.

Fixes igrigorik#1554
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.

YouTube's native Click+Hold for Fast-Forward feature is broken when VSC extension enabled

1 participant