Animate.css bxSlider text animations

As I am in the process of setting up a slider for my website, I have encountered some issues.

I am utilizing bxslider and wished to incorporate animations for the text on each slide by integrating animate.css. Animate.css is quite simple: just add "animated" along with the animation name as classes to the animated element.

In essence, I want the text to appear on a slide with an animation once the slider has completed transitioning to the slide. Additionally, I prefer the text to fade out before transitioning to the next slide with the subsequent text.

Considering the slider has callback functions, I assumed it would be straightforward to append the requisite CSS classes through.

JQUERY

$(document).ready(function(){

    $(".bxslider").bxSlider({
        auto: true,
        startSlide: 0,
        slideWidth: 640,
        onSlideAfter: function(){
        $(".title").addClass("animated bounceInRight");
        $(".text").addClass("animated bounceInRight");
        },
        onSlideBefore: function(){
        $(".title").removeClass("animated bounceInRight");
        $(".text").removeClass("animated bounceInRight");
        }
  });
});

HTML

<ul class="bxslider">
  <li><img src="" />
<h1 class="title animated bounceInRight">TITLE 1</h1><p class="text animated bounceInRight">
  text text text text text text
  text text text text text text

 </p></li>
  <li><img src="" /><h1 class="title">TITLE 2</h1><p class="text">
  text text text text text text
  text text text text text text

 </p></li>
  <li><img src="" /><h1 class="title">TITLE 3</h1><p class="text">
  text text text text text text
  text text text text text text

 </p></li>
  <li><img src="" /><h1 class="title">TITLE 4</h1><p class="text">
  text text text text text text
  text text text text text text

 </p></li>
</ul>

