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

Problems revolving around the fundamental CSS drop-down menu concept

I'm struggling to center a CSS drop-down menu on my webpage without causing the drop-down effect to break. No matter what I try, it seems to mess up. What am I missing? Snippet of code: html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,b ...

I am puzzled as to why it is searching for an ID rather than a view

Currently, I am attempting to navigate to a specific route that includes a form, but for some unknown reason, it is searching for an id. Allow me to provide you with my routes, views, and the encountered error. //celebrities routes const express = requir ...

Despite being a valid <link rel="shortcut icon">, a validation error occurs

I'm encountering an error with the w3.org validator related to this line of code: <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> The error message provided is as follows: Line 1, Column 727: Invalid value shortcut icon f ...

Issue with custom validator in Angular 6: setTimeout function not functioning as expected

Currently, I am in the process of following a tutorial to implement Asynchronous validation in Angular. The goal is to create a custom validator named shouldBeUnique that will be triggered after a 2-second delay. To achieve this, I have utilized the setTim ...

Fetching data from server using Ajax with PHP response

Need help with getting data from a PHP file on an AJAX call. Every time I make the call, it returns an error alert. Despite trying various methods, I am unable to figure out how to return an array from PHP to the AJAX call. This is what I have so far: AJ ...

Combining disparate arrays with serialized name/value pairs

Is there a way to merge an unassociated array with serialized name/value pairs without manually iterating over them? //First, I select certain values from mytable var data = $('#mytable input:checked'); console.log(data); //Object[input attribu ...

Trouble with the display none function

I am trying to achieve the following: If my shopping cart is empty, I want another div to display over the top of it. Instead of seeing the cart, users should see a message saying 'your cart is empty'. Currently, I have set the other div to dis ...

The problem of SVG rendering order requires a solution that does not rely on javascript

I am new to experimenting with inline svg, and I wanted to share my code: <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="350" height="350"> <defs> <style> .ring { transform-origin: 175px 175px; } ...

Is there a way to effectively organize an RSS feed using the .isoDate parameter while ensuring that the feed's elements remain interconnected (such as title and link)?

My goal is to organize the RSS feed by the most recent item while ensuring that each title corresponds correctly with its link. Currently, I am parsing and displaying the feed using the .isoDate property, but I am unsure of the best approach to achieve thi ...

Sinon - using callbacks in stubbed functions leading to test method exceeding time limit

One of my express route methods is structured as follows: exports.register_post = function(req, res) { var account = new Account(); account.firstName = req.param('firstName'); //etc... account.save(function(err, result) { ...

Scrollbar Overlay

I am currently working on an HTML page where I have implemented a CSS style overlay lightbox effect using CSS and jQuery. If you want to take a look at the code, click here One issue I am facing is that when I resize the window height so the right-hand s ...

What is the best way to retrieve a nested element from a JSON object using AngularJS?

Take a look at this Plunkr demonstration that showcases the ng-repeat functionality with a JSON file: Plunkr The code snippet below shows how I am displaying elements from $scope.foodlist: <li ng-repeat="food in foodlist"> ...

Sequelize.Model not being recognized for imported model

I am encountering an issue while trying to implement a sequelize N:M relation through another table. The error message I keep receiving is as follows: throw new Error(${this.name}.belongsToMany called with something that's not a subclass of Sequelize ...

Displaying hidden divs upon mouse hover using

Currently, I am in the process of creating a website that features a header with two rows of names. The goal is to have a specific div appear below the names when a user hovers over them. This div will include additional images and links for users to inter ...

Unpredictable jQuery modal form activation occurring twice

I have integrated Dropzone.js into my website for uploading images, and everything works smoothly during the upload process. However, I encounter a strange issue when attempting to delete the images. Occasionally, when clicking on the "trash" icon to delet ...

The integration of Angular 6 with AngularJS components fails to load properly in a hybrid application

Currently, I am in the process of upgrading a large AngularJS version 1.7.3 to a hybrid app using Angular 6. The initial phase involved converting all controllers/directives into an AngularJS component. Subsequently, I created a new Angular 6 project skele ...

jQuery modal popup failing to display the value of an element

When attempting to display content in a Bootstrap 4.0 modal on an ASP.NET Core 3.1 Razor page, the jQuery shown.bs.modal event seems to be failing to show the element value within the modal. Strangely, logging the assigned value to the console displays it ...

Looping through an array asynchronously and returning the result

I'm having some trouble with an asynchronous loop. Here's the code I've been working with: let items = []; data.forEach(async item => { var newItem = new Item(data); newItem.options = await this.fetchOptions(data[" ...

Instructions on how to ensure that an AJAX call will only function when the user is logged in within a Rails application

My application allows users to save photos by clicking on them, but this feature is only available when the user is logged in. Strangely, even when a user is logged out, they can still click on a photo and save it because the show page is identical for bot ...

The Chrome (version 58) webdriverio is currently inactive, while Firefox is up and running

Previously, I successfully ran automation tests on Firefox and Chrome locally. However, there seems to be an issue that has arisen when trying to run them on Chrome recently. My system configurations: Operating System: Windows 10 (64-bit) Chrome Versio ...