Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7703923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:34:11+00:00 2026-05-31T23:34:11+00:00

I recently started using JQuery and created a little slider to display logos of

  • 0

I recently started using JQuery and created a little slider to display logos of website sponsors and such. It seemed to be working properly for me using Firefox. I decided to load up the site in Chrome and it behaves rather strange. The animation seems fine until the first div(the slider is split into two divs, so that the first can move to the end once it has completed it’s pass through the masking div) enters the screen for the second(and each concurrent) pass. The first div seems to move more rapidly, and overtakes the second div. Any ideas what would cause this? It only seems to happen in Chrome and Safari. IE worked even!

$(document).ready(function () {
var s1 = $("div[name=s1]");
var s2 = $("div[name=s2]");
var release = 0;
var speed = 75; //px per sec
var interval = 100; //milliseconds per animation
var origSpeed = speed;

function slide() {
    release = 1 - release;
    if (release == 0) {
        return;
    }
    distance = "+=" + (parseInt(s1.width(), 10) + parseInt(s2.width(), 10)) + "px";
    if ((-1 * parseInt(s1.css("left"), 10)) > parseInt(s1.width(), 10)) {
        s1.css({left: distance});
    }
    if ((-1 * parseInt(s2.css("left"), 10)) > (parseInt(s1.width(), 10) + parseInt(s2.width(), 10))) {
        s2.css({left: distance});
    }
    slide_again();
}

function slide_again() {
    $("div[id=slider]").animate({left: "-=" + interval * (speed / 1000) + "px"}, interval, "linear", slide);
}

    $("div[id=slider]").hover(function() {
    speed = 0;
    }, function() {
        speed = origSpeed;
    });

    slide();
});

You can see it in action here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:34:12+00:00Added an answer on May 31, 2026 at 11:34 pm

    Animation depends on timed interrupts. There is no guarantee of exact timings, and so depending on implementation, the timing of your two sliders may diverge.

    If you just use one slider element, you won’t run into that issue. It also simplifies the code quite a bit. The way to do this is to replicate your slider elements (using jQuery) and then animate half the width (the pre-duped width) and start over:

    $(window).load(function() {
        var speed = 75; //px per sec
    
        // Get the width of the slider before you duplicate it
        var width = $('#slider').outerWidth();
    
        // Repeat the inner content by cloning and appending it to the end
        $('#slider').append($('#slider').children().clone());
    
        function slide() {
            // The duration takes into account the current position
            // in case you are starting from a hover-pause
            var curleft = $('#slider').position().left;
            var duration = (width+curleft) * 1000 / speed;
            $("#slider").animate({
                // Animate until original width slides off to left
                left: "-" + width + "px"
            }, duration, "linear", function() {
                // Reset to original position and start over
                $(this).css("left", "0px");
                slide();
            });
        }
    
        $("#slider").hover(function() {
            $('#slider').stop();
        }, function() {
            slide();
        });
    
        slide();
    });
    

    You can also change your hover to just do .stop() and slide() as long as you do a little extra math in your slide() call to see where you currently are.

    Demo: http://jsfiddle.net/6Dxg6/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started using Vim as my text editor and am currently working
I've only recently started using jQuery and am having no problems with most of
I recently started working with KnockoutJs and quickly realized using the default Json(myModelWithADate) resulted
Recently I started using https://github.com/crowdint/rails3-jquery-autocomplete It works great, but I was trying to set
Recently, I started using the email validation regular expression from the JQuery validation plugin
I recently started using the Yii framework trying to learn a little bit more
[See update for a more precise specification ...] I recently started using the jquery
I've recently started using prettyphoto to display a video. This is my current setup
I recently started using Eclipse at work for my Java servlet projects. I've been
We recently started using maven for dependency management. Our team uses eclipse as it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.