Guide to implementing a fadeInUp animation on a slider's text when the next-slide button is clicked using HTML, CSS, and JavaScript

I am looking to add a fadeInUp animation effect to the text in my slider. Currently, I have a slider in place and want the next slide text to run the fadeInUp animation when the user clicks on the next slide button. I tried using animate.style (), but it only runs the animation on load. I specifically want the animation to trigger when the user clicks the next-slide button to switch slides. Can anyone provide guidance on how to achieve this using CSS, JavaScript, or jQuery? Any help would be greatly appreciated. Thank you for your assistance! Here is the HTML code for my slider:

<html>
    <head>
        <meta charset="utf-8" />
        <title>Swiper demo</title>
        <meta
          name="viewport"
          content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"
        />
        <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
        <link
          rel="stylesheet"
          href="https://unpkg.com/swiper/swiper-bundle.min.css"
        />
   </head>
<body>
     <div class="swiper mySwiper">
        <div class="swiper-wrapper">
          <div class="swiper-slide">
            <div class="slide-container">
               <div id="slide-ani" class="slide-info">
                   <h1>REIMAGINE GROWTH 1.</h1>
                   <span>Scaling exponentially, not linearly</span>
                   <span>Powered by digital</span>
               </div>
               <div class="slide-img-section">
                 <img src="./Images/image1.jpg" class="slide-img" alt="slider1"/>
               </div>
            </div>
          </div>
          <div class="swiper-slide">
            <div class="slide-container">
              <div class="slide-info">
                  <h1>REIMAGINE GROWTH 2.</h1>
                  <span>Scaling exponentially, not linearly</span>
                  <span>Powered by digital</span>
              </div>
              <div class="slide-img-section">
                <img src="./Images/image2.jpg" class="slide-img" alt="slider1"/>
              </div>
           </div>
          </div>
          <div class="swiper-slide">
            <div class="slide-container">
              <div class="slide-info">
                  <h1>REIMAGINE GROWTH 3.</h1>
                  <span>Scaling exponentially, not linearly</span>
                  <span>Powered by digital</span>
              </div>
              <div class="slide-img-section">
                <img src="./Images/image1.jpg" class="slide-img" alt="slider1"/>
              </div>
           </div>
          </div>
          <div class="swiper-slide">
            <div class="slide-container">
              <div class="slide-info">
                  <h1>REIMAGINE GROWTH 4.</h1>
                  <span>Scaling exponentially, not linearly</span>
                  <span>Powered by digital</span>
              </div>
              <div class="slide-img-section">
                <img src="./Images/image2.jpg" class="slide-img" alt="slider1"/>
              </div>
           </div>
          </div>
    </div>
        <div id="swiper-button-next" class="swiper-button-next"></div>
        <div id="swiper-button-prev" class="swiper-button-prev"></div>
      </div>
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
     
    <script>
        var swiper = new Swiper(".mySwiper", {
          loop: true,
          slidesPerView: 1,
          navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
          },
        });
        
        $(".swiper-button-next").on("click", function() {
          // Add code here to trigger fadeInUp animation 
          // when user clicks on next slide button
        });
      </script>
</body>    
</html>

Answer №1

Your content delivery networks (CDNs) were not set up correctly. I have made some adjustments and added the necessary CSS with proper CDNs. Feel free to take a look:

Edit: Please disregard the images that are included in the code. I inserted random image paths from the internet just to test if the fade effect is functioning correctly or not.

var swiper = new Swiper(".swiper-container", {
  speed: 500, // Speed in milliseconds.
  pagination: {
    el: ".swiper-pagination",
    clickable: true,
  },
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },
  effect: "fade",
});
html,
body {
  position: relative;
  height: 100%;
}
body {
  background: #eee;
  font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #000;
  margin: 0;
  padding: 0;
}
.swiper-container {
  width: 100%;
  height: 100%;
}
.swiper-slide {
  text-align: center;
  font-size: 18px;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
}
img {
    width: 100%;
    height: 100%; 
    object-fit: contain;
}
<html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
    <meta charset="utf-8" />
    <title>Swiper demo</title>
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"
    />
    <script
      type="text/javascript"
      src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"
    ></script>
    <script
      type="text/javascript"
      src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.5/js/swiper.min.js"
    ></script>
    <link
      type="text/css"
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.5/css/swiper.css"
    />
  </head>
  <body>
    <div>
      <div class="swiper-container">
        <div class="swiper-wrapper">
          <div class="swiper-slide">
            <img
              src="https://example.com/image1.png"
              alt="Slide 1"
            />
          </div>
          <div class="swiper-slide">
            <img
              src="https://example.com/image2.png"
              class="slide-img"
              alt="Slide 2"
            />
          </div>
          <div class="swiper-slide">
            <img
              src="https://example.com/image3.png"
              alt="Slide 3"
            />
          </div>
          <div class="swiper-slide">
            <img
              src="https://example.com/image4.png"
              alt="Slide 4"
            />
          </div>
        </div>
        <!-- Add Pagination -->
        <div class="swiper-pagination"></div>
        <!-- Add Arrows -->
        <div class="swiper-button-next"></div>
        <div class="swiper-button-prev"></div>
      </div>
    </div>
  </body>
</html>

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

Prevent clicking through slides on React by disabling the Swiper feature

