-
Notifications
You must be signed in to change notification settings - Fork 508
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
Fix 2598 - mousewheel dom3 and wheel property #2633
Conversation
var rawAmount = evt.deltaY ? evt.deltaY : evt.detail; | ||
normalized = -(rawAmount % 3 ? rawAmount * 10 : rawAmount / 3); | ||
} | ||
return normalized; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just:
return event.wheelDelta ? event.wheelData / 120 : -(event.deltaY || event.detail || 0) / 3
I don't really understand the (x % 120 - 0) == -0
or the rawAmount % 3
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use event
instead of evt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arian I wanted to check event.wheelDelta % 120
but since that can return -0
I thought doing (-0) - (-0)
so I get a consistent number (always -0
) which I can compare with == -0
, would there be a better way? Math.abs
? Have ||
for both 0
and -0
?
The rawAmount % 3
is because FIrefox returns 3
and 0.1
multiples in respective Mac and Windows. This would detect that and normalize it.
We could just do the return
as you suggest. That would not normalize the value but stll give a direction indicator and make it easier to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so there are four cases:
- multiples of 120
- multiples of 12
- multiples of 3
- multiples of 0.1
Don't you have to do the - 0
trick for the % 3
as well?
In any case, -0 == 0
returns true
, so it shouldn't matter actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arian you are right, -0 == 0
returns true
anyway.
Will wait for travis to get back and re-test it.
added 2 specs - Spec for mousewheel event being set - Spec for mousewheel direction
@arian great feedback, thank you. Updated, re-tested, re-based also. |
if (event.wheelDelta){ | ||
normalized = event.wheelDelta % 120 == 0 ? event.wheelDelta / 120 : event.wheelDelta / 12; | ||
} else { | ||
var rawAmount = event.deltaY ? event.deltaY : event.detail; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var rawAmount = event.deltaY || event.detail || 0;
@kentaromiura: nice! Can someone check this so we moo on to 1.5.1 ? |
if (type == 'DOMMouseScroll' || type == 'mousewheel') | ||
this.wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3; | ||
|
||
if (type == 'DOMMouseScroll' || type == 'wheel' || type == 'mousewheel') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, that would be more clear, will fix.
Fix 2598 - mousewheel dom3 and wheel property
This pull requests fixes
wheel
event.wheel
property of MooTools's DOMEvent which would otherwise be broken in Firefox.It also updates the normalize of the
e.wheel
value according to each browsers return onevent.wheelDelta
,event.detail
andevent.deltaY
.The reason why
deltaY
is mixed in here is because Firefox returnsundefined
forevent.wheelDelta
and0
forevent.detail
, as can be tested in this jsFiddle: http://jsfiddle.net/mNdwW/Tested in SauceLabs and manually on IE7-11, Opera (latest) Win & Mac, Safari 7, Chrome (latest) Win & Mac, Firefox (latest) Win & Mac
fixes #2598, closes #2599, closes #2620