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

Add support for wheel events #808

Closed
jedeen opened this issue May 11, 2017 · 7 comments
Closed

Add support for wheel events #808

jedeen opened this issue May 11, 2017 · 7 comments
Labels
feature Label applied to new feature requests

Comments

@jedeen
Copy link
Member

jedeen commented May 11, 2017

Context

Currently, Excalibur does not directly support wheel events (such as mouse scrolling) for input.

Proposal

Add support for wheel events.

Additionally, work will need to be done for the scenario where a game is using wheel events, but the page has a scroll bar.

@jedeen jedeen added the feature Label applied to new feature requests label May 11, 2017
@jedeen jedeen added this to the vNext milestone May 11, 2017
@mrkmg
Copy link
Contributor

mrkmg commented May 12, 2017

I am willing to implement this (I already have a working prototype I am using in game I am working on).

For handling the scenario's where the page could have a scroll bar, we could provide some sort of "enableMousewheelCapture" flag which uses event.preventDefault() to cancel the window from scrolling. That way, the developer can decide how to handle that circumstance.

Aside from that, what should I name the events? I am thinking "wheelforward" and "wheelbackward".

@jedeen
Copy link
Member Author

jedeen commented May 12, 2017

I like "wheelForward" and "wheelBackward". @excaliburjs/core-contributors, any thoughts?

Watching for changes in vertical scroll covers the most common action with a standard mousewheel. There are other scrolling scenarios we may want to address (for example, a trackball, or a mouse with sidescroll capability). Those are probably best left to a second issue to add additional support for changes in deltaX and deltaZ.

@mrkmg
Copy link
Contributor

mrkmg commented May 12, 2017

Looking into this further, we could be more generic and have a "wheel" event in general. Then leave it up to the develop to examine deltaX, deltaY, and deltaZ.

I started work on this about an hour ago, and that's the way I am going so far.

I will push up a draft shortly.

Also, side question: why var instead of let and const?

@mrkmg
Copy link
Contributor

mrkmg commented May 12, 2017

@jedeen Further issues.

According the MDN (https://developer.mozilla.org/en-US/docs/Web/Events/wheel) there is a "deltaMode" which defines what type of "detla" is pased. It can either be "pixels", "lines" or "pages".

The question is, do we try to normalize this, or do we just give the developer the deltaMode and let them deal with it?

I am leaning toward just giving the developer the deltaMode and letting them deal with it. In most use cases, developers are not even going to care about the raw values. They are just going to want to know if they were positive or negative.

mrkmg pushed a commit to mrkmg/Excalibur that referenced this issue May 12, 2017
- Added event "wheel"
- Added sandbox pointer wheel test
- Added docs
@jedeen
Copy link
Member Author

jedeen commented May 12, 2017

Excalibur currently targets ECMAScript 5, which does not include the let statement.

I think passing through the deltaMode should be fine for now; we can always enhance the functionality at a later point.

@kamranayub
Copy link
Member

@jedeen did you mean to leave this comment on the PR?

@jedeen
Copy link
Member Author

jedeen commented May 13, 2017

@kamranayub no, I haven't had a chance to look at the PR yet, just responding to the questions in the previous comment.

mrkmg pushed a commit to mrkmg/Excalibur that referenced this issue May 23, 2017
- Added event "wheel"
- Added sandbox pointer wheel test
- Added docs
eonarheim pushed a commit that referenced this issue Jun 6, 2017
Closes #808 

## Changes

- Added event "wheel"
- Added sandbox pointer wheel test
- Added docs
@jedeen jedeen modified the milestones: 0.11.0 Release, vNext Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Label applied to new feature requests
Projects
None yet
Development

No branches or pull requests

3 participants