【发布时间】:2014-12-07 05:58:14
【问题描述】:
我注意到鼠标滚轮事件在 mac osx 中发生了多次。可以归因于惯性特征。
有没有办法解决这个问题?
(请自签名 ssl 不用担心!) https://sandbox.idev.ge/roomshotel/html5_v2/
我正在使用 scrollSections.js https://github.com/guins/jQuery.scrollSections
它使用鼠标滚轮 jquery 插件:https://github.com/brandonaaron/jquery-mousewheel
我看到很多人有同样的问题:https://github.com/brandonaaron/jquery-mousewheel/issues/36
有一些解决方案,但没有一个适用于 scrollSections 插件。
任何想法如何从 JS 中禁用此惯性功能?
我尝试的修复:
// Fix for OSX inertia problem, jumping sections issue.
if (isMac) {
var fireEvent;
var newDelta = deltaY;
if (oldDelta != null) {
//check to see if they differ directions
if (oldDelta < 0 && newDelta > 0) {
fireEvent = true;
}
//check to see if they differ directions
if (oldDelta > 0 && newDelta < 0) {
fireEvent = true;
}
//check to see if they are the same direction
if (oldDelta > 0 && newDelta > 0) {
//check to see if the new is higher
if (oldDelta < newDelta) {
fireEvent = true;
} else {
fireEvent = false;
}
}
//check to see if they are the same direction
if (oldDelta < 0 && newDelta < 0) {
//check to see if the new is lower
if (oldDelta > newDelta) {
fireEvent = true;
} else {
fireEvent = false;
}
}
} else {
fireEvent = true;
}
oldDelta = newDelta;
} else {
fireEvent = true;
}
您可以在此处看到已实施的修复:https://sandbox.idev.ge/roomshotel/html5_v2/ 但这是一个成功/失败。
【问题讨论】:
-
这是一个类似的问题,似乎已得到解答:stackoverflow.com/questions/17798091/…
-
@sphanley debounce 让它变得更糟。我已经尝试过该帖子中的解决方案,但它并没有真正起作用。
-
好的!只是觉得它看起来可能是相关的。祝你好运!
-
@sphanley 它肯定是相关的,但解决方案甚至无法接受。我的解决方案效果更好。
-
如果您能说出问题是否已解决以及提供的答案有多大用处,我将不胜感激。如果没有要求的精确,我们鼓励您给我们更详细的描述。附言网页设计精美。恭喜!
标签: javascript jquery macos scroll