Using jQuery to Generate an Automatically Updating Timer for Slideshow - Pausing on Mouse Click

My first slideshow with jQuery is up and running, but it's very basic and hard coded. I want to add an automatic scrolling effect every 8 seconds to the next item before looping back to the beginning.

I have an idea on how to achieve this, but I want to follow best practices in my design

HTML:

<div id="slideWrap">
<div id="slides">
    <ul id="slidePane">
        <li><img src="css/images/slides/slide1.png" alt="img1" /></li>
        <li><img src="css/images/slides/slide2.png" alt="img2" /></li>
        <li><img src="css/images/slides/slide3.png" alt="img3" /></li>
        <li><img src="css/images/slides/slide4.png" alt="img4" /></li>
    </ul>
</div>
<div id="slideNav">
    <ul>
        <li class="active"><h2>Packages</h2></li>
        <li><h2>Portfolio</h2></li>
        <li><h2>Prices</h2></li>
        <li><h2>About</h2></li>
    </ul>
</div>
</div>

jQuery:

<script>
(function() {
var slider = $('#slides'),
        imgWid = $('ul#slidePane img').width(),
        imgHeight = -300,
        imgs = 4,
        imgsHeight = 3200; 

$('#slideNav ul li').on('click', function() {
        var listSel = $(this),
            selImg = $('#slideNav li').index(this);

        $(this).addClass('active');
        $(this).siblings('li').removeClass('active');
        slider.animate({
            'margin-top': imgHeight * selImg
        });
    });
})();
</script>
  • I'm looking for guidance on implementing a feature that allows for auto-scrolling through items vertically until user interaction stops it. *

Live Host:

If you need my CSS code, please let me know although I believe it may not be relevant to the question.

Answer №1

Instead of taking the modern approach, I think I'll stick to the good old-fashioned method of doing it by hand. It may not be the easiest way, but sometimes simplicity is best. I'll share the outcomes here in due time.

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

The Ajax Success event fails to trigger when invoking a service

I am currently using JQuery to send an AJAX request to a local service. The local service is a HttpHandler named Request.ashx, which in turn calls an external website with CallExternalWebsite(). This is achieved through .NET's System.Net.WebRequest() ...

Learn how to implement a feature in your chat application that allows users to reply to specific messages, similar to Skype or WhatsApp, using

I am currently working on creating a chatbox for both mobile and desktop websites. However, I have encountered an obstacle in implementing a specific message reply feature similar to Skype and WhatsApp. In this feature, the user can click on the reply butt ...

Column Alignment Problem in Bootstrap

I'm currently working on a blog template project that resembles the design of this particular page However, I've encountered an issue with aligning the grids in a way that meets my requirements. To showcase my problem, I have shared my version o ...

The Javascript function will only initiate upon a manual reload of the page

My function is working perfectly, but only after I reload the page once it has been loaded. This function is a timer that starts counting down from 10 to 0 as soon as the page loads (which is the intended behavior). However, when I first land on the page ...

When using jQuery and AJAX together, it seems that the POST method is returning

Currently experimenting with Cloud9. The current project involves creating an image gallery. On the initial page: There are a few pictures representing various "categories". Clicking on one of these will take you to the next page showcasing albums fro ...

Angular 1.5 component using HTTP GET

Trying to utilize a 1.5 component with AngularJS has presented some challenges for me. I have a service that fetches my JSON file using $HTTP and returns a promise. In the controller of my component, I resolve the promise and assign it to a value using thi ...

Issues with Joomla's mobile menu compatibility

We are currently working on a Joomla website that can be accessed through this link. The site functions perfectly with two menus when viewed on a desktop screen. However, the issue arises when it is accessed from a smartphone like an iPhone 5, as instead o ...

Deliver real-time notifications to linked users by leveraging socket.io and node.js

Is there a solution for sending real-time updates to connected clients every second without using the setInterval() function in nodejs and socket.io? Please provide an alternative method that fits my specific scenario. ...

Navigating the battleground between native and HTML5 mobile applications

As an experienced iOS developer with knowledge in Windows Phone and Android, I have observed the increasing popularity of HTML5 web-apps over native apps. This shift towards HTML5 development frustrates me, as a strong argument can be made for native app d ...

Updating the chosen value in an HTML select menu dynamically using PHP

I understand that there are existing examples discussing how to dynamically set the selected tag in an HTML option tag. However, I am encountering a complex issue involving break statements and quotations while trying to accomplish this. In my code: whil ...

Transform ajax functionality into jquery

I need help converting an AJAX function to a jQuery function, but I'm not sure how to do it. function convertToJquery() { // Create our XMLHttpRequest object var hr = new XMLHttpRequest(); // Set up variables needed to send to PHP file var ur ...

JavaScript Datepicker Formatting

I need to modify the date format of a datepicker. Currently, it displays dates in MM/DD/YYYY format but I want them to be in DD-MM-YYYY format. <input id="single-date-picker" type="text" class="form-control"> Here's the JavaScript code: $("# ...

Issues arise when trying to integrate iframes with Ionic and AngularJS, as they

Using iframes in my ionic app to display webpages within the application has presented a challenge. This is what I currently have implemented: <iframe class= 'webPage' name= "eventsPage" ng-src="{{object.url}}"></iframe> The issue ...

Problems with WordPress Theme Rendering in Outdated Versions of Internet Explorer

Currently, I am developing a website for Chase on the Lake at http://chaseonthelake.com/. While everything looks perfect in FireFox, there are some display issues when viewing it in Internet Explorer. The dropdown transparency is not showing correctly, m ...

Exploring the Depths of the DOM: Enhancing User Experience with Jquery

I am facing an issue with my AJAX request in my page. After retrieving data from the database and trying to append it to a div, I am attempting to create an accordion interface without success. Below is a snippet of my source code after the AJAX call: ...

Running multiple instances of setTimeout() in JQuery

I'm looking for a way to delay the execution of 10 lines of independent jQuery code with 2 seconds between each line. I initially tried using setTimeout() on each line, but is there a more elegant solution for this scenario? The jQuery DELAY method do ...

Modify the anchor text when a malfunction occurs upon clicking

Whenever I click on the link, I am able to retrieve the correct id, but the status changes for all posts instead of just the selected item. Below is the HTML code: <div th:each="p : ${posts}"> <div id="para"> <a style="float: right;" href= ...

When an image is clicked, I would like it to redirect to a different page

In my slider image list, each image has an ID. If the ID becomes equal to a specific number, such as 24, I want that particular image to move to another page when clicked. Here is the code snippet: <?php $sql = "select * from ".$tblImages." Where cid= ...

What is the process for building a grid system similar to Bootstrap's 12-column grid using the new CSS Grid Layout?

Is there a way to implement a 12-column grid system similar to Bootstrap using CSS Grid? I am struggling to understand this new technology and would greatly appreciate it if someone could provide a demo. My goal is to create a simple grid structure resem ...

Improving User Experience with HTML Form Currency Field: Automatically Formatting Currency to 2 Decimal Places and Setting Maximum Length

Hello there, I am currently facing an issue with the currency auto-formatting in a deposit field on my form. The formatting adds 2 decimal places (for example, when a user types 2500, the field displays 25.00). However, the script I wrote does not seem to ...