Repository: peachananr/onepage-scroll
Branch: master
Commit: c805fbe98dcb
Files: 8
Total size: 55.5 KB
Directory structure:
gitextract_jwtbp1dq/
├── Demo/
│ ├── demo.html
│ ├── jquery.onepage-scroll.js
│ └── onepage-scroll.css
├── README.md
├── _config.yml
├── bower.json
├── jquery.onepage-scroll.js
└── onepage-scroll.css
================================================
FILE CONTENTS
================================================
================================================
FILE: Demo/demo.html
================================================
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery One Page Scroll by Pete R. | The Pete Design</title>
<meta name="title" content="jQuery One Page Scroll by Pete R. | The Pete Design" />
<meta name="description" content="Create an Apple-like one page scroller website (iPhone 5S website) with One Page Scroll plugin" />
<link rel="image_src" href="/images/notify_better_image.png" />
<meta content="https://www.thepetedesign.com/demos/onepage_scroll_demo.html" property="og:url" />
<meta content="https://www.thepetedesign.com/images/onepage_scroll_image.png" property="og:image" />
<link rel="shortcut icon" id="favicon" href="favicon.png">
<meta name="author" content="Pete R.">
<link rel="canonical" href="https://www.thepetedesign.com/demos/onepage_scroll_demo.html" />
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Pacifico:400' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="jquery.onepage-scroll.js"></script>
<link href='onepage-scroll.css' rel='stylesheet' type='text/css'>
<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, minimum-scale=1, user-scalable=no">
<style>
html {
height: 100%;
}
body {
background: #E2E4E7;
padding: 0;
text-align: center;
font-family: 'open sans';
position: relative;
margin: 0;
height: 100%;
-webkit-font-smoothing: antialiased;
}
.wrapper {
height: 100% !important;
height: 100%;
margin: 0 auto;
overflow: hidden;
}
a {
text-decoration: none;
}
h1, h2 {
width: 100%;
float: left;
}
h1 {
margin-top: 100px;
color: #000;
margin-bottom: 5px;
font-size: 70px;
letter-spacing: -4px;
font-weight: 100;
}
h1 span {
font-size: 26px;
margin: 0 5px;
text-transform: capitalize;
background: rgba(0,0,0,0.85);
display: inline-block;
color: #6D461D;
border-radius: 5px 5px;
-webkit-border-radius: 5px 5px;
-moz-border-radius: 5px 5px;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.75);
padding: 3px 10px;
}
h2 {
color: #6D461D;
font-weight: 100;
margin-top: 0;
margin-bottom: 10px;
}
.pointer {
color: #9b59b6;
font-family: 'Pacifico', cursive;
font-size: 30px;
margin-top: 15px;
}
code {
margin: 20px 1%;
float: left;
width: 48%;
height: 105px;
background: rgba(0,0,0,0.1);
border: rgba(0,0,0,0.05) 5px solid;
border-radius: 5px;
padding:5px;
color: white;
text-align: center;
font-size: 15px;
margin-top: 25px;
display: block;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
code.html {
color: #7EC9E6;
}
code.js {
color: #FFAD00;
}
.main {
float: left;
width: 100%;
margin: 0 auto;
}
.main h1 {
padding:150px 50px;
float: left;
width: 100%;
font-size: 45px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
font-weight: 100;
color: white;
margin: 0;
}
.main h1.demo1 {
background: #1ABC9C;
}
.reload.bell {
font-size: 12px;
padding: 20px;
width: 45px;
text-align: center;
height: 47px;
border-radius: 50px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
}
.reload.bell #notification {
font-size: 25px;
line-height: 140%;
}
.reload, .btn{
display: inline-block;
border: 4px solid #A2261E;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background: #CC3126;
display: inline-block;
line-height: 100%;
padding: 0.7em;
text-decoration: none;
color: #fff;
width: 100px;
line-height: 140%;
font-size: 17px;
font-family: open sans;
font-weight: bold;
}
.reload:hover{
background: #444;
}
.btn {
width: 200px;
color: rgb(255, 255, 255);
border: 4px solid rgb(0, 0, 0);
background: rgba(3, 3, 3, 0.75);
}
.clear {
width: auto;
}
.btn:hover, .btn:hover {
background: #444;
}
.btns {
width: 410px;
margin: 50px auto;
}
.credit {
text-align: center;
color: rgba(0,0,0,0.5);
padding: 10px;
width: 410px;
clear: both;
}
.credit a {
color: rgba(0,0,0,0.85);
text-decoration: none;
font-weight: bold;
text-align: center;
}
.back {
position: absolute;
top: 0;
left: 0;
text-align: center;
display: block;
padding: 7px;
width: 100%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
background: rgba(255, 255, 255, 0.25);
font-weight: bold;
font-size: 13px;
color: #000;
-webkit-transition: all 500ms ease-in-out;
-moz-transition: all 500ms ease-in-out;
-o-transition: all 500ms ease-in-out;
transition: all 500ms ease-in-out;
}
.back:hover {
color: black;
background: rgba(255, 255, 255, 0.5);
}
header {
position: relative;
z-index: 10;
}
.main section .page_container {
position: relative;
top: 25%;
margin: 0 auto 0;
max-width: 950px;
z-index: 3;
}
.main section {
overflow: hidden;
}
.main section > img {
position: absolute;
max-width: 100%;
z-index: 1;
}
.main section.page1 {
background:rgb(230, 217, 200);
}
.main section.page1 h1 {
text-align: left;
padding: 0;
margin-bottom: 15px;
font-size: 70px;
color: black;
}
.main section.page1 h2 {
color: rgba(0,0,0,0.85);
text-align: center;
width: 435px;
line-height: 160%;
}
.main section .page_container .btns {
clear: both;
float: left;
text-align: center;
width: 435px;
}
.main section .page_container .btns a{
text-align: center;
}
.main section.page2 {
background: #555557 url(back-phone.png) no-repeat center -150px ;
}
.main section.page2 > img {
position: absolute;
top: -300px;
left: 50%;
margin-left: -1095px;
}
.main section.page2 .page_container {
margin-top: 240px;
overflow: hidden;
}
.main section.page2 h1 {
text-align: center;
padding: 0;
margin-bottom: 15px;
font-size: 50px;
letter-spacing: -1px;
color: white;
}
.main section.page2 h2 {
color: rgba(255,255,255,0.85);
text-align: center;
line-height: 160%;
font-weight: 100;
}
.viewing-page-2 .back{
background: rgba(0, 0, 0, 0.25);
color: #FFF;
}
.main section.page3 {
background:url(tilted-phone.png) no-repeat 156px -150px ;
}
.main section.page3 .page_container {
overflow: hidden;
width: 500px;
right: -285px;
}
.main section.page3 h1 {
text-align: left;
padding: 0;
margin-bottom: 0;
font-size: 70px;
letter-spacing: -1px;
color: black;
}
.main section.page3 h2 {
color: rgba(0,0,0,0.85);
text-align: left;
line-height: 160%;
font-weight: 100;
font-size: 21px;
}
body.disabled-onepage-scroll .onepage-wrapper section {
min-height: 100%;
height: auto;
}
body.disabled-onepage-scroll .main section .page_container, body.disabled-onepage-scroll .main section.page3 .page_container {
padding: 20px;
margin-top: 150px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body.disabled-onepage-scroll section .page_container h1{
text-align: center;
font-size: 50px;
}
body.disabled-onepage-scroll section .page_container h2, body.disabled-onepage-scroll section .page_container .credit, body.disabled-onepage-scroll section .page_container .btns{
text-align: center;
width: 100%;
}
body.disabled-onepage-scroll .main section.page1 > img {
position: absolute;
width: 80%;
left: 10%;
}
body.disabled-onepage-scroll .main section > img {
position: relative;
max-width: 80%;
bottom: 0;
}
body.disabled-onepage-scroll code {
width: 95%;
margin: 0 auto 25px;
float: none;
overflow: hidden;
}
body.disabled-onepage-scroll .main section.page3 .page_container {
width: 90%;
margin-left: auto;
margin-right: auto;
right: 0;
}
body .one .bsa_it_ad { background: transparent; border: none; font-family: inherit; padding: 0 15px 0 10px; margin: 0; text-align: center; }
body .one .bsa_it_ad:hover img { -moz-box-shadow: 0 0 3px #000; -webkit-box-shadow: 0 0 3px #000; box-shadow: 0 0 3px #000; }
body .one .bsa_it_ad .bsa_it_i { display: block; padding: 0; float: none; margin: 0 0 5px; }
body .one .bsa_it_ad .bsa_it_i img { padding: 0; border: none; }
body .one .bsa_it_ad .bsa_it_t { padding: 6px 0; }
body .one .bsa_it_ad .bsa_it_d { padding: 0; font-size: 12px; color: #333; }
body .one .bsa_it_p { display: none; }
body #bsap_aplink, body #bsap_aplink:hover { display: block; font-size: 10px; margin: 12px 15px 0; text-align: center; }
.ads {
position: fixed;
left: 10px;
bottom: 10px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
z-index: 99;
text-align: center;
max-width: 200px;
}
.ads a {
color: black;
}
.ad-header {
margin: 0 0 -2px 0px;
background: white;
border-radius: 3px 3px 0 0;
overflow: hidden;
}
.ad-header a {
float: right;
border-left: 1px solid #f3f3f3;
padding:10px;
line-height: 100%;
font-weight: bold;
text-transform: uppercase;
text-align: center;
color: black;
}
.ad-header a:hover {
background: #eee;
}
.ads .promo {
position: absolute;
top: -195px;
left: 0;
}
.message {
max-width: 550px;
margin: 50px auto 0;
padding: 14px;
background: #72EC80;
color: #0E530E;
font-weight: normal;
font-style: normal;
border-radius: 3px;
}
.success-message a{
color: black;
border-bottom: 1px dotted #000;
}
.success-message {
background: #72EC80;
color: #0E530E;
}
.error-message a{
color: #FFF;
border-bottom: 1px dotted #fff;
}
.error-message {
background: #EC7272;
color: #FFF;
}
.socials {
text-align: center;
background: rgba(255, 255, 255, 0.1);
width: 100%;
float: left;
padding: 9px 5px 5px;
margin: 0 0 60px 0;
}
.socials > * {
display: inline !important;
}
.socials .fb-like {
top: -5px;
min-width: 85px;
text-align: left;
}
.socials .fb-like > span {
vertical-align: top;
}
.socials .twitter-share-button {
width: 85px !important;
}
#carbonads {
--width: 180px;
--font-size: 14px;
}
#carbonads {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
display: block;
overflow: hidden;
margin-bottom: 20px;
max-width: var(--width);
border-radius: 4px;
text-align: center;
box-shadow: 0 0 0 1px hsla(0, 0%, 0%, .1);
background-color: hsl(0, 0%, 98%);
font-size: var(--font-size);
line-height: 1.5;
}
#carbonads a {
color: inherit;
text-decoration: none;
}
#carbonads a:hover {
color: inherit;
}
#carbonads span {
position: relative;
display: block;
overflow: hidden;
}
.carbon-img {
display: block;
margin-bottom: 8px;
max-width: var(--width);
line-height: 1;
}
.carbon-img img {
display: block;
margin: 0 auto;
max-width: var(--width) !important;
width: var(--width);
height: auto;
}
.carbon-text {
display: block;
padding: 0 1em 8px;
}
.carbon-poweredby {
display: block;
padding: 10px var(--font-size);
background: repeating-linear-gradient(-45deg, transparent, transparent 5px, hsla(0, 0%, 0%, .025) 5px, hsla(0, 0%, 0%, .025) 10px) hsla(203, 11%, 95%, .4);
text-transform: uppercase;
letter-spacing: .5px;
font-weight: 600;
font-size: 9px;
line-height: 0;
}
@media only screen and (min-width: 320px) and (max-width: 759px) {
#carbonads {
float: none;
margin: 0 auto;
max-width: 330px;
}
#carbonads span {
position: relative;
}
#carbonads > span {
max-width: none;
}
.carbon-img {
float: left;
margin: 0;
}
.carbon-img img {
max-width: 130px !important;
}
.carbon-text {
float: left;
margin-bottom: 0;
padding: 8px 20px;
text-align: left;
max-width: calc(100% - 130px - 3em);
}
.carbon-poweredby {
left: 130px;
bottom: 0;
display: block;
width: 100%;
}}}
</style>
<script>
$(document).ready(function(){
$(".main").onepage_scroll({
sectionContainer: "section",
responsiveFallback: 600,
loop: true
});
});
</script>
</head>
<body>
<div class="wrapper">
<!-- AdPacks.com Zone Code -->
<div class="ads">
<script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CKYI5KJE&placement=wwwthepetedesigncom" id="_carbonads_js"></script>
</div>
<!-- End AdPacks.com Zone Code -->
<div class="main">
<section class="page1">
<div class="page_container">
<h1>One Page Scroll</h1>
<h2>Create an Apple-like one page scroller website (iPhone 5S website) with One Page Scroll plugin</h2>
<p class="credit">Created by <a href="https://www.thepetedesign.com">Pete R.</a>, Founder of <a href="https://www.bucketlistly.com" target="_blank">BucketListly</a></p>
<div class="btns">
<a class="reload btn" href="https://github.com/peachananr/onepage-scroll">Download on Github</a>
</div>
</div>
<img src="phones.png" alt="phones">
</section>
<section class="page2">
<div class="page_container">
<h1>Ready-to-use plugin</h1>
<h2>All you need is an HTML markup, call the script and BAM!</h2>
<code class="html">
<div class="main"><br>
<section>...</section><br>
<section>...</section><br>
...<br>
</div>
</code>
<code class="js">
$(".main").onepage_scroll();
</code>
</div>
</section>
<section class="page3">
<div class="page_container">
<h1>Pretty Neat Eh?</h1>
<h2>You can customise the animation timing, the selector or even the animation easing using CSS3. I can't wait to see what you guys will come up with. Don't forget to grab them for free on Github'</h2>
<div class="btns">
<a class="reload btn" href="https://github.com/peachananr/onepage-scroll">Download on Github</a>
</div>
</div>
</section>
</div>
<a class="back" href="https://www.thepetedesign.com/#design">Back to The Pete Design</a>
</div>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-11278966-3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-11278966-3');
</script>
</body>
</html>
================================================
FILE: Demo/jquery.onepage-scroll.js
================================================
/* ===========================================================
* jquery-onepage-scroll.js v1.3.1
* ===========================================================
* Copyright 2013 Pete Rojwongsuriya.
* http://www.thepetedesign.com
*
* Create an Apple-like website that let user scroll
* one page at a time
*
* Credit: Eike Send for the awesome swipe event
* https://github.com/peachananr/onepage-scroll
*
* License: GPL v3
*
* ========================================================== */
!function($){
var defaults = {
sectionContainer: "section",
easing: "ease",
animationTime: 1000,
pagination: true,
updateURL: false,
keyboard: true,
beforeMove: null,
afterMove: null,
loop: true,
responsiveFallback: false,
direction : 'vertical'
};
/*------------------------------------------------*/
/* Credit: Eike Send for the awesome swipe event */
/*------------------------------------------------*/
$.fn.swipeEvents = function() {
return this.each(function() {
var startX,
startY,
$this = $(this);
$this.bind('touchstart', touchstart);
function touchstart(event) {
var touches = event.originalEvent.touches;
if (touches && touches.length) {
startX = touches[0].pageX;
startY = touches[0].pageY;
$this.bind('touchmove', touchmove);
}
}
function touchmove(event) {
var touches = event.originalEvent.touches;
if (touches && touches.length) {
var deltaX = startX - touches[0].pageX;
var deltaY = startY - touches[0].pageY;
if (deltaX >= 50) {
$this.trigger("swipeLeft");
}
if (deltaX <= -50) {
$this.trigger("swipeRight");
}
if (deltaY >= 50) {
$this.trigger("swipeUp");
}
if (deltaY <= -50) {
$this.trigger("swipeDown");
}
if (Math.abs(deltaX) >= 50 || Math.abs(deltaY) >= 50) {
$this.unbind('touchmove', touchmove);
}
}
}
});
};
$.fn.onepage_scroll = function(options){
var settings = $.extend({}, defaults, options),
el = $(this),
sections = $(settings.sectionContainer)
total = sections.length,
status = "off",
topPos = 0,
leftPos = 0,
lastAnimation = 0,
quietPeriod = 500,
paginationList = "";
$.fn.transformPage = function(settings, pos, index) {
if (typeof settings.beforeMove == 'function') settings.beforeMove(index);
// Just a simple edit that makes use of modernizr to detect an IE8 browser and changes the transform method into
// an top animate so IE8 users can also use this script.
if($('html').hasClass('ie8')){
if (settings.direction == 'horizontal') {
var toppos = (el.width()/100)*pos;
$(this).animate({left: toppos+'px'},settings.animationTime);
} else {
var toppos = (el.height()/100)*pos;
$(this).animate({top: toppos+'px'},settings.animationTime);
}
} else{
$(this).css({
"-webkit-transform": ( settings.direction == 'horizontal' ) ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
"-webkit-transition": "all " + settings.animationTime + "ms " + settings.easing,
"-moz-transform": ( settings.direction == 'horizontal' ) ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
"-moz-transition": "all " + settings.animationTime + "ms " + settings.easing,
"-ms-transform": ( settings.direction == 'horizontal' ) ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
"-ms-transition": "all " + settings.animationTime + "ms " + settings.easing,
"transform": ( settings.direction == 'horizontal' ) ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
"transition": "all " + settings.animationTime + "ms " + settings.easing
});
}
$(this).one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
if (typeof settings.afterMove == 'function') settings.afterMove(index);
});
}
$.fn.moveDown = function() {
var el = $(this)
index = $(settings.sectionContainer +".active").data("index");
current = $(settings.sectionContainer + "[data-index='" + index + "']");
next = $(settings.sectionContainer + "[data-index='" + (index + 1) + "']");
if(next.length < 1) {
if (settings.loop == true) {
pos = 0;
next = $(settings.sectionContainer + "[data-index='1']");
} else {
return
}
}else {
pos = (index * 100) * -1;
}
if (typeof settings.beforeMove == 'function') settings.beforeMove( next.data("index"));
current.removeClass("active")
next.addClass("active");
if(settings.pagination == true) {
$(".onepage-pagination li a" + "[data-index='" + index + "']").removeClass("active");
$(".onepage-pagination li a" + "[data-index='" + next.data("index") + "']").addClass("active");
}
$("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
$("body").addClass("viewing-page-"+next.data("index"))
if (history.replaceState && settings.updateURL == true) {
var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (index + 1);
history.pushState( {}, document.title, href );
}
el.transformPage(settings, pos, next.data("index"));
}
$.fn.moveUp = function() {
var el = $(this)
index = $(settings.sectionContainer +".active").data("index");
current = $(settings.sectionContainer + "[data-index='" + index + "']");
next = $(settings.sectionContainer + "[data-index='" + (index - 1) + "']");
if(next.length < 1) {
if (settings.loop == true) {
pos = ((total - 1) * 100) * -1;
next = $(settings.sectionContainer + "[data-index='"+total+"']");
}
else {
return
}
}else {
pos = ((next.data("index") - 1) * 100) * -1;
}
if (typeof settings.beforeMove == 'function') settings.beforeMove(next.data("index"));
current.removeClass("active")
next.addClass("active")
if(settings.pagination == true) {
$(".onepage-pagination li a" + "[data-index='" + index + "']").removeClass("active");
$(".onepage-pagination li a" + "[data-index='" + next.data("index") + "']").addClass("active");
}
$("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
$("body").addClass("viewing-page-"+next.data("index"))
if (history.replaceState && settings.updateURL == true) {
var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (index - 1);
history.pushState( {}, document.title, href );
}
el.transformPage(settings, pos, next.data("index"));
}
$.fn.moveTo = function(page_index) {
current = $(settings.sectionContainer + ".active")
next = $(settings.sectionContainer + "[data-index='" + (page_index) + "']");
if(next.length > 0) {
if (typeof settings.beforeMove == 'function') settings.beforeMove(next.data("index"));
current.removeClass("active")
next.addClass("active")
$(".onepage-pagination li a" + ".active").removeClass("active");
$(".onepage-pagination li a" + "[data-index='" + (page_index) + "']").addClass("active");
$("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
$("body").addClass("viewing-page-"+next.data("index"))
pos = ((page_index - 1) * 100) * -1;
if (history.replaceState && settings.updateURL == true) {
var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (page_index - 1);
history.pushState( {}, document.title, href );
}
el.transformPage(settings, pos, page_index);
}
}
function responsive() {
//start modification
var valForTest = false;
var typeOfRF = typeof settings.responsiveFallback
if(typeOfRF == "number"){
valForTest = $(window).width() < settings.responsiveFallback;
}
if(typeOfRF == "boolean"){
valForTest = settings.responsiveFallback;
}
if(typeOfRF == "function"){
valFunction = settings.responsiveFallback();
valForTest = valFunction;
typeOFv = typeof valForTest;
if(typeOFv == "number"){
valForTest = $(window).width() < valFunction;
}
}
//end modification
if (valForTest) {
$("body").addClass("disabled-onepage-scroll");
$(document).unbind('mousewheel DOMMouseScroll MozMousePixelScroll');
el.swipeEvents().unbind("swipeDown swipeUp");
} else {
if($("body").hasClass("disabled-onepage-scroll")) {
$("body").removeClass("disabled-onepage-scroll");
$("html, body, .wrapper").animate({ scrollTop: 0 }, "fast");
}
el.swipeEvents().bind("swipeDown", function(event){
if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
el.moveUp();
}).bind("swipeUp", function(event){
if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
el.moveDown();
});
$(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function(event) {
event.preventDefault();
var delta = event.originalEvent.wheelDelta || -event.originalEvent.detail;
init_scroll(event, delta);
});
}
}
function init_scroll(event, delta) {
deltaOfInterest = delta;
var timeNow = new Date().getTime();
// Cancel scroll if currently animating or within quiet period
if(timeNow - lastAnimation < quietPeriod + settings.animationTime) {
event.preventDefault();
return;
}
if (deltaOfInterest < 0) {
el.moveDown()
} else {
el.moveUp()
}
lastAnimation = timeNow;
}
// Prepare everything before binding wheel scroll
el.addClass("onepage-wrapper").css("position","relative");
$.each( sections, function(i) {
$(this).css({
position: "absolute",
top: topPos + "%"
}).addClass("section").attr("data-index", i+1);
$(this).css({
position: "absolute",
left: ( settings.direction == 'horizontal' )
? leftPos + "%"
: 0,
top: ( settings.direction == 'vertical' || settings.direction != 'horizontal' )
? topPos + "%"
: 0
});
if (settings.direction == 'horizontal')
leftPos = leftPos + 100;
else
topPos = topPos + 100;
if(settings.pagination == true) {
paginationList += "<li><a data-index='"+(i+1)+"' href='#" + (i+1) + "'></a></li>"
}
});
el.swipeEvents().bind("swipeDown", function(event){
if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
el.moveUp();
}).bind("swipeUp", function(event){
if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
el.moveDown();
});
// Create Pagination and Display Them
if (settings.pagination == true) {
if ($('ul.onepage-pagination').length < 1) $("<ul class='onepage-pagination'></ul>").prependTo("body");
if( settings.direction == 'horizontal' ) {
posLeft = (el.find(".onepage-pagination").width() / 2) * -1;
el.find(".onepage-pagination").css("margin-left", posLeft);
} else {
posTop = (el.find(".onepage-pagination").height() / 2) * -1;
el.find(".onepage-pagination").css("margin-top", posTop);
}
$('ul.onepage-pagination').html(paginationList);
}
if(window.location.hash != "" && window.location.hash != "#1") {
init_index = window.location.hash.replace("#", "")
if (parseInt(init_index) <= total && parseInt(init_index) > 0) {
$(settings.sectionContainer + "[data-index='" + init_index + "']").addClass("active")
$("body").addClass("viewing-page-"+ init_index)
if(settings.pagination == true) $(".onepage-pagination li a" + "[data-index='" + init_index + "']").addClass("active");
next = $(settings.sectionContainer + "[data-index='" + (init_index) + "']");
if(next) {
next.addClass("active")
if(settings.pagination == true) $(".onepage-pagination li a" + "[data-index='" + (init_index) + "']").addClass("active");
$("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
$("body").addClass("viewing-page-"+next.data("index"))
if (history.replaceState && settings.updateURL == true) {
var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (init_index);
history.pushState( {}, document.title, href );
}
}
pos = ((init_index - 1) * 100) * -1;
el.transformPage(settings, pos, init_index);
} else {
$(settings.sectionContainer + "[data-index='1']").addClass("active")
$("body").addClass("viewing-page-1")
if(settings.pagination == true) $(".onepage-pagination li a" + "[data-index='1']").addClass("active");
}
}else{
$(settings.sectionContainer + "[data-index='1']").addClass("active")
$("body").addClass("viewing-page-1")
if(settings.pagination == true) $(".onepage-pagination li a" + "[data-index='1']").addClass("active");
}
if(settings.pagination == true) {
$(".onepage-pagination li a").click(function (){
var page_index = $(this).data("index");
el.moveTo(page_index);
});
}
$(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function(event) {
event.preventDefault();
var delta = event.originalEvent.wheelDelta || -event.originalEvent.detail;
if(!$("body").hasClass("disabled-onepage-scroll")) init_scroll(event, delta);
});
if(settings.responsiveFallback != false) {
$(window).resize(function() {
responsive();
});
responsive();
}
if(settings.keyboard == true) {
$(document).keydown(function(e) {
var tag = e.target.tagName.toLowerCase();
if (!$("body").hasClass("disabled-onepage-scroll")) {
switch(e.which) {
case 38:
if (tag != 'input' && tag != 'textarea') el.moveUp()
break;
case 40:
if (tag != 'input' && tag != 'textarea') el.moveDown()
break;
case 32: //spacebar
if (tag != 'input' && tag != 'textarea') el.moveDown()
break;
case 33: //pageg up
if (tag != 'input' && tag != 'textarea') el.moveUp()
break;
case 34: //page dwn
if (tag != 'input' && tag != 'textarea') el.moveDown()
break;
case 36: //home
el.moveTo(1);
break;
case 35: //end
el.moveTo(total);
break;
default: return;
}
}
});
}
return false;
}
}(window.jQuery);
================================================
FILE: Demo/onepage-scroll.css
================================================
body, html {
margin: 0;
overflow: hidden;
-webkit-transition: opacity 400ms;
-moz-transition: opacity 400ms;
transition: opacity 400ms;
}
body, .onepage-wrapper, html {
display: block;
position: static;
padding: 0;
width: 100%;
height: 100%;
}
.onepage-wrapper {
width: 100%;
height: 100%;
display: block;
position: relative;
padding: 0;
-webkit-transform-style: preserve-3d;
}
.onepage-wrapper .section {
width: 100%;
height: 100%;
}
.onepage-pagination {
position: absolute;
right: 10px;
top: 50%;
z-index: 5;
list-style: none;
margin: 0;
padding: 0;
}
.onepage-pagination li {
padding: 0;
text-align: center;
}
.onepage-pagination li a{
padding: 10px;
width: 4px;
height: 4px;
display: block;
}
.onepage-pagination li a:before{
content: '';
position: absolute;
width: 4px;
height: 4px;
background: rgba(0,0,0,0.85);
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
}
.onepage-pagination li a.active:before{
width: 10px;
height: 10px;
background: none;
border: 1px solid black;
margin-top: -4px;
left: 8px;
}
.disabled-onepage-scroll, .disabled-onepage-scroll .wrapper {
overflow: auto;
}
.disabled-onepage-scroll .onepage-wrapper .section {
position: relative !important;
top: auto !important;
left: auto !important;
}
.disabled-onepage-scroll .onepage-wrapper {
-webkit-transform: none !important;
-moz-transform: none !important;
transform: none !important;
-ms-transform: none !important;
min-height: 100%;
}
.disabled-onepage-scroll .onepage-pagination {
display: none;
}
body.disabled-onepage-scroll, .disabled-onepage-scroll .onepage-wrapper, html {
position: inherit;
}
================================================
FILE: README.md
================================================
#One Page Scroll 1.3.1 by Pete R.
Create an Apple-like one page scroll website (iPhone 5S website) with One Page Scroll plugin
Created by [Pete R.](http://www.thepetedesign.com), Founder of [BucketListly](http://www.bucketlistly.com)
License: [Attribution-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/deed.en_US)
## Requirement
jQuery (1.9.0 or later)
note: jQuery 1.9.0 or later is strongly recommended because using jQuery less than 1.8.3 and jquery.onepage-scroll.js together turns out to be a hash-based XSS vulnerabiliry.
see: http://jsfiddle.net/33WJx/
## Demo
[View demo](http://peachananr.github.io/onepage-scroll/Demo/demo.html)
## Compatibility
Modern browsers such as Chrome, Firefox, and Safari on both desktop and smartphones have been tested. Should work fine on IE8 and IE9 as well.
## Basic Usage
One Page Scroll let you transform your website into a one page scroll website that allows users to scroll one page at a time. It is perfect for creating a website in which you want to present something to the viewers. For example, [Apple's iPhone 5S website](http://www.apple.com/iphone-5s/) uses the same technique.
To add this to your website, simply include the latest jQuery library together with `jquery.onepage-scroll.js`, `onepage-scroll.css` into your document's `<head>` and call the function as follows:
````html
<body>
...
<div class="main">
<section>...</section>
<section>...</section>
...
</div>
...
</body>
````
Container "Main" must be one level below the `body` tag in order to make it work full page. Now call the function to activate as follows:
````javascript
$(".main").onepage_scroll({
sectionContainer: "section", // sectionContainer accepts any kind of selector in case you don't want to use section
easing: "ease", // Easing options accepts the CSS3 easing animation such "ease", "linear", "ease-in",
// "ease-out", "ease-in-out", or even cubic bezier value such as "cubic-bezier(0.175, 0.885, 0.420, 1.310)"
animationTime: 1000, // AnimationTime let you define how long each section takes to animate
pagination: true, // You can either show or hide the pagination. Toggle true for show, false for hide.
updateURL: false, // Toggle this true if you want the URL to be updated automatically when the user scroll to each page.
beforeMove: function(index) {}, // This option accepts a callback function. The function will be called before the page moves.
afterMove: function(index) {}, // This option accepts a callback function. The function will be called after the page moves.
loop: false, // You can have the page loop back to the top/bottom when the user navigates at up/down on the first/last page.
keyboard: true, // You can activate the keyboard controls
responsiveFallback: false, // You can fallback to normal page scroll by defining the width of the browser in which
// you want the responsive fallback to be triggered. For example, set this to 600 and whenever
// the browser's width is less than 600, the fallback will kick in.
direction: "vertical" // You can now define the direction of the One Page Scroll animation. Options available are "vertical" and "horizontal". The default value is "vertical".
});
````
And that's it. Now, your website should work the same way Apple's iPhone 5S website does. You should be able to swipe up/down as well (thanks to [Eike Send](https://github.com/eikes) for his swipe events!) when viewing your website on mobile phones.
## Keyboard Shortcuts
You can trigger page move with hotkeys as well:
### Up arrow / Page Up
Pressing the up arrow or the page up key allows you to move the page up by one.
### Down arrow / Page Donw
Pressing the down arrow or the page down key allows you to move the page down by one.
### Spacebar
Pressing the space key allows you to move the page down by one.
### Home
Pressing the home key brings you back to the first page.
### End
Pressing the end key brings you to the last page.
## Public Methods
You can also trigger page move programmatically as well:
### $.fn.moveUp()
This method allows you to move the page up by one. This action is equivalent to scrolling up/swiping down.
````javascript
$(".main").moveUp();
````
### $.fn.moveDown()
This method allows you to move the page down by one. This action is equivalent to scrolling down/swiping up.
````javascript
$(".main").moveDown();
````
### $.fn.moveTo(page_index)
This method allows you to move to the specified page index programatically.
````javascript
$(".main").moveTo(3);
````
## Callbacks
You can use callbacks to perform actions before or after the page move.
### beforeMove(current_page_index)
This callback gets called before the plugin performs its move.
````javascript
$(".main").onepage_scroll({
beforeMove: function(index) {
...
}
});
````
### afterMove(next_page_index)
This callback gets called after the move animation was performed.
````javascript
$(".main").onepage_scroll({
afterMove: function(index) {
...
}
});
````
If you want to see more of my plugins, visit [The Pete Design](http://www.thepetedesign.com/#design), or follow me on [Twitter](http://www.twitter.com/peachananr) and [Github](http://www.github.com/peachananr).
## Other Resources
- [OnePageScroll.js: Creating an Apple’s iPhone 5S Website](http://www.onextrapixel.com/2013/09/18/onepagescroll-js-creating-an-apples-iphone-5s-website/)
- [Eike Send's jQuery Swipe Events](https://github.com/eikes/jquery.swipe-events.js)
- [CSS Easing generator by Matthew Lein](http://matthewlein.com/ceaser/)
================================================
FILE: _config.yml
================================================
theme: jekyll-theme-cayman
================================================
FILE: bower.json
================================================
{
"name": "onepage-scroll",
"version": "1.3.1",
"author": "Pete R",
"main": [
"jquery.onepage-scroll.js",
"onepage-scroll.css"
],
"ignore": [
"Demo",
"README.md"
],
"dependencies": {
"jquery": "~1.10.2"
}
}
================================================
FILE: jquery.onepage-scroll.js
================================================
/* ===========================================================
* jquery-onepage-scroll.js v1.3.1
* ===========================================================
* Copyright 2013 Pete Rojwongsuriya.
* http://www.thepetedesign.com
*
* Create an Apple-like website that let user scroll
* one page at a time
*
* Credit: Eike Send for the awesome swipe event
* https://github.com/peachananr/onepage-scroll
*
* License: GPL v3
*
* ========================================================== */
!function($){
var defaults = {
sectionContainer: "section",
easing: "ease",
animationTime: 1000,
pagination: true,
updateURL: false,
keyboard: true,
beforeMove: null,
afterMove: null,
loop: true,
responsiveFallback: false,
direction : 'vertical'
};
/*------------------------------------------------*/
/* Credit: Eike Send for the awesome swipe event */
/*------------------------------------------------*/
$.fn.swipeEvents = function() {
return this.each(function() {
var startX,
startY,
$this = $(this);
$this.bind('touchstart', touchstart);
function touchstart(event) {
var touches = event.originalEvent.touches;
if (touches && touches.length) {
startX = touches[0].pageX;
startY = touches[0].pageY;
$this.bind('touchmove', touchmove);
}
}
function touchmove(event) {
var touches = event.originalEvent.touches;
if (touches && touches.length) {
var deltaX = startX - touches[0].pageX;
var deltaY = startY - touches[0].pageY;
if (deltaX >= 50) {
$this.trigger("swipeLeft");
}
if (deltaX <= -50) {
$this.trigger("swipeRight");
}
if (deltaY >= 50) {
$this.trigger("swipeUp");
}
if (deltaY <= -50) {
$this.trigger("swipeDown");
}
if (Math.abs(deltaX) >= 50 || Math.abs(deltaY) >= 50) {
$this.unbind('touchmove', touchmove);
}
}
}
});
};
$.fn.onepage_scroll = function(options){
var settings = $.extend({}, defaults, options),
el = $(this),
sections = $(settings.sectionContainer)
total = sections.length,
status = "off",
topPos = 0,
leftPos = 0,
lastAnimation = 0,
quietPeriod = 500,
paginationList = "";
$.fn.transformPage = function(settings, pos, index) {
if (typeof settings.beforeMove == 'function') settings.beforeMove(index);
// Just a simple edit that makes use of modernizr to detect an IE8 browser and changes the transform method into
// an top animate so IE8 users can also use this script.
if($('html').hasClass('ie8')){
if (settings.direction == 'horizontal') {
var toppos = (el.width()/100)*pos;
$(this).animate({left: toppos+'px'},settings.animationTime);
} else {
var toppos = (el.height()/100)*pos;
$(this).animate({top: toppos+'px'},settings.animationTime);
}
} else{
$(this).css({
"-webkit-transform": ( settings.direction == 'horizontal' ) ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
"-webkit-transition": "all " + settings.animationTime + "ms " + settings.easing,
"-moz-transform": ( settings.direction == 'horizontal' ) ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
"-moz-transition": "all " + settings.animationTime + "ms " + settings.easing,
"-ms-transform": ( settings.direction == 'horizontal' ) ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
"-ms-transition": "all " + settings.animationTime + "ms " + settings.easing,
"transform": ( settings.direction == 'horizontal' ) ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
"transition": "all " + settings.animationTime + "ms " + settings.easing
});
}
$(this).one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
if (typeof settings.afterMove == 'function') settings.afterMove(index);
});
}
$.fn.moveDown = function() {
var el = $(this)
index = $(settings.sectionContainer +".active").data("index");
current = $(settings.sectionContainer + "[data-index='" + index + "']");
next = $(settings.sectionContainer + "[data-index='" + (index + 1) + "']");
if(next.length < 1) {
if (settings.loop == true) {
pos = 0;
next = $(settings.sectionContainer + "[data-index='1']");
} else {
return
}
}else {
pos = (index * 100) * -1;
}
if (typeof settings.beforeMove == 'function') settings.beforeMove( next.data("index"));
current.removeClass("active")
next.addClass("active");
if(settings.pagination == true) {
$(".onepage-pagination li a" + "[data-index='" + index + "']").removeClass("active");
$(".onepage-pagination li a" + "[data-index='" + next.data("index") + "']").addClass("active");
}
$("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
$("body").addClass("viewing-page-"+next.data("index"))
if (history.replaceState && settings.updateURL == true) {
var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (index + 1);
history.pushState( {}, document.title, href );
}
el.transformPage(settings, pos, next.data("index"));
}
$.fn.moveUp = function() {
var el = $(this)
index = $(settings.sectionContainer +".active").data("index");
current = $(settings.sectionContainer + "[data-index='" + index + "']");
next = $(settings.sectionContainer + "[data-index='" + (index - 1) + "']");
if(next.length < 1) {
if (settings.loop == true) {
pos = ((total - 1) * 100) * -1;
next = $(settings.sectionContainer + "[data-index='"+total+"']");
}
else {
return
}
}else {
pos = ((next.data("index") - 1) * 100) * -1;
}
if (typeof settings.beforeMove == 'function') settings.beforeMove(next.data("index"));
current.removeClass("active")
next.addClass("active")
if(settings.pagination == true) {
$(".onepage-pagination li a" + "[data-index='" + index + "']").removeClass("active");
$(".onepage-pagination li a" + "[data-index='" + next.data("index") + "']").addClass("active");
}
$("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
$("body").addClass("viewing-page-"+next.data("index"))
if (history.replaceState && settings.updateURL == true) {
var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (index - 1);
history.pushState( {}, document.title, href );
}
el.transformPage(settings, pos, next.data("index"));
}
$.fn.moveTo = function(page_index) {
current = $(settings.sectionContainer + ".active")
next = $(settings.sectionContainer + "[data-index='" + (page_index) + "']");
if(next.length > 0) {
if (typeof settings.beforeMove == 'function') settings.beforeMove(next.data("index"));
current.removeClass("active")
next.addClass("active")
$(".onepage-pagination li a" + ".active").removeClass("active");
$(".onepage-pagination li a" + "[data-index='" + (page_index) + "']").addClass("active");
$("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
$("body").addClass("viewing-page-"+next.data("index"))
pos = ((page_index - 1) * 100) * -1;
if (history.replaceState && settings.updateURL == true) {
var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (page_index - 1);
history.pushState( {}, document.title, href );
}
el.transformPage(settings, pos, page_index);
}
}
function responsive() {
//start modification
var valForTest = false;
var typeOfRF = typeof settings.responsiveFallback
if(typeOfRF == "number"){
valForTest = $(window).width() < settings.responsiveFallback;
}
if(typeOfRF == "boolean"){
valForTest = settings.responsiveFallback;
}
if(typeOfRF == "function"){
valFunction = settings.responsiveFallback();
valForTest = valFunction;
typeOFv = typeof valForTest;
if(typeOFv == "number"){
valForTest = $(window).width() < valFunction;
}
}
//end modification
if (valForTest) {
$("body").addClass("disabled-onepage-scroll");
$(document).unbind('mousewheel DOMMouseScroll MozMousePixelScroll');
el.swipeEvents().unbind("swipeDown swipeUp");
} else {
if($("body").hasClass("disabled-onepage-scroll")) {
$("body").removeClass("disabled-onepage-scroll");
$("html, body, .wrapper").animate({ scrollTop: 0 }, "fast");
}
el.swipeEvents().bind("swipeDown", function(event){
if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
el.moveUp();
}).bind("swipeUp", function(event){
if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
el.moveDown();
});
$(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function(event) {
event.preventDefault();
var delta = event.originalEvent.wheelDelta || -event.originalEvent.detail;
init_scroll(event, delta);
});
}
}
function init_scroll(event, delta) {
deltaOfInterest = delta;
var timeNow = new Date().getTime();
// Cancel scroll if currently animating or within quiet period
if(timeNow - lastAnimation < quietPeriod + settings.animationTime) {
event.preventDefault();
return;
}
if (deltaOfInterest < 0) {
el.moveDown()
} else {
el.moveUp()
}
lastAnimation = timeNow;
}
// Prepare everything before binding wheel scroll
el.addClass("onepage-wrapper").css("position","relative");
$.each( sections, function(i) {
$(this).css({
position: "absolute",
top: topPos + "%"
}).addClass("section").attr("data-index", i+1);
$(this).css({
position: "absolute",
left: ( settings.direction == 'horizontal' )
? leftPos + "%"
: 0,
top: ( settings.direction == 'vertical' || settings.direction != 'horizontal' )
? topPos + "%"
: 0
});
if (settings.direction == 'horizontal')
leftPos = leftPos + 100;
else
topPos = topPos + 100;
if(settings.pagination == true) {
paginationList += "<li><a data-index='"+(i+1)+"' href='#" + (i+1) + "'></a></li>"
}
});
el.swipeEvents().bind("swipeDown", function(event){
if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
el.moveUp();
}).bind("swipeUp", function(event){
if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
el.moveDown();
});
// Create Pagination and Display Them
if (settings.pagination == true) {
if ($('ul.onepage-pagination').length < 1) $("<ul class='onepage-pagination'></ul>").prependTo("body");
if( settings.direction == 'horizontal' ) {
posLeft = (el.find(".onepage-pagination").width() / 2) * -1;
el.find(".onepage-pagination").css("margin-left", posLeft);
} else {
posTop = (el.find(".onepage-pagination").height() / 2) * -1;
el.find(".onepage-pagination").css("margin-top", posTop);
}
$('ul.onepage-pagination').html(paginationList);
}
if(window.location.hash != "" && window.location.hash != "#1") {
init_index = window.location.hash.replace("#", "")
if (parseInt(init_index) <= total && parseInt(init_index) > 0) {
$(settings.sectionContainer + "[data-index='" + init_index + "']").addClass("active")
$("body").addClass("viewing-page-"+ init_index)
if(settings.pagination == true) $(".onepage-pagination li a" + "[data-index='" + init_index + "']").addClass("active");
next = $(settings.sectionContainer + "[data-index='" + (init_index) + "']");
if(next) {
next.addClass("active")
if(settings.pagination == true) $(".onepage-pagination li a" + "[data-index='" + (init_index) + "']").addClass("active");
$("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
$("body").addClass("viewing-page-"+next.data("index"))
if (history.replaceState && settings.updateURL == true) {
var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (init_index);
history.pushState( {}, document.title, href );
}
}
pos = ((init_index - 1) * 100) * -1;
el.transformPage(settings, pos, init_index);
} else {
$(settings.sectionContainer + "[data-index='1']").addClass("active")
$("body").addClass("viewing-page-1")
if(settings.pagination == true) $(".onepage-pagination li a" + "[data-index='1']").addClass("active");
}
}else{
$(settings.sectionContainer + "[data-index='1']").addClass("active")
$("body").addClass("viewing-page-1")
if(settings.pagination == true) $(".onepage-pagination li a" + "[data-index='1']").addClass("active");
}
if(settings.pagination == true) {
$(".onepage-pagination li a").click(function (){
var page_index = $(this).data("index");
el.moveTo(page_index);
});
}
$(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function(event) {
event.preventDefault();
var delta = event.originalEvent.wheelDelta || -event.originalEvent.detail;
if(!$("body").hasClass("disabled-onepage-scroll")) init_scroll(event, delta);
});
if(settings.responsiveFallback != false) {
$(window).resize(function() {
responsive();
});
responsive();
}
if(settings.keyboard == true) {
$(document).keydown(function(e) {
var tag = e.target.tagName.toLowerCase();
if (!$("body").hasClass("disabled-onepage-scroll")) {
switch(e.which) {
case 38:
if (tag != 'input' && tag != 'textarea') el.moveUp()
break;
case 40:
if (tag != 'input' && tag != 'textarea') el.moveDown()
break;
case 32: //spacebar
if (tag != 'input' && tag != 'textarea') el.moveDown()
break;
case 33: //pageg up
if (tag != 'input' && tag != 'textarea') el.moveUp()
break;
case 34: //page dwn
if (tag != 'input' && tag != 'textarea') el.moveDown()
break;
case 36: //home
el.moveTo(1);
break;
case 35: //end
el.moveTo(total);
break;
default: return;
}
}
});
}
return false;
}
}(window.jQuery);
================================================
FILE: onepage-scroll.css
================================================
body, html {
margin: 0;
overflow: hidden;
-webkit-transition: opacity 400ms;
-moz-transition: opacity 400ms;
transition: opacity 400ms;
}
body, .onepage-wrapper, html {
display: block;
position: static;
padding: 0;
width: 100%;
height: 100%;
}
.onepage-wrapper {
width: 100%;
height: 100%;
display: block;
position: relative;
padding: 0;
-webkit-transform-style: preserve-3d;
}
.onepage-wrapper .section {
width: 100%;
height: 100%;
}
.onepage-pagination {
position: absolute;
right: 10px;
top: 50%;
z-index: 5;
list-style: none;
margin: 0;
padding: 0;
}
.onepage-pagination li {
padding: 0;
text-align: center;
}
.onepage-pagination li a{
padding: 10px;
width: 4px;
height: 4px;
display: block;
}
.onepage-pagination li a:before{
content: '';
position: absolute;
width: 4px;
height: 4px;
background: rgba(0,0,0,0.85);
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
}
.onepage-pagination li a.active:before{
width: 10px;
height: 10px;
background: none;
border: 1px solid black;
margin-top: -4px;
left: 8px;
}
.disabled-onepage-scroll, .disabled-onepage-scroll .wrapper {
overflow: auto;
}
.disabled-onepage-scroll .onepage-wrapper .section {
position: relative !important;
top: auto !important;
left: auto !important;
}
.disabled-onepage-scroll .onepage-wrapper {
-webkit-transform: none !important;
-moz-transform: none !important;
transform: none !important;
-ms-transform: none !important;
min-height: 100%;
}
.disabled-onepage-scroll .onepage-pagination {
display: none;
}
body.disabled-onepage-scroll, .disabled-onepage-scroll .onepage-wrapper, html {
position: inherit;
}
gitextract_jwtbp1dq/ ├── Demo/ │ ├── demo.html │ ├── jquery.onepage-scroll.js │ └── onepage-scroll.css ├── README.md ├── _config.yml ├── bower.json ├── jquery.onepage-scroll.js └── onepage-scroll.css
SYMBOL INDEX (8 symbols across 2 files)
FILE: Demo/jquery.onepage-scroll.js
function touchstart (line 46) | function touchstart(event) {
function touchmove (line 55) | function touchmove(event) {
function responsive (line 215) | function responsive() {
function init_scroll (line 264) | function init_scroll(event, delta) {
FILE: jquery.onepage-scroll.js
function touchstart (line 46) | function touchstart(event) {
function touchmove (line 55) | function touchmove(event) {
function responsive (line 215) | function responsive() {
function init_scroll (line 264) | function init_scroll(event, delta) {
Condensed preview — 8 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (60K chars).
[
{
"path": "Demo/demo.html",
"chars": 15945,
"preview": "<!doctype html>\n<html>\n<head>\n\t<meta charset=\"utf-8\">\n\t<title>jQuery One Page Scroll by Pete R. | The Pete Design</title"
},
{
"path": "Demo/jquery.onepage-scroll.js",
"chars": 15657,
"preview": "/* ===========================================================\n * jquery-onepage-scroll.js v1.3.1\n * ==================="
},
{
"path": "Demo/onepage-scroll.css",
"chars": 1731,
"preview": "body, html {\n margin: 0;\n overflow: hidden;\n -webkit-transition: opacity 400ms;\n -moz-transition: opacity 400ms;\n t"
},
{
"path": "README.md",
"chars": 5847,
"preview": "#One Page Scroll 1.3.1 by Pete R.\nCreate an Apple-like one page scroll website (iPhone 5S website) with One Page Scroll "
},
{
"path": "_config.yml",
"chars": 26,
"preview": "theme: jekyll-theme-cayman"
},
{
"path": "bower.json",
"chars": 245,
"preview": "{\n \"name\": \"onepage-scroll\",\n \"version\": \"1.3.1\",\n \"author\": \"Pete R\",\n \"main\": [\n \"jquery.onepage-scroll.js\",\n "
},
{
"path": "jquery.onepage-scroll.js",
"chars": 15636,
"preview": "/* ===========================================================\n * jquery-onepage-scroll.js v1.3.1\n * ==================="
},
{
"path": "onepage-scroll.css",
"chars": 1731,
"preview": "body, html {\n margin: 0;\n overflow: hidden;\n -webkit-transition: opacity 400ms;\n -moz-transition: opacity 400ms;\n t"
}
]
About this extraction
This page contains the full source code of the peachananr/onepage-scroll GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 8 files (55.5 KB), approximately 15.2k tokens, and a symbol index with 8 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.