Recent projects related to multiple div switching effects, including the normal button click Switch and the mouse wheel scroll up and down, and so on; its main content is the mouse wheel up and down switching event monitoring, here is the first contact, so record here, but also hope to help you have the need of friends.
The following is a project instance:
$ (function () {
var count = $ ("#sysCount"). Val ();
var isUp = false;
Initializing the Subsystem module
if (Count > 6) {
$ ("#panel"). CSS ("width", "1200px");
$ (". Line2"). CSS ("width", "550px");
$ (". Hoverbtn"). CSS ("Display", "block");
for (var i = 6; i < count; i++) {
$ ("#sys" + i). CSS ("display", "none");
}
$ ("#lastBtn"). Hover (function () {
if (start! = 0) {
$ (this). Toggleclass ("Hoverbtntog");
}
});
$ ("#nextBtn"). Hover (function () {
if (Count-start! = 6) {
$ (this). Toggleclass ("Hoverbtntog");
}
});
Mouse Wheel Event
var Isfirefox = navigator.userAgent.indexOf ("Firefox")! =-1;
Firefox events: Dommousescroll, Ie/opera/chrome event: MouseWheel
var mousewheel = Isfirefox? "Dommousescroll": "MouseWheel";
Mouse scrolling Events
var scrollfunc = function (e) {
E = e | | window.event;
When the mouse is within the Subsystem Area: Screen window wheel-scroll scroll bar event;
The subsystem scrolling method is only called at this time
if (isUp) {
E = e | | window.event;
if (e.stoppropagation) e.stoppropagation ();
else e.cancelbubble = true;
if (E.preventdefault) E.preventdefault ();
else E.returnvalue = false;
if (Isfirefox) {
if (E.detail = =-3) {
Scroll up
GetLast ();
} else {
Scroll down
GetNext ();
}
}else{
if (E.wheeldelta = = 120) {
Scroll up
GetLast ();
} else {
Scroll up
GetNext ();
}
}
}
};
Document.addeventlistener (MouseWheel, Scrollfunc, false);
$ ("#hor"). MouseOver (function () {
IsUp = true;
});
$ ("#hor"). MouseLeave (function () {
IsUp = false;
});
}
});
JS Mouse scroll up and down monitoring event application instance (cross-browser, pro-test)