CSS 1 (what was added to the slider's default CSS)

.bxslider {
    padding: 0;
    margin: 0;
    list-style: none;
}
.title {
    position: absolute;
    top:100px;
    left: 100px;
    color: #FFF;
    font-family: Helvetica;
}
.text {
    display: block;
    position: absolute;
    top:200px;
    left: 200px;
    color: #000;
    font-family: Helvetica;
    width: 300px;
    background: #FFF;
    -webkit-animation-delay: 1s; /* to delay text "entrance" */

}

CSS 2 (animation "trigger"... the different animations are just CSS3 animations with keyframes and so on)

.animated {
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

An example slider can be viewed online here: bxslider test.

Thus far, there exist several problems. Although I will always mention "text," this encompasses both the <h1> and the <p> tags.

First: The first slide animates properly, with the text appearing through animations. However, on the second slide, the text is already visible before the animation commences. My intention is for the text to emerge "through" the animation.

Second: Despite attempting to introduce the fadeOut effect (once more through the addition and removal of corresponding CSS classes), it does not work as expected. The fadeOut occurs after transitioning to the next slide. It seems like I might be making a fundamental mistake in adding and removing the classes, but I am unable to pinpoint it.

Third: Is it feasible to utilize different entrance effects on each slide, possibly even randomly?

Fourth: A bug appears to manifest in Safari. On my personal computer (Safari & Chrome), the slideshow initiates with the first slide. However, on the web server in Safari, the last slide is initially visible, then quickly scrolls through to the second slide...quite odd. In Chrome, the slideshow behaves normally. Following inspection of Safari's log, no issues seem to arise from the code.

Any assistance pertaining to at least the initial two problems would be greatly appreciated!

Thank you!

Answer №1

Steps to achieve this effect:

HTML structure:

<section class="slider">  
    <ul class="bxslider" >
        <li><img src="photo-1.jpg"/>
            <div class="one slider-text">your content here</div>
        </li>
        <li><img src="photo-2.jpg"/>
        <div class="slider-text">your content 2</div>
        </li>       
        <li><img src="photo-3.jpg"/>
        <div class="slider-text">your content 3</div>
        </li>                    
    </ul>
</section>

CSS styles:

.slider .slider-text {
    font-size: 250%;
    color: #fff;
    position: absolute;
    z-index: 9999;
    text-align: center;
    bottom: 20%;
    width: 100%;  
}
.slider-text {
    visibility:hidden;
}
.slider-text.active-slide {
    visibility: visible;
}

JQUERY scripting:

$('.bxslider').bxSlider({
    auto: true,
    preloadImages: 'all',
    mode: 'horizontal',
    captions: false,
    controls: false,
    pause: 5000,
    speed: 800,
    onSliderLoad: function () {
        $('.bxslider>li .slider-text').eq(1).addClass('active-slide');
        $(".slider-text.active-slide").addClass("wow animated bounceInRight");
    },
    onSlideAfter: function (currentSlideNumber, totalSlideQty, currentSlideHtmlObject) {
        console.log(currentSlideHtmlObject);
        $('.active-slide').removeClass('active-slide');
        $('.bxslider>li .slider-text').eq(currentSlideHtmlObject + 1).addClass('active-slide');
        $(".slider-text.active-slide").addClass("wow animated bounceInRight");

    },
    onSlideBefore: function () {
        $(".slider-text.active-slide").removeClass("wow animated bounceInRight");
        $(".one.slider-text.active-slide").removeAttr('style');

    }
});

Dependencies utilized:
BxSlider v4.1.2
jQuery v1.11.2
Latest Animate.css

Additional resources:
You may also incorporate wow.js for more dynamic effects.

Answer №2

One easy way to add animations to your website is by using wow js and adding classes as usual, then reinitializing wow each time.

$(document).ready(function(){
    new WOW().init();
    $('.bxslider').bxSlider({
        auto: true,
        adaptiveHeight: true,
        onSlideAfter: function () {
            new WOW().init();
        },
        onSlideBefore: function () {
            new WOW().init();
        }
    });
});

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

Vue unable to load material icons

The icons npm package "material-icons" version "^0.3.1" has been successfully installed. "material-icons": "^0.3.1" The icons have been imported as shown below. <style lang="sass"> $material-icons-font-path: '~material-icons/iconfont/'; ...

Expand the range of input movement using a unique and oversized custom thumb graphic

In my project, I am creating a personalized input range feature by utilizing a 40px x 80px image as the background for the thumb. Typically, the thumb is limited to moving within the length of the track from edge to edge. However, I am aiming for the thu ...

Angular text input with customizable placeholder text and embedded icon

Hey there, I'm looking to create a unique custom textbox that includes a text placeholder and a help icon that will display useful information in a popover. https://i.sstatic.net/Zh0IK.png When typing into the input, the textbox should have a specif ...

Align text divs vertically and ensure font size is responsive within a container div

Within this designated div, I have included: https://i.stack.imgur.com/j099H.png In an attempt to ensure that the font size of the text adjusts responsively, I implemented the following code: font-size:calc(xx + 1.5vw); However, upon resizing the scree ...

How can I customize the color of the title and property value in Handlebars?

Here is the list I am working with: <li>Equipment Area:{{equipment_area}}</li> <li>Equipment Type: {{equipment_type}}</li> <li>Manufacturer: {{manufacturer}}</li> <li>Model Number: {{model_number}}</li> < ...

Table of Data: Enhancing row selection with icons

I have a dilemma regarding adding images to the left of text in specific columns within rows. A similar issue was faced by an individual (referenced here: jQuery DataTables add country icons to each column). The person wanted to include flag icons next to ...

Rearrange the sequence of specific child elements within the Div

Is there a way to reverse the order of specific div's children elements using just CSS? For instance: I need <div id="parent"> <a>A</a> <a>B</a> <a>C</a> <a>D</a> &l ...

Jquery: Understanding the impact of sending multiple ajax requests to a single URL

Today, I encountered some unexpected behavior and I wanted to confirm if this is normal for jQuery or if I'm simply overlooking something... I wrote a function that makes an AJAX call and performs an action on the promise.done(). Below is a simplifie ...

Scrolling with animation

While exploring the Snapwiz website, I came across a captivating scroll effect that I would love to implement on my own site. The background picture changes seamlessly as you scroll, with the front image sliding elegantly into view. A similar type of scro ...

Is it possible to upload multiple files using JavaScript?

My JavaScript project can be found on GitHub. You can check out a live demo of the project here. The main goal for my HTML Button with id='Multiple-Files' is to enable users to upload multiple files, have them displayed in the console, and then ...

Refreshing Kendo Grid following an asynchronous request

I have successfully implemented a kendo grid that fetches data from a URL in JSON format. The code I used is functional and here it is: $('#grid').kendoGrid({ dataSource: { transport: { read: { url: "http://localhost/ ...

Choose the ul element with two distinct classes using Jquery

Visit this link for the source code I currently have a multi-level navigation bar that is solely CSS-based. I would like to implement JQuery functionality so that the dropdowns occur on tap or click events. Here's a snippet of the JQuery toggle fun ...

What is the best way to add child elements to the parent element when the height limit has been reached?

This is the code I've been working on: <ul style="height:200px;width:100%;"> <li>Hi</li> <li>Hi</li> <li>Hi</li> ... (add more items here) </ul> Here is a preview of how it currently looks: ...

What is the best way to connect data so that when a user clicks on a specific card, it appears on a popup card

When a user clicks on any card containing data retrieved from a backend API GET method, that data should be displayed in a pop-up card. In my situation, I have two components: DisplayNotes.vue and UpdateNotes.vue. Whenever a user clicks on a displayed card ...

Choose a particular optgroup simultaneously using custom JavaScript

Check out this Fiddle for an example I am facing a situation where I have two different types of option groups with options. My challenge is to ensure validation between these two groups. How can I achieve this? Situation 1 If I select something from g ...

What is the purpose of including a viewport meta tag on my website if I already have CSS media queries in place?

As someone who is just starting out with building websites, I have been delving into the world of meta tags. However, even after conducting thorough research, I am still unsure about the necessity of a meta viewport tag when I am already utilizing CSS me ...

Is there a way to create a new prettyphoto window by clicking on a link within the original prettyphoto window?

I have an HTML table that is dynamically constructed on the server side using AJAX. The table is displayed using prettyphoto, everything works fine up to this point. However, the last column of the table contains a link that should open an image using pret ...

Execute a function prior to making a synchronous call

Seeking guidance on a complex issue that I have encountered. In my code, I am dealing with a synchronous AJAX call and need to execute a function before this particular call is made. The function in question is a simple one: $.blockUI(); This function ...

Creating a HTML5 canvas animation of an emoticon winking to add a fun touch to your

Currently, I am facing a challenge in animating an emoticon that was initially sketched on canvas. While following a tutorial to implement draw and clear animations using frames, I haven't been able to achieve the desired outcome. With 6 frames of the ...

What is the best way to restrict the length and number of lines in a textarea based on pixel dimensions?

I am looking to create a textarea where people can select different fonts, such as "sans-serif" and "serif", to type in text. I plan to have buttons labeled "sans-serif" and "serif" that will change the font of the textarea when clicked. However, there ar ...