JS Roll Rotation Cutting screen

Source: Internet
Author: User

Because the whole project is not written by themselves, but to help others to write JS roller code, and other projects are still not on-line, so just post their own part of the code,

Effect: When the mouse wheel scrolls, the screen of one screen and one screen up and down switch

(The following code in the local computer's ie,chrome and Firefox these three browsers have been tested and have been successful)

    var sum=0;    var Otxt=document.getelementbyid ("txt");    var scrollfunc=function (e) {var direct=0;    var men = $ (". Menu_m"). Find (". Menu"). Find ("Li");            Men.each (function (j) {if ($ (this). attr ("class") = = "M_selected") {sum=j;    }    }); e=e | |    window.event;            if (E.wheeldelta) {//ie/opera/chrome if (navigator.appname== ' Netscape ') {//Chorme roll once with two effects, so add 0.5                            if (e.wheeldelta>0) {sum=parsefloat (sum-0.5);            } else{sum=parsefloat (sum) +0.5;            }}else{if (e.wheeldelta>0) sum=parsefloat (sum-1);        else Sum=parsefloat (sum+1); }else if (e.detail) {//firefox//firefox up-down values are not the same as above, you can print out to see if (e.detail>0) sum=parsefloat (sum+            1);    else Sum=parsefloat (sum-1); }//sum out of the, here is what you want to do, I am here to write with the current project has so associated with the screen jump, but rememberTo add a return false;        Otherwise, in Google and IE, will appear, rolled more than the Var sizes= $ (". Menu_m"). Find (". Menu"). Find ("Li"). Size (); if (sum>=0&&parsefloat (sum) <=parsefloat (sizes)-1) {Men.each (function (j) {$ (this).              Removeclass ("m_selected")});              $ (". Menu_m"). Find (". Menu Li:eq (" +sum+ ")"). Find ("span"). Click ();          return false; }}/* Register Event */if (document.addeventlistener) {document.addeventlistener (' dommousescroll ', Scrollfunc,false);} W3cwindow.onmousewheel=document.onmousewheel=scrollfunc;//ie/opera/chrome/safari

JS Roll Rotation Cutting screen

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.