Create an Apple-like one page scroller website (iPhone 5S website) with One Page Scroll plugin

Overview

#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., Founder of BucketListly

License: Attribution-ShareAlike 4.0 International

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

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 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:

<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:

$(".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 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.

  $(".main").moveUp();

$.fn.moveDown()

This method allows you to move the page down by one. This action is equivalent to scrolling down/swiping up.

  $(".main").moveDown();

$.fn.moveTo(page_index)

This method allows you to move to the specified page index programatically.

  $(".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.

  $(".main").onepage_scroll({
    beforeMove: function(index) {
      ...
    }
  });

afterMove(next_page_index)

This callback gets called after the move animation was performed.

  $(".main").onepage_scroll({
    afterMove: function(index) {
      ...
    }
  });

If you want to see more of my plugins, visit The Pete Design, or follow me on Twitter and Github.

Other Resources

Comments
  • Added an IE8 fix

    Added an IE8 fix

    This little fix makes the script work in Internet Explorer 8. It uses the jQuery animate function and the CSS top position instead of the CSS3 transform. To get this working you do need Modernizr, but you can also use a few lines of jQuery to detect the browser.

    opened by dirkgroenen 9
  • IE8/IE9 Not working

    IE8/IE9 Not working

    I can't get this plugin to work on IE8/IE9 even with modernizr. (Even the demo doesn't work) Weirdly enough, the version v1 works...

    EDIT: The code is looking for the class "ie8" in the html. Even if modernizr adds this class, it still won't work in IE9.

    My fix: Look for the "no-csstransforms3d" class instead.

    opened by domialex 8
  • [question] Disable onepage on mobile?

    [question] Disable onepage on mobile?

    When viewing your demo page on a mobile device, it seems that onepage-scroll is disabled (no little indicators on the right and there is no auto-scrolling). How to get this behaviour?

    Great plugin by the way :)

    opened by zoran119 6
  • scroll to section 2 when click button

    scroll to section 2 when click button

    How I make scroll to section 2 when click button (Section 1)?

    $('.reload.btn').bind('click', function(){
         $(".main").moveTo(2);
    });
    

    This not work.

    opened by helga-hai 4
  • Add horizontal scroll for v1.2.1

    Add horizontal scroll for v1.2.1

    If you want horizontal scroll just add in options

    direction: 'horizontal'
    

    For example:

    $('.main').onepage_scroll({
        sectionContainer: "section",
        animationTime: 1000,
        pagination: false,
        updateURL: false,
        loop: true,
        direction: 'horizontal'
    })
    

    There is a solution https://github.com/peachananr/onepage-scroll/pull/39 , but it doesn`t support newest features of onepage-scroll plugin (such as loop option etc.).

    I hope that`s userful :)


    Если вы хотите использовать горизонтальный скролл вместо вертикального - просто добавьте при инициализации плагина опцию

    direction: 'horizontal'
    

    Например

    $('.main').onepage_scroll({
        sectionContainer: "section",
        animationTime: 1000,
        pagination: false,
        updateURL: false,
        loop: true,
        direction: 'horizontal'
    })
    

    За основу было взято решение https://github.com/peachananr/onepage-scroll/pull/39 , но оно уже довольно старое и не поддерживает новые фишки плагина.

    Надеюсь мое "улучшение" окажется кому-то полезным :)

    opened by MEGApixel23 3
  • after adding stopped working!!">

    after adding "onepage-scroll" to my code, all stopped working!!

    the website was working normally as well as all ahrefs, but as soon as i added the onepage-scroll, all a hrefs stopped working and are not clickable anymore.. I don't even see the cursor of the mouse change to a hand anymore..

    Any idea??

    opened by zahidaoui 3
  • No license specified

    No license specified

    The source code does not include the license. Thus, it may be possible to "download for free" this script, but it is not possible to use it or redistribute it on one's web site.

    opened by bonzini 3
  • $(el).moveDown() undefined

    $(el).moveDown() undefined

    I have a click event to call the moveDown() but the console shows me

    alt b moveDown is not defined i have the last version jquery-onepage-scroll.js v1.3.1 and* jQuery JavaScript Library v1.11.1

    $('.arrow-down').click(function() {
       $("#fullpage").moveDown();
    });
    
    opened by cannap 2
  • Outdated bower.json file potentially resolve some people's issues (like moveTo not functioning)

    Outdated bower.json file potentially resolve some people's issues (like moveTo not functioning)

    The currentbower.json file is referencing an out dated version of this repo.

    {
      "name": "onepage-scroll",
      "version": "1.2.2",
      "author": "Pete R",
      "main": [
        "jquery.onepage-scroll.js",
        "onepage-scroll.css"
      ],
      "ignore": [
        "Demo",
        "README.md"
      ],
      "dependencies": {
        "jquery": "~1.10.2"
      }
    }
    
    opened by sheedy 2
  • index is one iteration behind the actual value

    index is one iteration behind the actual value

    I'm seeing a strange issue on my app where by the index value passed to the before and after callbacks is delayed. ie. When you scroll from #1 to #2 then then the console log of index shows 1. then on scrolling back up to #1 the console log shows 2.

    You can see and example here and I've kept the console log values in there: http://chew-lv.herokuapp.com/

    opened by benbowler 2
  • refresh site with index #0 issue

    refresh site with index #0 issue

    onepager is scrolling to blank site

    go to http://www.thepetedesign.com/demos/onepage_scroll_demo.html#0 and refresh the site to see the bug.

    fix: if(window.location.hash != "" && window.location.hash != "#0" && window.location.hash != "#1") {

    opened by patlux 2
  • Unable to preventDefault inside passive event listener due to target being treated as passive. See <URL>

    Unable to preventDefault inside passive event listener due to target being treated as passive. See

    The URL is https://chromestatus.com/feature/6662647093133312

    Even your demo site is getting this error in Chrome browser.

    pure js version is the same.

    opened by kimyuil 1
  • Uncaught ReferenceError: total is not defined

    Uncaught ReferenceError: total is not defined

    I get this error

    Uncaught ReferenceError: total is not defined
        at s.fn.init.e.fn.onepage_scroll (jquery.onepage-scroll.min.js?ver=1.0.186:1)
        at onepage.js?ver=1.0.186:3
        at onepage.js?ver=1.0.186:15
    

    And it gets me to this function

         $.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 = "";
            ...
    

    What should I do?

    opened by FabiolaDErcole 1
  • How to use this with section heights < 100vh?

    How to use this with section heights < 100vh?

    Loving this plugin so far, but I have an issue. I have some sections that before installing the plugin had an auto max height which renders to about 50vh on desktop, but now with the plugin those sections have a whole lotta whitespace. Is there a way to fix this?

    Screenshot 2021-02-09 200209

    Edit: Am also having overflow issues on mobile so basically my question is: How do I use this plugin with auto max height sections

    opened by Farlandercd 0
  • License query

    License query

    Hi!

    I want to use this in a theme I created for our company's online (hosted in Atlassian Confluence) product documentation. Where do I specify the license attribution and links etc.? What I have in the footer is what links to the company's license, etc.

    -Amit

    opened by kapooramit 1
Releases(1.3.1)
Simple & lightweight (<4kb gzipped) vanilla JavaScript library to create smooth & beautiful animations when you scroll.

lax.js Simple & lightweight (<4kb gzipped) vanilla JavaScript library to create smooth & beautiful animations when you scroll. >> DEMO << What's new w

Alex Fox 9.4k Dec 29, 2022
Largetable - jQuery plugin to scroll in/maximize large tables

largetable jQuery plugin to scroll in/maximize large tables Usage Install with npm: $ npm install largetable Then include largetable files in the HTM

Edinum 1 Feb 3, 2021
A simple and fast API to monitor elements as you scroll

scrollMonitor The scroll monitor allows you to receive events when elements enter or exit a viewport. It does this using watcher objects, which watch

Stu Kabakoff 3.3k Jan 4, 2023
Smooth WebGL Shader Transformations on Scroll

Rock the Stage with a Smooth WebGL Shader Transformation on Scroll A handy setup to create a smooth scroll based GLSL animation using Three.js and GSA

Faboolea 97 Dec 25, 2022
🚀 Performance focused, lightweight scroll animation library 🚀

Sal Performance focused, lightweight (less than 2.8 kb) scroll animation library, written in vanilla JavaScript. No dependencies! Sal (Scroll Animatio

Mirek Ciastek 3.4k Dec 28, 2022
Animate elements as they scroll into view.

Animate elements as they scroll into view. Introduction ScrollReveal is a JavaScript library for easily animating elements as they enter/leave the vie

Julian Lloyd 21.2k Jan 4, 2023
▲ NEXT.JS - Example project using Next.js with Locomotive Scroll. (experimental)

nextjs-with-locomotive-scroll-example ?? NEXT.JS - Example project using Next.js with Locomotive Scroll. (experimental) ?? Demo ?? Getting started The

Bruno Silva 27 Dec 21, 2022
Better scroll event management using requestAnimationFrame.

Scroll Frame Better scroll event management using requestAnimationFrame. Install npm install @jamestomasino/scroll-frame Use const { addScrollListener

James Tomasino 2 Feb 12, 2022
Scroll made easy!

Demo - Installation - Methods - Callbacks - Styling ◼️ Features: ?? Native Scroll Behavior ?? Standardized events / shortcuts / API ?? Fast & Lightwei

Bruno Vieira 307 Nov 20, 2022
🚀 Scroll Follow Tab is a lightweight javascript library without jQuery, no dependencies.

Scroll Follow Tab is a lightweight javascript library without jQuery, no dependencies. It is used to make scrollspy effect for your menu, table of contents, etc. Only 21.7Kb.

Hieu Truong 11 Jun 20, 2022
fullPage plugin by Alvaro Trigo. Create full screen pages fast and simple

fullPage.js English | Español | Français | Pусский | 中文 | 한국어 Available for Vue, React and Angular. | 7Kb gziped | Created by @imac2 Demo online | Cod

Álvaro 34.3k Jan 4, 2023
jQuery plugin for creating interactive parallax effect

jquery.parallax What does jquery.parallax do? jquery.parallax turns nodes into absolutely positioned layers that move in response to the mouse. Depend

stephband 1.1k Nov 25, 2022
BetterScroll is a plugin which is aimed at solving scrolling circumstances on the mobile side (PC supported already).

BetterScroll is a plugin which is aimed at solving scrolling circumstances on the mobile side (PC supported already).

HuangYi 15.9k Dec 30, 2022
Create a beautiful 3D tilted effect on scroll with jQuery Tilted Page Scroll plugin

#Tilted Page Scroll by Pete R. Create a beautilful 3D tilted scrolling effect for your website with jQuery Tilted Page Scroll. Created by Pete R., Fou

Pete R. 321 Sep 18, 2022
A jQuery plugin that creates a paneled-style menu (like the type seen in the mobile versions of Facebook and Google, as well as in many native iPhone applications).

#jPanelMenu ###Version 1.4.1 jPanelMenu is a jQuery plugin for easily creating and managing off-canvas content. Check out the demo (and documentation)

Anthony Colangelo 927 Dec 14, 2022
This script produce the video scroll effect that we can find on the Apple Website's

Scrollable Sequence Description This script produce the video scroll effect that we can find on the Apple Website's. This script is inspired from the

bpy 2 Jan 25, 2022
el-table awlays show horizontal-scroller on bottom

el-table awlays show horizontal-scroller on bottom

Edward Mizuka 24 Dec 1, 2022
Scroll-stash - A JavaScript plugin to help preserve an element's scroll position.

scroll-stash A JavaScript plugin to help preserve an element's scroll position. CodePen Example Installation npm install scroll-stash JavaScript Impo

Sebastian Nitu 5 Sep 5, 2022
:iphone: A super lightweight HTML, Sass, CSS, and JavaScript framework for building responsive websites

Responsive Boilerplate A powerful, accessible, developer friendly, framework for building responsive websites Responsive Boilerplate is the developers

ResponsiveBP 845 Dec 22, 2022
jQuery based scrolling Bar, for PC and Smartphones (touch events). It is modern slim, easy to integrate, easy to use. Tested on Firefox/Chrome/Maxthon/iPhone/Android. Very light <7ko min.js and <1Ko min.css.

Nice-Scrollbar Responsive jQuery based scrolling Bar, for PC and Smartphones (touch events). It is modern slim, easy to integrate, easy to use. Tested

Renan LAVAREC 2 Jan 18, 2022