Last active
August 29, 2015 14:24
-
-
Save IGGY-MODEL/5fff854c05811c1b2d29 to your computer and use it in GitHub Desktop.
Смена экранов одностраничного сайта (вертикально)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Change window</title> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css"/> | |
| <link href='http://fonts.googleapis.com/css?family=Titillium+Web:400,300italic,200,200italic,300,400italic,600,600italic,700,700italic,900' rel='stylesheet' type='text/css'> | |
| <link rel="stylesheet" href="css/main.css"> | |
| <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> | |
| <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> | |
| <!--[if lt IE 9]> | |
| <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | |
| <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | |
| <![endif]--> | |
| </head> | |
| <body> | |
| <div class="wrapper"> | |
| <div class="maincontent"> | |
| <section class="page one"> | |
| <h1>Hi, I am a section #1</h1> | |
| </section> | |
| <section class="page two"> | |
| <h1>Hi, I am a section #2</h1> | |
| </section> | |
| <section class="page three"> | |
| <h1>Hi, I am a section #3</h1> | |
| </section> | |
| </div> | |
| </div> | |
| <!-- jQuery --> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> | |
| <script src="libs/jquery-mousewheel-master/jquery.mousewheel.js"></script> | |
| <script src="js/main.js"></script> | |
| </body> | |
| </html> | |
| <!-- END HTML --> | |
| /*main.css*/ | |
| html, body { | |
| margin: 0; | |
| padding: 0; | |
| height: 100%; | |
| width: 100%; | |
| } | |
| body { | |
| color: #222; | |
| font-family: 'Titillium Web', sans-serif; | |
| font-size: 14px; | |
| box-sizing: border-box; | |
| } | |
| h1 { | |
| /* margin: 0; | |
| padding: 0;*/ | |
| display: inline-block; | |
| } | |
| .container { | |
| display: block; | |
| width: 1200px; | |
| margin: 0 auto; | |
| } | |
| .clearfix:after, | |
| .clearfix, | |
| .clearfix:before { | |
| content: ''; | |
| display: table; | |
| clear: both; | |
| } | |
| .wrapper { | |
| height: 100%; | |
| overflow: hidden; | |
| } | |
| .maincontent { | |
| width: 100%; | |
| height: 100%; | |
| position: relative; | |
| top: 0; | |
| -webkit-transition: top 1s ease-in-out; | |
| -moz-transition: top 1s ease-in-out; | |
| -ms-transition: top 1s ease-in-out; | |
| -o-transition: top 1s ease-in-out; | |
| transition: top 1s ease-in-out; | |
| } | |
| .page { | |
| display: inline-block; | |
| width: 100%; | |
| height: 100%; | |
| color: #fff; | |
| position: relative; | |
| } | |
| .page.one{ | |
| background: purple; | |
| text-align: center; | |
| } | |
| .page.two{ | |
| background: #f35; | |
| text-align: center; | |
| } | |
| .page { | |
| background: #1f9; | |
| text-align: center; | |
| } | |
| /*END main.css*/ | |
| /*main.js*/ | |
| $(document).ready(function() { | |
| var | |
| curScreen = 0, | |
| container = $('.maincontent'), | |
| pages = $('.page'), | |
| inScroll = false; | |
| $('.page:first-child').addClass('active'); | |
| $('body').on('mousewheel', function(event) { | |
| var activePage = pages.filter('.active'); | |
| if (!inScroll) { | |
| inScroll = true; | |
| if (event.deltaY > 0) { | |
| if (activePage.prev().length) {curScreen--;} | |
| } else { | |
| if (activePage.next().length) {curScreen++;} | |
| } | |
| } | |
| var | |
| position = (-curScreen*100) + '%'; | |
| pages.eq(curScreen).addClass('active').siblings().removeClass('active'); | |
| container.css('top', position); | |
| setTimeout(function () { | |
| inScroll = false; | |
| }, 1300); | |
| }); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment