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

Update Bespoke navigation plugin to adjust wheel sensitivity #345

Merged
merged 8 commits into from
May 11, 2021

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented May 11, 2021

This PR includes changed for adjustment wheel sensitivity, and stopped using deprecated event.which.

Resolves #340.

Wheel sensitivity

Based on the feedback in #340, the navigation through mouse wheel has updated to make a threshold of wheel delta for triggering page navigation.

Multi-touch device such as Magic Trackpad and Magic Mouse will tell a wheel event in much high resolution (wheel delta 3) than the common wheel mouse (wheel delta 120). So the wheel event for navigation was emitted sensitively because events were triggered by a slightly move of a finger, especially on the Magic Mouse.

We should follow these requirements:

  • Navigation must not be too sensitive to a slight movement of a finger on Magic Mouse.
  • Navigation must not be too insensitive to the scroll/swipe gesture on Magic Trackpad and Magic Mouse.
  • The wheel navigation by the regular mouse must work as usual like the other presentation software.

This PR will change not to trigger the navigation against the wheel event with the delta value that was less than 20. We are trying to detect enough amount of scroll delta to navigate in cross browser. It should be reduced unexpected navigation from a slightly movement of a finger on Magic Mouse, with keeping sensitivity in the trackpad and regular mouse wheel. Especially must react to the wheel event triggered by a single wheel notch at least.

// Prevent too sensitive navigation on trackpad and magic mouse
const currentWheelDelta = Math.sqrt(e.deltaX ** 2 + e.deltaY ** 2)
if (e.wheelDelta !== undefined) {
if (e.webkitForce === undefined) {
// [Chromium]
// Chromium has (a deprecated) wheelDelta value and it is following the
// pre-defeind WHEEL_DELTA (=120). It means a required delta for
// scrolling 3 lines. We have set a threshold as 40 (required to scroll
// 1 line).
if (Math.abs(e.wheelDelta) < 40) return
}
// [WebKit]
// WebKit's wheelDelta value will just return 3 times numbers from the
// standard delta values, so using the standard delta will be better
// than depending on deprecated values.
//
// Both of Chromium and Webkit are starting scroll from 4 pixels by a
// event of the mouse wheel notch. If set a threshold to require 1 line
// of scroll, the navigation by mouse wheel may be insensitive. So we
// have set a threshold as 4 pixels.
//
// It means Safari is more sensitive to Multi-touch devices than other
// browsers.
if (e.deltaMode === e.DOM_DELTA_PIXEL && currentWheelDelta < 4) return
} else {
// [Firefox]
// Firefox only has delta values provided by the standard wheel event.
//
// It will report 36 as the delta of the minimum tick for the regular
// mouse wheel because Firefox's default font size is 12px and 36px is
// required delta to scroll 3 lines at once.
if (e.deltaMode === e.DOM_DELTA_PIXEL && currentWheelDelta < 12) return
}

For the trackpad user, this change may feel like making insensitive against the scroll/swipe gesture. Welcome the feedback continuously.

@yhatt yhatt merged commit 416f3d4 into main May 11, 2021
@yhatt yhatt deleted the bespoke-navgigation-wheel-sensitivity branch May 11, 2021 22:27
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.

How to deactivate action of (mouse) scroll wheel (go to next slide)?
1 participant