Is there a way to handle the global document click event (using React hook useClickAway) so that it still fires even when clicking on a slide? For example, think of a circle in the header like an avatar dropdown - when you click on it, a menu pops up. Th ...

Tips for shrinking the circumference of a circle

Currently, I have a circular div that has been styled using CSS animations. My goal is to keep the size of the circle consistent when it moves to the bottom, but reduce its size when it bounces back to the top. I am uncertain if this can be achieved solely ...

AngularJS promises are known for returning the object itself instead of just the resolved value

function getBusTimetable() { var waiting = $q.defer(); var busData = $http.get('https://bus.data.je/latest'); busData.success(function(response) { waiting.resolve(response); }); busData.error(function(error) { waiting.reject( ...

Is there a link outside a webpage that has Facebook connect capabilities?

Recently, I started delving into the world of the Facebook API. My initial experiment was a simple "Hello World" application that displays the logged-in username. Everything was working perfectly when I had the FB.init() function inline - the "Login using ...

Is there a way to connect an image to initiate a video in fullscreen mode?

Hey there, I'm currently learning about html5 in school and I have a question. I have created a credits button (image) and what I want is for a video to overlay everything on the website when that button is clicked. I initially considered redirecting ...

The method for renaming a namespace when exporting it in Typescript

Suppose I am using a third-party namespace Foo in my Typescript code. I intend to create some utility functions for this module within a module called Utility.Foo. The issue here is that the original Foo would be hidden from functions defined inside Util ...

The life cycle of the request/response object in Express.js when using callbacks

Feel free to correct me if this question has already been asked. (I've done as much research as I can handle before asking) I'm really trying to wrap my head around the life cycle of request and response objects. Take a look at the following co ...

Modifying a variable in $rootScope data will also update other instances of $rootScope data

Since I need to use the data in multiple controllers, I have stored it in $rootScope.currentCache. When the page loads, the data typically looks like this: { System: "Foo Bar", StartDateTime: "2014-11-27T12:35:00" } (please disregard any formatti ...

Unexpected Ordering of Knockout Observable Array

Background: In my current project, I am engrossed in developing a user interface powered by Knockout. While I have some experience with Knockout, one particular challenge has left me puzzled. My objective is to sort an observable array named Actions and bi ...

What is the best way to toggle the visibility of elements within a single div container?

Can someone assist me with a peculiar issue I am facing? I am attempting to toggle the visibility of certain elements when a user clicks a button. Here is my HTML structure: <div class='slide-content'> <h1>Title</h1& ...

What is the best approach to implementing jQuery ajax in my project?

Is there a way to efficiently send lengthy strings (potentially exceeding 10,000 characters) to a servlet? I am seeking information on the best method, possibly involving jquery ajax, for transmitting such extensive data to the servlet. Despite utilizing ...

Personalized modify and remove elements on a row of the DataGrid material-ui version 5 component when hovered over

In my React Js app, I am utilizing Material UI components or MUI v5 as the UI library for my project. Within the DataGrid/DataGridPro component, I am implementing a custom edit and delete row feature. The requirement is to display edit and delete icons w ...

Gradually make a section disappear and delete it in WordPress

Is there a way to smoothly fade out and remove a section after clicking on it in WordPress? I tried using the code below, which worked but doesn't seem to work for WordPress. I am using the Oceanwp theme, which allows me to easily add CSS and JavaScri ...

Delaying the standard effect of jQuery on a specific class

Greetings! I am initiating myself with my debut post on stackoverflow... 1) My goal is to create a twinkling effect by pausing opacity at 1 when hovering over a star. However, I only want the specific element being hovered on to be affected, not the entir ...

Executing Javascript code in Web2Py works on a local environment, but faces issues when the

Trying to incorporate a simple JavaScript code in a web2py VIEW to fetch an external URL has presented some challenges: <script src="http://widgets.aapc.com/countdown/aapc_cdwidgetbox_220.js"></script> The script runs smoothly locally but fai ...

Upon installation, the extension that replaces the new tab fails to detect the index.html file

edit: Check out the Chrome Extension here Edit 2: It seems that the recent update containing the index.html file was not published due to Google putting it under revision. Apologies for forgetting to include the index.html file in the upload zip, as I ...

Guide for adding Chinese characters with digital signature in your jsrsasign.js code

I am currently working on integrating with third-party organizations that require a digital signature to be added to the data in the request header. After some research, I decided to utilize the jsrsasign.js library for handling the digital signature proc ...

Utilizing AngularJS to bind form fields with select boxes to enable synchronized data. Modifying the selection in the dropdown should dynamically

Currently, I am working on an input form that involves a select with various options. Depending on the user's selection, three additional fields need to be populated accordingly. For instance: If the user picks Option1, then the three other fields s ...

HTML - No alterations to Writing Mode

Hello everyone, I'm attempting to display a header vertically in my table but the writing-mode property is not having any effect. CSS .VerticalText { writing-mode: tb-rl; } HTML <td rowspan="6" id="tableHeader" class="Border"> <h1 cl ...

Switching jQuery toggle effects to Angular framework

My current jQuery animations for toggling the sidebar are as follows: $('.sa-fixedNav_toggle').click(function () { $('.sa-fixedNav_positon').toggleClass('sa-fixedNav_size-grow') $('.pa-content_layout' ...