Enhancing Fullpage.js with a custom scroll delay feature

One issue I'm having is with a fading div "box" using ".fp-viewing" as a trigger for the transition effect. The problem arises when the page begins scrolling upon .fp-viewing being activated, causing the box to scroll out of view before its animation completes.

I am looking for a way to prevent the scrolling from starting immediately when .fp-viewing is triggered until the box has finished its animation lasting 4 seconds.

.box{
  transition: all 4s ease-out;
  -webkit-transition: all 4s ease-out;
}

.fp-viewing-2 .box{
  opacity: 0;
}

Answer №1

Explore the functionality provided by fullpage.js for preemptively interrupting a scroll movement.

Access live demo here

var delay = 2000; //milliseconds
var timeoutId;
var animationIsFinished = false;

new fullpage('#fullpage', {
      sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6'],
    onLeave: function(origin, destination, direction){
        var curTime = new Date().getTime();

        //animating my element
        $('#element').addClass('animate');

        clearTimeout(timeoutId);

        timeoutId = setTimeout(function(){
            animationIsFinished = true;

            fullpage_api.moveTo(destination.index + 1);
        }, delay);

        return animationIsFinished;
    },
});

Answer №2

#fullpage {
    animation-delay: 1s !important;
}

Alternatively, you could update the addAnimation function within fullpage.js

Answer №3

Here is the solution that worked for me:

$(elem).fullpage({ 
/// options, 
onLeave: function(origin, destination, direction){ 
if(animationIsFinished === false){ 
// execute some code 
} 
clearTimeout(timeoutId); 
timeoutId = setTimeout(function(){ 
animationIsFinished = true;
 $.fn.fullpage.moveTo(destination); 
   setTimeout(() => { 
     animationIsFinished = false; 
   }, 200); 
}, 600); 
return animationIsFinished; 

Answer №4

I have found a simple and cost-effective solution by creating a custom function wrapper for the Full Page functionality that I require. By using settimeout as demonstrated in this specific response, I am able to trigger the desired function at my convenience.

function executeDelayedSlide() {
    fullpage_api.moveSlideRight();
}

// Trigger slide change on select
$('select').on('change', function(){
    setTimeout(executeDelayedSlide, 500);
})

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Switching from AngularJS to vanilla JavaScript or integrating AngularJS and Flask on a single server

It is common knowledge that angular has the ability to create a project and convert it into pure HTML, CSS, and js code. Similarly, I am looking to do the same for my AngularJS application. When I execute the app using npm start it works perfectly fine. My ...

Cross-origin resource sharing policy is preventing a request from the client-side to the server

I am currently working on a Vue.js application and I am facing an issue with CORS policy blocking my backend requests. I am using axios to make the request to the backend for data that I need to display charts on the UI. Here is the code snippet of my char ...

Illumination causes surfaces to transform

In my simple scene, I have a ground and an interesting light source. However, when the light hits certain meshes, it creates some strange effects. The shadows are being cast correctly, but the other meshes affected by the light are showing unusual results. ...

Can a website be designed to load a specific font for mobile phones, such as Arial Black for iOS?

Although the font Arial Black is commonly available on both Mac and PC systems, it is not accessible on iOS devices. Is there a way for a webpage to implement CSS techniques or tricks (such as assigning a class like "mobile" or "ios" to the body element), ...

transitioning from having async set to false to now setting it to true

Hey there! I'm currently facing an issue with a piece of code that needs some tweaking. The code snippet below is meant to load JSON files asynchronously, but I need it to work in sync with jQuerymobile for better functionality: var Loader = { b ...

When the 'shown' event is triggered by manually activating a Bootstrap modal

Issue arises when I attempt to display the modal for the first time. The modal appears, but the shown event is triggered only when I drag the modal or click on the close button (I can see the alert). I am working with Bootstrap 2.3.2 and Firefox 26.0. $ ...

Is there a method to obtain over 10 markers on the map?

Trying to find nearby places from my current location. The issue I'm currently facing is that I'm only able to see 10 markers on the map, and no more locations are being displayed. Is there a way to bypass or resolve this problem? I've come ...

Learn how to send information to a form and receive a response when a key is pressed, either up or down, by

Can you help with fetching data and passing it into a form to respond to customer names on keyup or keydown using JSON and PHP? <?php $conn = new mysqli("localhost", 'root', "", "laravel"); $query = mysqli_query($conn,"select * from customers ...

What is the significance of storing the array length in the selection sort algorithm?

The code snippet below is taken from the Grokking algorithm book: const findSmallestIndex = (array) => { let smallestElement = array[0]; // Stores the smallest value let smallestIndex = 0; // Stores the index of the smallest value for (let i = 1 ...

Iterating through an array of objects and performing reduction based on various key-value pairs

I am faced with a challenge of consolidating a large array of objects into one single array that has a specific structure. Each item, such as a banana, needs to be present in two separate objects for buy orders and sell orders, each with their own distinct ...

Tips for enabling browser back and forward functionality in a one-page website design

Building on the previous discussion about optimizing a horizontal sliding layout (Most efficient way to do a horizontal sliding layout), I'm curious if it's feasible to enable the back and forward buttons in the browser when implementing a single ...

When working with multiple states in React, the toggle does not update on click when using setState

As a beginner in React JS, I have been learning and experimenting with state management. Initially, I successfully used setState to change the state. However, I encountered an issue when attempting to work with multiple states simultaneously – it didn&ap ...

Validating Two DateTime Pickers as a Group with Javascript in asp.net

How to Ensure Group Validation of Two DateTime Pickers Using JavaScript in ASP.NET ...

Tips for creating basic Jasmine and Karma tests for an Angular application to add an object to an array of objects

I have developed a basic Angular project for managing employee data and I'm looking to test the addProduct function. Can someone guide me on how to write a test case for this scenario? I am not using a service, just a simple push operation. Any assist ...

Is there a way to delay loading 'div' until a few seconds after the 'body' has been fully loaded?

Is there a way to delay the appearance of the "text-container" div after the image is displayed? I have attempted to achieve this using JavaScript with the following code: <script> window.onload = function(){ var timer = setTimeout("showText()",700 ...

I would like a div element to slide up from the bottom of the page

Could someone please assist me in creating a popup div that appears from bottom to top when a specific button is clicked? I would like the div to be fixed without affecting the overall page content. Any help would be greatly appreciated. Thank you! $( ...

Searching for a specific key and its corresponding value within an Object Literal (JSON string / object) is necessary

After reading up on JSON objects , I am now trying to locate the value associated with a specific KEY, which may be null, no or yes. The KEY in question is "f03eb90f-6b5e-4b26-bd9f-bad788b7edac" and I want to retrieve its value You can find the Fiddle ...

The replaceWith() function in jQuery is able to transform PHP code into an HTML comment

How can I change a div element in a click event handler, while ensuring that PHP code inside the element remains intact and does not get moved into an HTML comment? You can find my code snippet below: $("#replaceCat1").click(function(){ $("div.boxconte ...

Having trouble with Vue 3 Component State not updating following an asynchronous operation?

Encountering challenges in my Vue 3 app when trying to update a component's state post an asynchronous operation. Here's what's happening: Within a component, there is a method called containerMoveHere that utilizes Socket.io for an async o ...

Implement FluentUI Progress Component as the New Style in Blazor

Looking for a solution to remove the track from the FluentUI Progress bar, but limited to using only this library. Unable to consider alternatives. Tried applying CSS in my application to override the default style, but it seems any modifications to the c ...