Looking to incorporate a new title animation into my jQuery slideshow

After downloading a slideshow for my home page, I noticed it came with 2 animated text titles (H2 and H3) that slide in from the left to center. Now, I am trying to incorporate an additional line of text (H4) that should slide in from the right with a delay of a few seconds.

I have made the necessary edits to the webpage and .css file, but I'm uncertain about handling the javascript without causing any issues.

Below is a snippet of the js file where the title animation is being managed:

// titles animation
$nextSlide.find('div.ei-title > h2')
.css( 'margin-right', 50 + 'px' )
.stop()
.delay( this.options.speed * this.options.titlesFactor )
.animate({ marginRight : 0 + 'px', opacity : 1 },  
this.options.titlespeed, this.options.titleeasing )
.end()
.find('div.ei-title > h3')
.css( 'margin-right', -50 + 'px' )
.stop()
.delay( this.options.speed * this.options.titlesFactor )
.animate({ marginRight : 0 + 'px', opacity : 1 }, 
this.options.titlespeed, this.options.titleeasing )

And here's the css file after adding the extra text as 'H4':

.ei-slider{
position: relative;
width: 100%;
max-width: 1999px;
height: 500px;
margin: 0 auto;
}
.ei-slider-loading{
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
z-index:999;
background: rgba(0,0,0,0.9);
color: #fff;
text-align: center;
line-height: 400px;
}
...(remaining CSS rules)
}

Lastly, here is the HTML/JS code on the webpage:

<div class="wrapper">
<div id="ei-slider" class="ei-slider">
<ul class="ei-slider-large">
...(slider content)
</script>

For the complete JavaScript file, you can refer to the link below:

View My Slider in Action!

Answer №1

Your plugin's jQuery code, as shown in the initial snippet you provided, is designed to animate each element (h2 and h3) sequentially.

To extend this animation to include h4, simply add the same code block and adjust the pixel values as desired.

        // titles animation
        $nextSlide.find('div.ei-title > h2')
              .css( 'margin-right', 50 + 'px' )
              .stop()
              .delay( this.options.speed * this.options.titlesFactor )
              .animate({ marginRight : 0 + 'px', opacity : 1 },  
        this.options.titlespeed, this.options.titleeasing )
              .end()
              .find('div.ei-title > h3')
              .css( 'margin-right', -50 + 'px' )
              .stop()
              .delay( this.options.speed * this.options.titlesFactor )
              .animate({ marginRight : 0 + 'px', opacity : 1 }, 
     this.options.titlespeed, this.options.titleeasing )
              .end()
              .find('div.ei-title > h4')
              .css( 'margin-right', -150 + 'px' )
              .stop()
              .delay( this.options.speed * this.options.titlesFactor )
              .animate({ marginRight : 0 + 'px', opacity : 1 }, 
     this.options.titlespeed, this.options.titleeasing )

In the code snippet, I set the margin-right for h4 to -150px to maintain consistency with the gap between h3 and h4, but feel free to customize this value to suit your specific requirements.

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

Generate an array consisting of characters within a designated range

I recently came across some Ruby code that caught my attention: puts ('A'..'Z').to_a.join(',') The output was: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z I'm curious if there is a similar way to achieve this ...

Encountering a null pointer exception when launching the Chrome browser using Selenium

Hope you all are doing well. I need assistance in resolving a null pointer issue while developing a new Selenium framework for my company. The problem arises after calling the method "StartBrowser()" from the base class in the browser class. Everything ru ...

Utilizing JavaScript to eliminate objects from a collection and showcase a refreshed arrangement

On a simple webpage using bootstrap and js/jquery, data is fetched via ajax to create entries displayed to the viewer. The process involves: - making a request - parsing XML to create an array of objects with all the data - sorting by one property - cr ...

Interactive Map Using HTML5, CSS, and JQuery

