Using animate.css and jQuery for sequential animations

Is there a way to make them fadeInUp one after the other?

Check out the demo http://jsfiddle.net/uz2rm8jy/4/

Here is the HTML structure:

<div class="c one"></div>

<div class="c two"></div>

<div class="c three"></div>

This is the JavaScript code I am using:

$(function() {
$('.c').each(function(i) {
$(this).delay((i++) * 150).addClass('fadeInUp'); })
});

Answer №1

To accomplish this task, you can utilize jquery's fadeTo function by following the same method you are currently using...

$(function() {
  $('.c').each(function(i) {
  $(this).delay((i++) * 150).fadeTo(500,1); })
});

$(function() {
$('.c').each(function(i) {
$(this).delay((i++) * 150).fadeTo(500,1); })
});
.one,.two,.three {
    height: 50px;
    background: #dddddd;
    width: 50px;
    border-radius: 50%;
    display:inline-block;
    margin: auto 10px;
    opacity:0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<div class="c one"></div>

<div class="c two"></div>

<div class="c three"></div>

Answer №2

The question originally centered around the Animate.css library; however, the provided answers did not offer assistance with animate.css. I encountered the same issue and eventually found a solution. You can view the solution in the following JSFiddle link: JSFiddle

Here is the example HTML code:

<div class="content">
  <div class="firstanimation">
    <h1 data-animation="fadeInUp" style='display: none'>
      This is Title
    </h1>
  </div>
  <div class="secondanimation">
    <p data-animation="wobble" style='display: none'>
      This is Description
    </p>
  </div>
  <div class="lastanimation">
    <p data-animation="bounce" style='display: none'><a href="#">Link</a></p>
  </div>
</div>

jQuery section:

// With Queue
function animate2(queue) {
  if (queue && queue.length > 0) {
    var elm = queue.shift();

    var animClass = "animated " + $(elm).data('animation');

    $(elm).show().addClass(animClass)
      .on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
        $(elm).removeClass();
        animate2(queue);
      });
  }
};



$(function() {
  var animationQueue = [
    $('.content').find('.firstanimation h1'),
    $('.content').find('.secondanimation p'),
    $('.content').find('.lastanimation p')
  ];

  animate2(animationQueue);
});

Answer №3

There are a couple of options available to you.

  1. You can utilize transition end events, which can be triggered with JavaScript.
  2. An alternative option is to incorporate transition delays.

You can listen for transition end events on any element that has a transition. To execute a function once the transition has ended, you can do the following:

element.addEventListener( "transitionend", function() {
    // Insert code here to add a class to the next element
});

It is important to remember to include any necessary prefixes, but jQuery can simplify this process. You can easily accomplish this by using a for loop.

Another approach, which does not require additional JavaScript or transition end events, involves delaying the transitions of .c.two and .c.three by the duration of the actual transition (and double that for .c.three). This can be implemented directly in the CSS by utilizing the transition-delay property on the corresponding elements.

I trust this information proves beneficial to you.

Answer №4

It appears that you were attempting to apply the 'fadeInUp' class to your divs based on your code. However, you may want to consider the following solution for a different approach.

function fade(element){
$(element+":not(:visible):first").fadeIn(function(){
    fade(element);
});
}

To implement this function, simply provide the class 'c' as an argument like so: eg.

fade('.c');

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

How can I extract particular combinations from a PHP array?

I have a unique question that is quite specific and despite searching online, I couldn't find an answer. So, I decided to seek advice here. Imagine my webpage has three sliders: one for selecting color options for a square, another for a circle, and ...

Modify the width of the <nz-date-picker> component from Ng-Zorro

Currently using Ng-Zorro for my template styling and working on implementing a date picker that I want to align perfectly with the dropdown menu above it. I would like to adjust the width of the date-picker manually within the template, but after visiting ...

Determining When the Collapse Transition in Material UI 5 is Complete

Snippet <Collapse in={expanded} onTransitionEnd={() => console.log('finished')} > <div>foo</div> </Collapse> Error Detection The callback function (onTransitionEnd) is not triggered af ...

Using Javascript to dynamically add and remove elements on click

Whenever I click on a link, I am able to generate input, label, and text. However, I want to be able to delete these elements with the next click event on the same link: I've tried updating my code like this: var addAnswer = (function() { var la ...

