What are some effective ways to slow down the image transitions in a Javascript slideshow?

I am currently developing a slideshow that updates Images, Title, and Description simultaneously based on their Array index.

The slideshow is functional BUT, my goal is to achieve a smooth transition to the next/previous Image (... title & description) when users click the "Next" and "Previous" buttons.

This can be implemented using either javascript or jquery.
Any assistance or recommendations would be greatly appreciated. Thank you.

Below is the provided HTML:

    <div class="featured">
        <div class="infofeat">
            <div class="infocont">
                <h1>FEATURED</h1>
                    <div id="feat_title">
                        First Title
                    </div>
                    <div id="description">
                        First Description
                    </div>
                <div id="controllers">
                    <a  id="_previous"href="#" onclick="return change_image(-1)" > Previous </a>
                    <a  id="_next"href="javascript:change_image(1)" > Next </a>
                </div>
            </div>
        </div>
        <div class="picfeat">
            <img src="images/designs/tempfeatured.jpg" name="slideshow" />
        </div>
    </div>

The slideshow's Javascript code is as follows:

var Image = new Array("images/designs/tempfeatured.jpg", "../images/designs/feat2.jpg", "../images/designs/feat3.jpg");
var Description = new Array ("First description", "Second Description", "Third Description");
var Title = new Array("First Title", "Second Title", "Third Title")
var Image_Number = 0;
var Image_Length = Image.length - 1;

function change_image(num){

    Image_Number = Image_Number + num;

    if (Image_Number > Image_Length){

        Image_Number = 0;

    }
    if (Image_Number < 0){

        Image_Number = Image_Length;

    }


    document.slideshow.src= Image[Image_Number];
    document.getElementById("description").innerHTML = Description[Image_Number];
    document.getElementById("feat_title").innerHTML = Title[Image_Number];
    return false;
}

You can test the functionality on JsFiddle here . Thank you for your support.

Answer №1

Whenever a fresh image is loaded, place it beneath the original picture in a secondary image at the same position:

    <div class="picfeat">
        <img src="images/designs/tempfeatured.jpg" name="slideshow" style="position: absolute; z-index: 5" />
        <img src="images/designs/feat2.jpg" name="slideshow" style="position: relative; z-index: -5" />
    </div>

After that, use jQuery to fade out the initial image:

$('.picfeat:first-child').fadeOut(2000); // quite slow

Answer №2

Utilizing CSS3, I believe it is possible to achieve the desired outcome. Check out this webpage and let me know if you find it useful:

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

Using an Ajax call within an event handler function

After spending a full day attempting to execute an AJAX call within an event handler function, I've tried various combinations of when(), then(), and done(), as well as setting async: false. However, I keep encountering undefined errors despite my eff ...

What is the proper way to eliminate the port from a URL so that the images sourced from the XAMPP database can function correctly?

I am a beginner in Angular and I am facing an issue with Angular and XAMPP. I am attempting to load images from mySQL database where I stored their destinations. The problem is that Angular is trying to access that destination through this link: This is m ...

Creating a CSS full-width navigation menu