As someone venturing into the world of web front end development, I am curious about the process of mapping an image so that specific functions can be triggered by pressing different parts. In this case, the shapes will be irregular (such as a map of Europ ...

Tips for centering or aligning a component to the right using Material UI?

Is there an efficient method to align my button to the right of its parent in Material UI? One approach could be using: <Grid container justify="flex-end"> However, this would also require implementing another <Grid item />, which m ...

Transferring data from localStorage to MySQL database

Can anyone suggest a simple method for transferring data from localStorage or sessionStorage to a MySQL database using callbacks? I assume that AJAX would be involved, but I'm struggling to locate a comprehensive tutorial on the process. Essentially, ...

Show Navbar Toggler only when in Portrait mode on mobile devices, not Landscape mode

Attempting to create a responsive website utilizing Bootstrap 4, I encountered a problem with the menu expanding in Landscape orientation on mobile devices, causing distortion. How can I ensure the menu stays collapsed in Landscape orientation? Despite ha ...

What is the correct way to reference items during a loop iteration?

Take a look at http://jsfiddle.net/tAfkU/ When looping through an array, how can one correctly refer to the element of the array when callbacks are bound within the loop? var items = ["a", "b", "c"]; for(var i in items) { var this_item = items[i]; ...

Achieving full wrapping of border around the entire element

Trying to create a link that resembles a button, but facing an issue when the anchor text spans more than one word causing it to wrap onto the next line. This results in the border around the link/button not wrapping around the entire element. It appears a ...

How to conceal the border in a Bootstrap datetimepicker

I am currently using a bootstrap datetimepicker and I would like to eliminate the border around the days and months in the cell. This is my attempt so far: .bootstrap-datetimepicker-widget td { border: 0px !important; } I have also included a ...

What is the best way to add animation to my Navigation Button and ensure it performs the correct animation with JavaScript?

Can someone help me understand why my burger div (navigation button on mobile) is not animating to form an X shape? I've tried using JavaScript to toggle the class name but it doesn't animate the lines at 45 degrees. Any insights on what I might ...

Is it possible to adjust the font size in Bootstrap 4.6.2 to fit smaller fonts and bring back color to the tabs that were removed in the update?

While attempting to update Bootstrap from version 4.6.0 to 4.6.2 in a few codebases, I encountered some issues that prevented me from completing the upgrade successfully. The <small> tag and .small CSS class are now displaying larger than before. Ta ...

Ensure the correct file extension is chosen when selecting a file for the 'file_field' and display any error messages using Ruby on Rails

I am currently using Ruby on Rails 3 and Prototype, and I need to be able to check the file extension when a file is selected with file_field. I only want to allow files with extensions of .doc or .pdf, any other extensions should display an error. In my ...

What is the best way to distinguish elements in the same HTML using Angular Material?

Currently, I am working on a project using Angular material, where I have a component.html file that defines a form and a table with data. In the first image of my project, you can see the tab title, a form to add new records, and the table displaying exi ...

What are the steps to resolving an issue with importing a css file in next.js?

Error: ./node_modules/quill-emoji/dist/quill-emoji.css ModuleParseError: Module parse failed: Unexpected character '�' (1:0) You may need a suitable loader for handling this file type, as there are currently no configured loaders to process it. ...

What is the best way to transfer the text from the input box to a div at the bottom of the page?

Recently, I came across a small piece of HTML containing two input boxes, a checkbox, and an "Add" button: <div class="row"> <div class="form-group col-xs-4"> <input type="text" class="form-control" id="items" na ...

React element failing to appear on webpage

I'm having trouble loading the snippetInfo.js file in the HTML, and I can't seem to figure out why. I've searched online extensively for solutions, but none of them have worked for me. Whenever I try adding type='text/javascript' t ...

Array with distinct object properties

How can I create a new array of objects that are unique based on a specific property? Specifically, for this example, the property is "field": 0: Object field: "name" operator: "eq" value: "d" 1: Object field: "gridSearch" operator: "contains" value: "1" ...

What are the steps to creating a live editor for the plugin settings page in WordPress?

As the creator of the WordPress plugin Tipu Scroll To Top, I am seeking assistance on how to enable users to view live changes on the setting page. Currently, my implementation only utilizes jQuery for the scroll to top button, which is shown below: (func ...

Node.js: Breaking the Rules with an Illegal Break Statement

Struggling to generate a unique ID in Node.js and MongoDB, using a while loop that checks existing IDs in MongoDB until a unique value is found. If the ID is already taken, a number is added to the end until Mongo returns no results. Everything seems to b ...