(function ($) {
var types = ['DOMMouseScroll', 'mousewheel'];
$.event.special.mousewheel = {
set for (var i = types .length; i;) {
this.addEventListener(types[--i], handler, } else {
this.onmouse輪子= 處理程序;
;
; }
},
拆解: function () {
for (var i = types.length; i;) {
this.removeEventListener(類型[-- i], handler, false);
}
usewheel = null;
}
}
};
. }
};
. extend({
滑鼠滾輪:函數(fn) {
return fn ?( },
unmousewheel:函數(fn) {
return this.unbind("mousewheel", fn);
}
);
函式處理程序(事件){
var orgEvent = 事件|| window.event, args = [].slice.call(arguments, 1), delta = 0, returnValue = , deltadelta = 0;
event = $.event.fix(orgEvent);
event.type = "mousewheel"; if (event.originalEvent.detail) { delta = -event.originalEvent.detail / 3 > deltaY = delta;
// Gecko
if (orgEvent.axis !== undefined && 0;
deltaX = -1 * delta;
}
// Webkit
if (orgEvent.wheelattaY !== 錯誤 if (orgEvent.wheelDeltaX !== undefined) { deltaX = - 1 * orgEvent.wheelDeltaX / 120; }
// 將event 與delta 加到參數前面
args.unshift(event, deleventta, .X args.unshift(event, deleventta, )X handle.apply( this, args);
}
})(jQuery);
呼叫:
$(document).mousewheel(function (e,detail) {
}