Recently, I came across a menu code on the web that seemed great. However, I wanted to make my menu responsive and full width. Since I am new to CSS and HTML, adjusting the menu code has been a bit of a challenge for me. .menu, .menu ul { list-style: ...

Troubleshooting code: JavaScript not functioning properly with CSS

I am attempting to create a vertical header using JavaScript, CSS, and HTML. However, I am facing an issue with the header height not dynamically adjusting. I believe there might be an error in how I am calling JSS. Code : <style> table, tr, td, t ...

How can I retrieve all links using XPath in Puppeteer when there are issues with pausing or functionality?

I am having issues with using XPaths to select all links on a page in my Puppeteer app. Sometimes the method I am using gets stuck and causes my crawler to pause. I'm wondering if there is a better way to retrieve all links from an XPath or if there m ...

The ts-node encountered an issue with the file extension in this message: "TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension

When using ts-node, I encountered the following error: $ ts-node index.ts TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/projects/node-hddds8/index.ts I attempted to remove "type": "module& ...

Is it possible to prompt npm to install a sub-dependency from a GitHub pull request?

Currently, I'm in the process of setting up geofirestore, which has a dependency on geofirestore-core. However, there is an existing bug in geofirestore-core that has been addressed in a pull request. How can I make sure that my geofirestore installa ...

Mapping with Star Components

As a newcomer to ReactJs, my task is to create a 5-star review component with the ability to display half-star ratings. I previously implemented this in Angular5. Within the map method, I need to loop through the following elements: <!-- full star -- ...

What is the best way to extract all the data from a JSON using a shared key?

I'm trying to extract an array containing all the name values from a JSON structure. This is how my JSON data is structured: { "profile": { "G5j7": { "name": "siddharth", "age": &quo ...

ReactJS import duplication problem arising from utilizing npm link for component testing prior to npm package release

I have a basic component structured like this. import React, {useState} from 'react'; function MyComponentWithState(props) { const [value, setValue] = useState(0); return ( <p>My value is: {value}</p> ) } expo ...

Integrate Ruby parameter into JavaScript in Rails

I have a div that I want to turn into a link to another page. Typically, we achieve this using link_to link. <% for item in @items %> <%= link_to "Item", item %> # -> or <%= link_to(item) %> <% end %> However, I need the ent ...

Creating interactive tabs within the HTML document with AngularJS

Trying to customize the tab layout on my HTML page and I have a code similar to this: <form name="requestForm"> <div class="form-group col-md-6 md-padding"> <div class="text-primary"> <h3>Create Request</h3> ...

Is there an issue with the JSON data?

"stocksdata" :[{"id":7,"SCRIP":"ASIANPAINT","LTP":3341,"OHL":"BUY","ORB15":"BREAKOUT","ORB30":"NT","PRB":"NA","CAMARILLA& ...

A dynamic image carousel featuring multiple images can be enhanced with fluid movement upon a flick of

I am trying to enhance this image slider in HTML and CSS to achieve the following objectives: 1. Eliminate the scroll bar 2. Implement swipe functionality with mouse flick (should work on mobile devices as well) 3. Make the images clickable .slider{ ove ...

Utilizing props for toggling the navigation list, incorporating nested arrays or objects

My issue involves two components that are loading data. I want the links to be output like this: group1 linka linkb However, they are currently displaying like this: group1 linka group1 linkb I believe the problem lies in how I am handling the ...

How can I pass GET data and make it accessible in another PHP page through ajax?

After gaining access to www.mysite.com/index.php?order_by=id asc I need to send $name AND $_GET[order_by] to autoload_process.php. How should I proceed? . . . The contents of index.php are as follows: <!DOCTYPE html> <html> <head> ...

Transparent background with opaque text

I noticed that my div has a gray background with some opacity. <div className="absolute w-full h-full top-0 left-0 right-0 bottom-0 bg-slate-500 opacity-50 z-10"> <p className="relative top-1/2 px-8 text-center hea ...

Tips for preventing the loss of ajax calls when an Oauth access-token expires

As the creator of a JavaScript browser application (SPA) that communicates with a server protected by OAuth 2, I encounter the challenge of using short-lived access tokens and longer-lived refresh tokens. While this specific scenario involves my own server ...

Utilize the Multer file upload feature by integrating it into its own dedicated controller function

In my Express application, I decided to keep my routes.js file organized by creating a separate UploadController. Here's what it looks like: // UploadController.js const multer = require('multer') const storage = multer.diskStorage({ dest ...

Exploring the complexities of object scope in Javascript

I'm having trouble accessing certain variables from a function. Here's the issue I'm facing: var PTP = function (properties) { this.errorsArray = [] } PTP.prototype.initHTMLItems = function () { $('input[data-widget-type="dat ...