Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Normalize mouse wheel deltas #3911

Merged
merged 2 commits into from
Jul 1, 2018
Merged

Normalize mouse wheel deltas #3911

merged 2 commits into from
Jul 1, 2018

Conversation

wildyeast
Copy link

This fix normalizes the mouse wheel delta values and enables reasonable scrolling in Firefox (see #3792). Timeline now uses the wheel event if supported by the browser.

Relevant examples: timeline/other/horizontalScroll.html and verticalScroll.html

Copy link

@deltragon deltragon left a comment

Choose a reason for hiding this comment

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

This drops support for IE 6/7/8 since it always uses addEventListener now instead of attachEvent for those browsers.

document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
this.dom.centerContainer.addEventListener ? "DOMMouseScroll" : // Older Firefox versions like "DOMMouseScroll"
"onmousewheel" // All the rest should be comfortable with "onmousewheel"
this.dom.centerContainer.addEventListener(wheelType, onMouseWheel.bind(this), false);

Choose a reason for hiding this comment

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

Use attachEvent here in case addEventListener is not supported (IE < 9).

Copy link
Author

Choose a reason for hiding this comment

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

That's right. Thank you!

Copy link

@deltragon deltragon left a comment

Choose a reason for hiding this comment

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

Uses the spec-conforming "wheel" event for new browsers that support it, behaving more appropriately.
Does not change behaviour for other browsers.

@SpeedHighway
Copy link

I'm trying this in firefox quantum, and it isn't having any effect at all.... It still moves in micrometers when scrolling with the mousewheel, or dragging the scrollbar, etc.

@deltragon
Copy link

@SpeedHighway:
Hmm
Are you sure you checked out the develop branch/rebuilt it correctly? Can confirm that the mousewheel works properly in Firefox 59 on Linux.

@SpeedHighway
Copy link

SpeedHighway commented May 17, 2018

Actually, no. I just tried this fix, by itself, because we're using vis through npm. I'm not sure of how I can get wildyeast's branch, doing it this way.

EDIT: Okay, I built directly from wildyeast's fork and it does work. Using the scrollbar or arrows on the scrollbar still work horribly, but the mouse wheel works, at the very least. :)

@wildyeast
Copy link
Author

Nice! Thanks for giving it a try 👍

@yotamberk
Copy link
Contributor

Hi @wildyeast ,
I've now branched out to a new fork of my own including only Timeline.
I've applied your change here: https://github.com/yotamberk/timeline-plus
and can be used via npm here: https://www.npmjs.com/package/timeline-plus
Awesome fix! Thanks for your contribution! Future PRs will be reviewed and added in the new fork

@yotamberk yotamberk merged commit 8441fed into almende:develop Jul 1, 2018
@deltragon
Copy link

@yotamberk We have switched to your fork. Thank you for your time!

mojoaxel pushed a commit to visjs/vis_original that referenced this pull request Jun 9, 2019
* Normalize mouse wheel deltas for almende#3792

* include support for IE6/7/8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants