fullPage.js can be installed via npm, yarn, or by directly downloading the files from the official website.
npm:
npm install fullpage.js
yarn:
yarn add fullpage.js
Direct Download: Download the necessary files (fullpage.css and fullpage.js) from the official website and include them in your project.
Before you begin, ensure you have a basic HTML structure with sections representing your website’s different pages. Each section will become a slide in your fullPage.js website. A simple structure could look like this:
<div id="fullpage">
<div class="section">Section 1</div>
<div class="section">Section 2</div>
<div class="section">Section 3</div>
</div>
After setting up your HTML structure, you need to initialize fullPage.js. This is done by including the CSS and JavaScript files and then calling the $.fn.fullpage.init()
function. Refer to the next section for details on including the files. After including the files, add the following JavaScript code:
$(document).ready(function() {
$('#fullpage').fullpage();
; })
This code will initialize fullPage.js on the element with the ID “fullpage”.
Include the fullpage.css
stylesheet in the <head>
of your HTML document and the fullpage.js
script in the <body>
, ideally just before the closing </body>
tag. For npm/yarn users, the paths will depend on your project setup. For direct downloads, adjust the paths accordingly. Example:
<!DOCTYPE html>
<html>
<head>
<title>My fullPage.js Website</title>
<link rel="stylesheet" href="path/to/fullpage.css">
</head>
<body>
<div id="fullpage">
<!-- Your sections here -->
</div>
<script src="path/to/jquery.min.js"></script> <!-- Make sure you include jQuery -->
<script src="path/to/fullpage.js"></script>
<script>
$(document).ready(function() {
$('#fullpage').fullpage();
;
})</script>
</body>
</html>
Remember to replace "path/to/..."
with the correct paths to your files. You will also need to include jQuery; fullPage.js relies on it.
fullPage.js aims for broad browser compatibility. It officially supports the latest versions of major browsers including Chrome, Firefox, Safari, Edge, and Opera. While older browsers might work, full functionality and optimal performance are not guaranteed. For best results, target modern browsers. Refer to the official documentation for the most up-to-date compatibility information.
fullPage.js organizes your website content into sections and slides. A section represents a full-screen page, while slides are individual elements within a section, allowing for horizontal scrolling within a section. Each section is defined by a <div>
with the class section
, and each slide within a section is defined by a <div>
with the class slide
.
<div id="fullpage">
<div class="section">
<div class="slide">Slide 1 of Section 1</div>
<div class="slide">Slide 2 of Section 1</div>
</div>
<div class="section">
<div class="slide">Slide 1 of Section 2</div>
</div>
<div class="section">Section 3</div> </div>
In this example, there are three sections. The first section contains two slides, the second section contains one slide, and the third section contains only one slide (no horizontal scrolling).
fullPage.js provides built-in navigation features, including:
fullPage.js offers smooth and intuitive scrolling between sections and slides. Scrolling behavior can be customized, offering options for:
ease
, linear
).fullPage.js adapts to different screen sizes and devices. You can define different settings for different screen sizes and orientations through its options. Consider using media queries in your CSS to style elements appropriately for different viewport sizes. FullPage.js itself handles the adjustments to maintain functionality across various devices.
fullPage.js offers a rich set of events that you can use to trigger custom actions at specific points within the scrolling process. These events include:
afterLoad
: Triggered after a section has been loaded.onLeave
: Triggered when a user leaves a section.afterRender
: Triggered after all sections are rendered.afterSlideLoad
: Triggered after a slide within a section has been loaded.afterResize
: Triggered after a window resize event.scrollHorizontal
: Triggered when a user scrolls horizontally (between slides).You can use these events to execute custom JavaScript code, such as animations or updating content based on the user’s current position in the website. Refer to the official documentation for a complete list and details on how to use each event.
When initializing fullPage.js using $('#fullpage').fullpage(options);
, you can pass an object containing various options to customize its behavior. Here are some key options:
licenseKey
(string): Your license key (required for commercial use).anchors
(array): An array of strings defining anchors for each section. These are used for URL linking and navigation.menu
(string or jQuery object): Selector for the navigation menu element.navigation
(boolean): Shows or hides the built-in vertical navigation dots.navigationPosition
(string): Positions the navigation (e.g., right
, left
).scrollHorizontally
(boolean): Enables horizontal scrolling (slides).slidesNavigation
(boolean): Shows or hides the navigation for slides within sections.autoScrolling
(boolean): Enables or disables automatic scrolling.fitToSection
(boolean): Whether to resize the sections to the viewport height.responsiveWidth
(number): The viewport width at which the responsive mode activates.responsiveHeight
(number): The viewport height at which the responsive mode activates.Many more options exist for fine-grained control over styling, animations, and functionality. Consult the official documentation for a complete list and descriptions.
fullPage.js provides several methods to control its behavior after initialization. These methods are called on the fullPage.js instance. Example: $.fn.fullpage.reBuild();
fullpage.moveSectionUp()
: Moves to the previous section.fullpage.moveSectionDown()
: Moves to the next section.fullpage.moveTo(section,slide)
: Moves to a specific section and slide (index or anchor).fullpage.setResponsive(isResponsive)
: Manually sets the responsive mode.fullpage.reBuild()
: Rebuilds the plugin (useful after DOM manipulations).fullpage.destroy()
: Completely destroys the fullPage.js instance.fullpage.setAllowScrolling(value, direction)
: Enables or disables scrolling. Direction can be ‘vertical’, ‘horizontal’, or ‘both’.fullpage.getActiveSection()
: Returns the currently active section.fullpage.getActiveSlide()
: Returns the currently active slide.These are some of the commonly used methods. Refer to the official documentation for a full list of available methods and parameters.
Callbacks are functions that you can provide as options during initialization to execute code at specific moments within fullPage.js’s lifecycle. These are often used in conjunction with Events. Example (In Initialization options):
$('#fullpage').fullpage({
afterLoad: function(origin, destination, direction){
console.log("Section loaded:", destination.index);
}; })
Common callbacks include afterLoad
, onLeave
, afterRender
, afterSlideLoad
, etc., mirroring many of the events.
fullPage.js triggers various events throughout its operation, allowing you to integrate custom functionality. These events can be bound using jQuery’s on()
method.
afterLoad
: Triggered after a section is loaded.onLeave
: Triggered when leaving a section.afterRender
: Triggered after the plugin has finished rendering all sections and slides.afterSlideLoad
: Triggered after a slide within a section is loaded.afterResize
: Triggered after a window resize.slideChange
: Triggered after a slide changes.scrollHorizontal
: Triggered during horizontal scroll.sectionsNav
: Triggered when interacting with the sections navigation.lazyLoad
: Triggered when an image or element is lazy-loaded.To listen for these events, use jQuery’s on()
method like this:
$('#fullpage').on('afterLoad', function(origin, destination, direction){
// Your custom code here
; })
Refer to the official documentation for more details on each event’s parameters. Remember to replace placeholders like // Your custom code here
with your actual code.
Beyond the basic navigation options, fullPage.js allows extensive customization. You can:
menu
option. This provides more design control.fullPage.js’s default vertical scrolling behavior can be modified extensively:
scrollingSpeed
option to control how quickly users move between sections.easing
option to alter the animation curve during scrolling.continuousVertical: true
) to allow scrolling beyond the last section and looping back to the beginning.scrollBar:true
(to show) or scrollBar:false
(to hide).For horizontal scrolling within sections (slides), consider these points:
slidesNavigation: true
to provide users with visual cues and controls for navigating slides within a section.autoScrolling: true
for automatic, autoScrolling: false
for manual scrolling) based on your design and user experience goals.Elements positioned using position: fixed;
remain in place while the user scrolls. However, keep these considerations in mind when using fixed elements with fullPage.js:
afterLoad
, onLeave
, etc.) to account for the changing viewport and section positioning.To ensure your fullPage.js website works well on different devices, leverage responsive design techniques:
responsiveWidth
, responsiveHeight
) to switch to a different scrolling mode or layout at specific breakpoints.To improve accessibility for users with disabilities:
To maintain good performance, especially on larger websites or devices with limited resources:
A simple website can benefit from fullPage.js by presenting information across multiple sections, each acting as a distinct page. This is ideal for websites with a small number of pages or those that want a more visually engaging user experience than traditional linear scrolling. Each section can contain text, images, and other content relevant to that page. Navigation can be implemented using the built-in navigation bullets or a custom menu. This approach provides a clean, straightforward design and excellent user experience.
fullPage.js can be used to create a single-page application (SPA) with multiple sections representing different parts of the application. This allows for content organization within a single page, providing a seamless user experience without constant page reloads. Each section can host a different component or view of the application. Using the API, you can trigger actions and updates based on which section is currently visible, enhancing the interactivity and dynamics of the SPA. This structure simplifies navigation and reduces the number of HTTP requests.
fullPage.js can easily create a sophisticated slideshow. Each section can represent a different slide, with multiple slides (using horizontal scrolling) per section for a more complex display. You can incorporate various media types within each slide, making for an impressive visual presentation. Adding custom animations triggered by afterLoad
or onLeave
events further enhances the slideshow’s dynamic quality. Navigation can be customized to match the desired style of the slideshow.
For showcasing a portfolio of work, fullPage.js creates a visually appealing and intuitive experience. Each section can represent a different project, containing images, videos, descriptions, and links. The smooth scrolling between sections provides a polished feel, drawing attention to each project. Sections can be structured to emphasize key project aspects. This allows for a comprehensive yet navigable display of a creative individual’s or company’s work. Using the API, you can even incorporate interactive elements within each project’s presentation.
While fullPage.js isn’t ideal for complex e-commerce applications, it can enhance aspects of the user experience. You could use it to present product categories in different sections, creating a visually attractive way to browse products. Each section could focus on a specific product category or a set of related products. However, it’s crucial to ensure that core e-commerce functionalities like adding items to a cart, checkout processes, and secure payment processing are handled separately and don’t rely solely on the fullPage.js structure. Consider fullPage.js as a supplementary enhancement to a well-structured e-commerce application rather than the foundation of it.
fullPage.js not working: Ensure that you’ve correctly included jQuery, the fullPage.js CSS file (fullpage.css
), and the fullPage.js JavaScript file (fullpage.js
) in your HTML. Check the paths are correct and that there are no conflicts with other scripts or styles. Also, verify that the element with the ID you’re targeting (#fullpage
by default) exists in your HTML and is correctly structured.
Sections not displaying correctly: Check your HTML structure to make sure your sections (<div class="section">
) and slides (<div class="slide">
) are correctly nested. Incorrect nesting or missing classes can lead to rendering issues. Also, inspect the browser’s console for any JavaScript errors that may be preventing fullPage.js from functioning properly.
Scrolling issues: Problems with scrolling may arise from conflicts with other JavaScript libraries that manipulate scrolling behavior. Try disabling other scripts temporarily to see if that resolves the issue. Also, check your fullPage.js initialization options, such as autoScrolling
, scrollingSpeed
, and easing
, to ensure they are set appropriately.
Responsive issues: If your website doesn’t adapt correctly to different screen sizes, review your CSS media queries and fullPage.js responsive options (responsiveWidth
, responsiveHeight
). Ensure that your design is properly responsive and accounts for different viewport sizes.
License key errors: If using a commercial license, make sure you’ve entered the correct license key during initialization. Incorrect license keys will prevent the plugin from functioning correctly.
Use your browser’s developer tools (usually accessed by pressing F12) to debug your fullPage.js implementation:
Simplify your HTML: Create a minimal HTML structure with just the essential sections to isolate potential problems. Gradually add complexity to identify which part of your code is causing the issue.
Check for JavaScript conflicts: Temporarily disable other JavaScript libraries to see if they’re interfering with fullPage.js.
Consult the documentation: The official fullPage.js documentation provides detailed information on usage, options, and troubleshooting.
Search for similar issues: Search online forums and communities for reported issues that are similar to yours. The solution may have already been found and documented.
Test on different browsers: Ensure your website works correctly across various browsers and devices to identify potential browser-specific issues.
For additional assistance, consider these resources:
Remember to provide clear and concise details when seeking help, including your fullPage.js version, browser information, relevant code snippets, and a detailed description of the problem you’re encountering.