var x = null;
var y = null;
$(document).mousemove(function(e){
x = e.pageX;
y = e.pageY;
});
var scrollFunc = function(e) {
var e = e || window.event;
var m = null;
if(e.wheelDelta) {
m = e.wheelDelta;
if(e.wheelDelta > 0) { //当鼠标滚轮向上滚动时
divMousemove(1);
}
if(e.wheelDelta < 0) { //当鼠标滚轮向下滚动时
divMousemove(2);
}
} else if(e.detail) {
m = e.detail;
if(e.detail < 0) { //当鼠标滚轮向上滚动时
divMousemove(1);
}
if(e.detail > 0) { //当鼠标滚轮向下滚动时
divMousemove(2);
}
}
function divMousemove(upward){
var btnList = $('.right_btn_block');//获取你想要的DIV
var y1 = btnList.offset().top; //div上面两个的点的y值
var y2 = y1 + btnList.height();//div下面两个点的y值
var x1 = btnList.offset().left; //div左边两个的点的x值
var x2 = x1 + btnList.width(); //div右边两个点的x的值
if( x < x1 || x > x2 || y < y1 || y > y2){
// console.log('鼠标不在该DIV中');
}else{
// console.log('鼠标在该DIV中');
if(upward == 1){
//鼠标在该元素区域内向上滚动
}else if(upward == 2){
//鼠标在该元素区域内向下滚动
}
};
}
}
// 给页面绑定鼠标滚轮事件,针对火狐的非标准事件
window.addEventListener("DOMMouseScroll", scrollFunc);
// 给页面绑定鼠标滚轮事件,针对Google,mousewheel非标准事件已被弃用,请使用 wheel事件代替
window.addEventListener("wheel", scrollFunc);
// ie不支持wheel事件,若一定要兼容,可使用mousewheel
window.addEventListener("mousewheel", scrollFunc);