Error 404 in Cordova AJAX请求

As I work on developing an android application with cordova, AJAX requests are essential for the functionality. Utilizing jQuery for these requests, I updated the security policies in index.php to allow connection to a remote server. However, upon initiati ...

Rendering a Subarray using Map in ReactJS

I have an object containing data structured like this: [{"groupid":"15","items":[ {"id":"42","something":"blah blah blah"}, {"id":"38","something":"blah blah blah"}]}, {"groupid":"7","items": [{"id":"86","something":"blah blah blah"}, {"id":"49","somethin ...

Updating specific data in MongoDB arrays: A step-by-step guide

{ "_id":{"$oid":"5f5287db8c4dbe22383eca58"}, "__v":0, "createdAt":{"$date":"2020-09-12T11:35:45.965Z"}, "data":["Buy RAM","Money buys freedom"], & ...

Node.js post request body is still showing as undefined despite using body-parser

Hello everyone, I am currently using Node.js to implement a Dialogflow chatbot. My goal is to extract parameters from an HTTP POST request. To achieve this, I utilized Postman and made sure to set the content type to JSON in the header. Below is the code f ...

Unable to parse JSON elements using jQuery

Currently, I have an unordered list containing customer names that are retrieved from a JSON file. I am trying to implement a click event using jQuery, but it seems to be having trouble reading it. While the list appears correctly in the HTML source file, ...

Ways to easily modify images using a single button with the help of jq

I am new to programming and eager to learn... Currently, I am facing the following problem: I would like to create a functionality where three images can be changed using one button and incorporating fadeIn and fadeOut animations. Essentially, all images ...

retrieving data from a different controller through a view

I am currently working on a Ruby on Rails project that involves using ajax to update various sections of a page. In my setup, I have a posts_controller responsible for displaying a collection of posts. Each post can be toggled between 'hidden' an ...

The consistent failure of the 201 status node express API is causing major

I am currently working on creating an API using Express. However, when I receive a response from the server, it shows '201 created'. The issue arises when I attempt to make an HTTP request through promises and encounter a false interpretation of ...

Leveraging the power of PHP variables within jQuery code

Wondering how to incorporate a PHP value into jQuery? My approach involves retrieving the VAT rate from the database using PHP and storing it in $vatrate: $sqlv = <<<SQL SELECT * FROM `vatrate` WHERE id='1' SQL; if(!$resultv = $db-&g ...

Next.js triggers the onClick event before routing to the href link

Scenario In my current setup with Next.js 13, I am utilizing Apollo Client to manage some client side variables. Objective I aim to trigger the onClick function before navigating to the href location. The Code I'm Using <Link href={`/sess ...

What is the best way to store user data from an Angular App into the Firebase Realtime database?

As I delve into the world of Angular by following a tutorial, I find myself struggling with saving users to the Firebase database. Despite successfully logging in, the database remains empty. import { Injectable } from '@angular/core&apo ...

Adding flair to a fresh element and then removing it upon its inception

I'm working with a JavaScript code that creates a new element when a button is clicked. I have a question about it. Here's the JavaScript code snippet: var comment = document.querySelector("#AddComment"); var req = new XMLHttpRequest(); if(comm ...

Create a new promise within a factory function

I am facing an issue in my factory where I want to return a promise inside a function, but every time I try, my controller throws an error like: Provider 'personFactory' must return a value from $get factory method. This is how my factory looks ...

Bringing life to web pages through captivating animations when showing and hiding div elements, utilizing the power

After extensive research on various online platforms, including stackoverflow, I unfortunately couldn't find a suitable solution to my problem. However, with the invaluable assistance of you all, I managed to successfully implement a code for my proje ...

CSS overflow property determines whether to display or hide the parts of an element

Is it possible to create HTML text that will automatically hide itself entirely if it exceeds the container size, instead of clipping with the overflow: hidden property? ...

JS: The for loop will keep iterating even if the condition becomes false

Can anyone help me understand why my for loop is continuing even after the conditions are met? Unfortunately I can't share the entire file due to its size, but here is a snippet of the loops: for (var j = 0; j < depKeyArr.length; j++) { var di ...