JS Mouse scroll up and down monitoring event application instance (cross-browser, pro-test)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.