_mouseWheeled: function(/*Event*/ evt){
// summary:
// Mouse wheel listener where supported
if (!this.focused) return;
...
不过,正确的方法是扩展小部件。
// Disable _mouseWheeled when not in focus.
require(
[
"dojo/_base/lang"
, "dojo/_base/event"
, "dijit/form/_Spinner"
]
, function(
lang
, event
, _Spinner
){
lang.extend(_Spinner, {
_mouseWheeled: function(/*Event*/ evt){
// summary:
// Mouse wheel listener where supported
if (!this.focused) return;
event.stop(evt);
// FIXME: Safari bubbles
// be nice to DOH and scroll as much as the event says to
var wheelDelta = evt.wheelDelta / 120;
if(Math.floor(wheelDelta) != wheelDelta){
// If not an int multiple of 120, then its touchpad scrolling.
// This can change very fast so just assume 1 wheel click to make it more manageable.
wheelDelta = evt.wheelDelta > 0 ? 1 : -1;
}
var scrollAmount = evt.detail ? (evt.detail * -1) : wheelDelta;
if(scrollAmount !== 0){
var node = this[(scrollAmount > 0 ? "upArrowNode" : "downArrowNode" )];
this._arrowPressed(node, scrollAmount, this.smallDelta);
if(!this._wheelTimer){
clearTimeout(this._wheelTimer);
}
this._wheelTimer = setTimeout(lang.hitch(this,"_arrowReleased",node), 50);
}
}
});
}
);
2条答案
按热度按时间dz6r00yl1#
如果你从来不需要它,并且你可以访问dojo源代码,并且能够自己构建,请在dijit/form/_Spinner. js上注解这一行:
或者,您可以在小部件上将intermediateChanges属性设置为true,并执行如下操作:
在您的html中:
在您的javascript块中:
vojdkbi02#
一个快速而肮脏的方法是,将
if (!this.focused) return;
添加到dijit/form/_Spinner.js
中_mouseWheeled
的顶部,以使鼠标滚轮仅在小部件具有焦点时工作。不过,正确的方法是扩展小部件。