Jquery. mousewheel implements the screen flip effect on the whole screen. jquery. mousewheel

Source: Internet
Author: User
Tags jquery library

Jquery. mousewheel implements the screen flip effect on the whole screen. jquery. mousewheel

Achieve the full screen flip effect:
Js to be loaded

<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script><script type="text/javascript" src="js/jquery.mousewheel.js"></script>

The css style is as follows:

body{padding:0;margin:0; overflow:hidden }ul{list-style:none;}.content{width:100%;height100%;position:relative;top:0;}.div_01,.div_02,.div_03,.div_04{width:100%;margin:0 auto; text-align: center;}.div_01{background: #b20909;}.div_02{background: #0941b2;}.div_03{background: #2db209;}.div_04{background: #b29c09;}.left_fixed{position:fixed;width:15px; height:100px; left:100px;top:200px;z-index:999;}.left_fixed ul li{  background:#000;cursor:pointer;width:15px;height: 15px;  border-radius:15px;margin-bottom: 10px;}.left_fixed ul li.active{background:#fff;}

The jquery code is as follows:

Var page = 0; // The Screen flip variable. The initial screen is var shakStaute = 0; // This variable acts as a jitter when the mouse pulley is sliding down or up. $ (function () {var starttime = 0, endtime = 0; $ ("body "). mousewheel (function (event, delta) {starttime = new Date (). getTime (); // record the initial time of screen flip if (delta <0 & page> = 0 & page <= $ (". content. divsame "). length-2) {if (shakStaute> = 0 & (starttime = 0 | (endtime-starttime) <=-500 )) {// execute a screen flip shakStaute = 1; page ++; renderPage (page, true) within ms; // The Screen flip function endtime = new Date (). getTime (); // record the screen flip end time} else if (delta> 0 & page> = 1 & shakStaute = 1 & (starttime = 0 | (endtime- starttime) <=-500) {page --; renderPage (page, true); endtime = new Date (). getTime () ;}}); var div_height =$ (window ). height (); $ (". divsame ").css ({'height': div_height}); $ (window ). resize (function () {div_height = $ (window ). height (); $ (". divsame "2.16.css ({'height': div_height}); $ ('. content '). animate ({top:-page * div_height}, 100) ;}); $ (". left_fixed ul li "). on ("click", function () {// click the navigation bar and run var index = $ (this ). index (); if (index> 0) {shakStaute = 1 ;}page = index; renderPage (page, true); $ (". left_fixed ul li "). removeClass ("active"); $ (this ). addClass ("active"); return false;}); function renderPage (pageNumber, isScroll) {if (isScroll) {$ ('. content '). animate ({top:-pageNumber * div_height}, 'low'); $ (". left_fixed ul li "). removeClass ("active"); $ (". left_fixed ul li "). eq (pageNumber ). addClass ("active") ;}return ;}})

It is also a real-time response.

Let's look at an example.

Pay attention to the index. js implemented by js, jquery library, and mousewheel. js loaded in the header.

<!doctype html>

The jquery code is as follows (index. js ):

Var I = 0; // The Screen flip variable. The initial screen is var s = 0; // This variable acts as a jitter when the mouse pulley is sliding down or up. $ (function () {var starttime = 0, endtime = 0; $ ("body "). mousewheel (function (event, delta) {starttime = new Date (). getTime (); // record the initial time of screen flip if (delta <0 & I> = 0 & I <= 2) {if (s> = 0 & (starttime = 0 | (endtime-starttime) <=-500 )) {// perform screen flip s = 1 within ms; I ++; renderPage (I, true); // The Screen flip function endtime = new Date (). getTime (); // record the screen flip end time} else if (delta> 0 & I> = 1 & s = 1 & (starttime = 0 | (endtime- starttime) <=-500) {I --; // console. log (I); renderPage (I, true); endtime = new Date (). getTime () ;}}); var div_height =$ (window ). height (); $ (". div_01 ,. div_02 ,. div_03 ,. div_04 ").css ({'height': div_height}); $ (window ). resize (function () {var div_height = $ (window ). height (); $ (". div_01 ,. div_02 ,. div_03 ,. div_04 "pai.css ({'height': div_height}) ;}); function renderPage (pageNumber, isScroll) {if (isScroll) {$ ('body, html '). animate ({scrollTop: pageNumber * div_height}, 'low'); $ (". left_fixed ul li "). removeClass ("active"); $ (". left_fixed ul li "). eq (pageNumber ). addClass ("active") ;}return ;}$ (". left_fixed ul li "). on ("click", function () {// click the navigation bar and run var index = $ (this ). index (); renderPage (index, true); $ (". left_fixed ul li "). removeClass ("active"); $ (this ). addClass ("active"); return false ;});})

Related Article

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.