Created
July 11, 2015 15:13
-
-
Save IGGY-MODEL/a46bdfed6bbb4c0d91f3 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
| <!-- HTML --> | |
| <!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> | |
| <!-- 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: 300%; | |
| height: 100%; | |
| position: relative; | |
| left: 0; | |
| -webkit-transition: left 1s ease-in-out; | |
| -moz-transition: left 1s ease-in-out; | |
| -ms-transition: left 1s ease-in-out; | |
| -o-transition: left 1s ease-in-out; | |
| transition: left 1s ease-in-out; | |
| } | |
| .page { | |
| display: inline-block; | |
| width: 33.333%; | |
| height: 100%; | |
| color: #fff; | |
| /*position: relative;*/ | |
| float: left; | |
| } | |
| .page.one{ | |
| background: purple; | |
| text-align: center; | |
| } | |
| .page.two{ | |
| background: #f35; | |
| text-align: center; | |
| } | |
| .page { | |
| background: #1f9; | |
| text-align: center; | |
| } | |
| /*END 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('left', position); | |
| setTimeout(function () { | |
| inScroll = false; | |
| }, 1300); | |
| }); | |
| }); | |
| /*END JS*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment