Fullpage.js

Create full screen pages fast and simple

README

fullPage.js

preview
compatibility

English | Español | Français | Pусский | 中文 | 한국어 | Português Brasileiro

Available for Vue, React and Angular.

fullPage.js version License PayPal Donate jsDelivr Hits Minzipped Size
  |   Created by @imac2
- [[Migration from fullPage v3 to fullpage v4]](https://alvarotrigo.com/fullPage/help/migration-from-fullpage-3/)
A simple and easy to use library that creates fullscreen scrolling websites (also known as single page websites or onepage sites) and adds landscape sliders inside the sections of the site.

Introduction

Suggestion are more than welcome, not only for feature requests but also for coding style improvements.
Let's make this a great library to make people's lives easier!

Compatibility

fullPage.js is fully functional on all modern browsers and with IE 11. If you need to support IE < 11 consider using fullPage.js v3.
It also provides touch support for mobile phones, tablets and touch screen computers.
Special thanks to Browserstack for supporting fullpage.js.

License

Commercial license

If you want to use fullPage to develop non open sourced sites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary. Which means, you won't have to change your whole application source code to an open source license. [[Purchase a Fullpage Commercial License]](https://alvarotrigo.com/fullPage/pricing/)

Open source license

If you are creating an open source application under a license compatible with the GNU GPL license v3, you may use fullPage under the terms of the GPLv3.
You will have to provide a prominent notice that fullPage.js is in use. The credit comments in the JavaScript and CSS files should be kept intact (even after combination or minification).

Usage

As you can see in the example files, you will need to include:
- The JavaScript file fullpage.js (or its minified version fullpage.min.js)
- The css file fullpage.css
Optionally, when using css3:false, you can add the easings file in case you want to use other easing effects apart from the one included in the library (easeInOutCubic).

Install using bower or npm

Optionally, you can install fullPage.js with bower or npm if you prefer:
Terminal:
  1. ``` sh
  2. // With bower
  3. bower install fullpage.js
  4. // With npm
  5. npm install fullpage.js
  6. ```

Including files:

  1. ``` html
  2. <link rel="stylesheet" type="text/css" href="fullpage.css" />
  3. <script src="vendors/easings.min.js"></script>
  4. <script type="text/javascript" src="fullpage.js"></script>
  5. ```
Using Webpack, Browserify or Require.js? Check how to use fullPage.js with module loaders.

Optional use of CDN

If you prefer to use a CDN to load the needed files, fullPage.js is in CDNJS:
https://cdnjs.com/libraries/fullPage.js

Required HTML structure

Start your HTML document with the compulsory [HTML DOCTYPE declaration](https://www.corelangs.com/html/introduction/doctype.html) on the 1st line of your HTML code. You might have troubles with sections heights otherwise. The examples provided use HTML 5 doctype ``.
Each section will be defined with an element containing the section class.
The active section by default will be the first section, which is taken as the home page.
Sections should be placed inside a wrapper (`
` in this case). The wrapper can not be the `body` element.
  1. ``` html
  2. <div id="fullpage">
  3. <div class="section">Some section</div>
  4. <div class="section">Some section</div>
  5. <div class="section">Some section</div>
  6. <div class="section">Some section</div>
  7. </div>
  8. ```
If you want to define a different starting point rather than the first section or the first slide of a section, just add the class active to the section and slide you want to load first.
  1. ``` html
  2. <div class="section active">Some section</div>
  3. ```
In order to create a landscape slider within a section, each slide will be defined by default with an element containing the slide class:
  1. ``` html
  2. <div class="section">
  3. <div class="slide"> Slide 1 </div>
  4. <div class="slide"> Slide 2 </div>
  5. <div class="slide"> Slide 3 </div>
  6. <div class="slide"> Slide 4 </div>
  7. </div>
  8. ```
You can see a fully working example of the HTML structure in the [simple.html file](https://github.com/alvarotrigo/fullPage.js/blob/master/examples/simple.html).

Initialization

Initialization with Vanilla Javascript

All you need to do is call fullPage.js before the closing `` tag.
  1. ``` js
  2. new fullpage('#fullpage', {
  3. //options here
  4. autoScrolling:true,
  5. scrollHorizontally: true
  6. });
  7. ```

Initialization with jQuery

You can use fullpage.js as a jQuery plugin if you want to!
  1. ``` js
  2. $(document).ready(function() {
  3. $('#fullpage').fullpage({
  4.   //options here
  5.   autoScrolling:true,
  6.   scrollHorizontally: true
  7. });
  8. //methods
  9. $.fn.fullpage.setAllowScrolling(false);
  10. });
  11. ```
Functions and methods can still be called in the jQuery way, as in fullPage.js v2.X.

Vanilla JS example with all options

A more complex initialization with all options set could look like this:
  1. ``` js
  2. var myFullpage = new fullpage('#fullpage', {
  3. // Navigation
  4. menu: '#menu',
  5. lockAnchors: false,
  6. anchors:['firstPage', 'secondPage'],
  7. navigation: false,
  8. navigationPosition: 'right',
  9. navigationTooltips: ['firstSlide', 'secondSlide'],
  10. showActiveTooltip: false,
  11. slidesNavigation: false,
  12. slidesNavPosition: 'bottom',
  13. // Scrolling
  14. css3: true,
  15. scrollingSpeed: 700,
  16. autoScrolling: true,
  17. fitToSection: true,
  18. fitToSectionDelay: 600,
  19. scrollBar: false,
  20. easing: 'easeInOutCubic',
  21. easingcss3: 'ease',
  22. loopBottom: false,
  23. loopTop: false,
  24. loopHorizontal: true,
  25. continuousVertical: false,
  26. continuousHorizontal: false,
  27. scrollHorizontally: false,
  28. interlockedSlides: false,
  29. dragAndMove: false,
  30. offsetSections: false,
  31. resetSliders: false,
  32. fadingEffect: false,
  33. normalScrollElements: '#element1, .element2',
  34. scrollOverflow: true,
  35. scrollOverflowMacStyle: false,
  36. scrollOverflowReset: false,
  37. touchSensitivity: 15,
  38. bigSectionsDestination: null,
  39. // Accessibility
  40. keyboardScrolling: true,
  41. animateAnchor: true,
  42. recordHistory: true,
  43. // Design
  44. controlArrows: true,
  45. controlArrowsHTML: [
  46.   '<div class="fp-arrow"></div>',  
  47.   '<div class="fp-arrow"></div>'
  48. ],
  49. verticalCentered: true,
  50. sectionsColor : ['#ccc', '#fff'],
  51. paddingTop: '3em',
  52. paddingBottom: '10px',
  53. fixedElements: '#header, .footer',
  54. responsiveWidth: 0,
  55. responsiveHeight: 0,
  56. responsiveSlides: false,
  57. parallax: false,
  58. parallaxOptions: {type: 'reveal', percentage: 62, property: 'translate'},
  59. dropEffect: false,
  60. dropEffectOptions: { speed: 2300, color: '#F82F4D', zIndex: 9999},
  61. waterEffect: false,
  62. waterEffectOptions: { animateContent: true, animateOnMouseMove: true},
  63. cards: false,
  64. cardsOptions: {perspective: 100, fadeContent: true, fadeBackground: true},
  65. // Custom selectors
  66. sectionSelector: '.section',
  67. slideSelector: '.slide',
  68. lazyLoading: true,
  69. observer: true,
  70. credits: { enabled: true, label: 'Made with fullPage.js', position: 'right'},
  71. // Events
  72. beforeLeave: function(origin, destination, direction, trigger){},
  73. onLeave: function(origin, destination, direction, trigger){},
  74. afterLoad: function(origin, destination, direction, trigger){},
  75. afterRender: function(){},
  76. afterResize: function(width, height){},
  77. afterReBuild: function(){},
  78. afterResponsive: function(isResponsive){},
  79. afterSlideLoad: function(section, origin, destination, direction, trigger){},
  80. onSlideLeave: function(section, origin, destination, direction, trigger){},
  81. onScrollOverflow: function(section, slide, position, direction){}
  82. });
  83. ```

Creating links to sections or slides

If you are using fullPage.js with anchor links for the sections (using the anchors option or the attribute data-anchor in each section), then you will be able to use anchor links also to navigate directly to a certain slide inside a section.
This would be an example of a link with an anchor: https://alvarotrigo.com/fullPage/#secondPage/2 (which is the URL you will see once you access to that section/slide manually)
Notice the last part of the URL ends in #secondPage/2.
Having the following initialization:
  1. ``` js
  2. new fullpage('#fullpage', {
  3. anchors:['firstPage', 'secondPage', 'thirdPage']
  4. });
  5. ```
The anchor at the end of the URL #secondPage/2 defines the section and slide of destination respectively. In the previous URL, the section of destination will be the one defined with the anchor secondPage and the slide will be the 2nd slide, as we are using the index 2 for it. (the fist slide of a section has index 0, as technically it is a section).
We could have used a custom anchor for the slide instead of its index if we would have used the attribute data-anchor on the HTML markup like so:
  1. ``` html
  2. <div class="section">
  3. <div class="slide" data-anchor="slide1"> Slide 1 </div>
  4. <div class="slide" data-anchor="slide2"> Slide 2 </div>
  5. <div class="slide" data-anchor="slide3"> Slide 3 </div>
  6. <div class="slide" data-anchor="slide4"> Slide 4 </div>
  7. </div>
  8. ```
In this last case, the URL we would use would be #secondPage/slide3, which is the equivalent to our previous #secondPage/2.
Note that section anchors can also be defined in the same way, by using the data-anchor attribute, if no anchors array is provided.
Be careful! data-anchor tags can not have the same value as any ID element on the site (or NAME element for IE).

Creating smaller or bigger sections

Demo fullPage.js provides a way to remove the full height restriction from its sections and slides. It is possible to create sections which height is smaller or bigger than the viewport. This is ideal for footers.
It is important to realise that it doesn't make sense to have all of your sections using this feature. If there is more than one section in the initial load of the site, fullPage.js won't scroll at all to see the next one as it will be already in the viewport.
To create smaller sections just use the class fp-auto-height in the section you want to apply it. It will then take the height defined by your section/slide content.
  1. ``` html
  2. <div class="section">Whole viewport</div>
  3. <div class="section fp-auto-height">Auto height</div>
  4. ```

Responsive auto height sections

Demo A responsive auto height can be applied by using the classfp-auto-height-responsive. This way sections will be fullscreen until the responsive mode gets fired. Then they'll take the size required by their content, which could be bigger or smaller than the viewport.

State classes added by fullpage.js

Fullpage.js adds multiple classes in different elements to keep a record of the status of the site:
- active is added the current visible section and slide.
- active is added to the current menu element (if using the menu option).
- A class of the form fp-viewing-SECTION-SLIDE is added to the body element of the site. (eg: [fp-viewing-secondPage-0](https://alvarotrigo.com/fullPage/#secondPage)) The SECTION and SLIDE parts will be the anchors (or indexes if no anchor is provided) of the current section and slide.
- fp-responsive is added to the body element when the entering in the responsive mode
- fp-enabled is added to the html element when fullpage.js is enabled. (and removed when destroyed).
- fp-destroyed is added to the fullpage.js container when fullPage.js is destroyed.

Lazy Loading

Demo fullPage.js provides a way to lazy load images, videos and audio elements so they won't slow down the loading of your site or unnecessarily waste data transfer.
When using lazy loading, all these elements will only get loaded when entering in the viewport.
To enable lazy loading all you need to do is change your src attribute to data-src as shown below:
  1. ``` html
  2. <img data-src="image.png">
  3. <video>
  4. <source data-src="video.webm" type="video/webm" />
  5. <source data-src="video.mp4" type="video/mp4" />
  6. </video>
  7. ```
If you already use another lazy load solution which uses data-src as well, you can disable the fullPage.js lazy loading by setting the option lazyLoading: false.

Auto play/pause embedded media

DemoNote: the autoplay feature might not work on some mobile devices depending on the OS and browser (i.e. Safari on iOS version < 10.0).

Play on section/slide load:

Using the attribute autoplay for videos or audio, or the param autoplay=1 for youtube iframes will result in the media element playing on page load.
In order to play it on section/slide load use instead the attribute data-autoplay. For example:
  1. ``` html
  2. <audio data-autoplay>
  3. <source src="https://www.w3schools.com/html/horse.ogg" type="audio/ogg">
  4. </audio>
  5. ```

Pause on leave

Embedded HTML5 `