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

  • SEARCH
  • Home
  • 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 6763295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:27:32+00:00 2026-05-26T14:27:32+00:00

So I have my script running, (you can use sample links/images to test) but

  • 0

So I have my script running, (you can use sample links/images to test)
but I have an issue. After counting my images for length, it seems that
my “interim period” before the slider starts back / repeats itself is
about triple the length of the images. We can test it by using sample
urls.

<a class='wrapper' href='http://www.universallifechurchministers.org/images/big_image/ConanObrien.jpg' title="Conan O'Brien: TV host, comedian, writer, producer and performer."><img class='logo' alt="TV host, comedian, writer, producer and performer." id='conanobrien' src='http://www.universallifechurchministers.org/images/conan-obrien-sm.jpg' /><div class='long'>[.....]</div></a>
<a class='wrapper' href='http://www.universallifechurchministers.org/images/big_image/RobDyrdek.jpg' title="Rob Dyrdek: Skateboarding Entrepreneur, Fantasy Factory on MTV."><img class='logo' alt="Skateboarding Entrepreneur, Fantasy Factory on MTV." id='robdyrdek' src='http://www.universallifechurchministers.org/images/rob-drydek-sm.jpg' /><div class='long'>[.....]</div></a>
<a class='wrapper' href='http://www.universallifechurchministers.org/images/big_image/Glann-Beck.jpg' title="Glenn Beck: Talk Radio Host"><img class='logo' alt="Talk Radio Host" id='glennbeck' src='http://www.universallifechurchministers.org/images/image1.jpg' /><div class='long'>[.....]</div></a>
<a class='wrapper' href='http://www.universallifechurchministers.org/images/big_image/Mel-Blanc.jpg' title="Mel Blanc: Voice Actor"><img class='logo' alt="Voice Actor" id='melblanc' src='http://www.universallifechurchministers.org/images/image2.jpg' /><div class='long'>[.....]</div></a>

left: -632.914px seems to what my slider stops at before it starts sliding again.
I would like it to start again immediately afterward at the end of the last image,
but cannot figure out what is stopping it from doing that?

[You can see it working here] and here’s the full code source

<!DOCTYPE html>
<html>
  <head>
    <style>

        /* js-disabled class - set image sizes so they all fit in the viewer */
        .js-disabled img { width:100px; height:100px; display:block; float:left; margin:30px 0 0; }
        .wrapper {padding: 0 5px;}
        .long { display:none; }

        #outerContainer { width:542px; height:202px; margin:auto; position:relative; margin:220px auto; }
        #imageScroller { width:675px; height:202px; position:relative; background: url(filmstrip_right.png) no-repeat; }
            #viewer {
                background-color: #000000;
                height: 72px;
                margin: auto;
                overflow: hidden;
                position: relative;
                right: 10px;
                top: 51px;
                width: 540px;
            }
        #imageScroller a:active, #imageScroller a:visited { color:#000000; }
        #imageScroller a img { border:0; }
            #controls {
                background: url("images/controlsBG.png") no-repeat scroll 0 0 transparent;
                height: 47px;
                left: 11px;
                position: absolute;
                top: -7px;
                width: 534px;
                z-index: 10;
            }

            #cover {
                background: url("images/cover.png") no-repeat scroll 0 0 transparent;
                height: 71px;
                left: 57px;
                position: absolute;
                top: 51px;
                width: 38px;
                z-index: 999;
            }
        #controls a { width:37px; height:35px; position:absolute; top:3px; }
        #controls a:active, #controls a:visited { color:#0d0d0d; }
        #title { color:#000; font-family:arial; font-size:13px; font-weight:bold; width:100%; text-align:center; margin-top:13px; }

    </style>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>[....]</title>
  </head>
  <body>
        <div id="outerContainer">
            <div id="imageScroller">
                <div id="cover"></div>
                <div id="viewer" class="js-disabled">

                    <?php   include('famous/class/scraper.php');
                            $scrape = new Scraper('http://www.universallifechurchministers.org');
                            $scrape = (array)$scrape;

                        foreach($scrape as $multi) {
                         if(is_array($multi)) {

                            $holder = ''; 
                            foreach($multi as $single) {

                                foreach($single as $k=>$v)  { 
                                    switch($k) {
                                        case 'fimg': $fimg = $v; break;
                                        case 'simg': $simg = $v; break;
                                        case 'name': $name = $v; break;
                                        case 'note': $note = $v; break;
                                        case 'long': $long = $v; break; 
                                    }
                                }

                                    $id = strtolower( //clean
                                           str_replace("'",'',
                                           str_replace(' ','',$name)
                                          ));

                                /* sample output:   <a class='wrapper' href='[uri]/*-lrg.jpg' 
                                 *                     title='[note]'>
                                 *
                                 *                  <img class='logo' alt='[note]' id='[cleanName]' 
                                 *                       src='[uri]/*-sm.jpg' /></a>
                                 *
                                 *                  [....repeat....]
                                 */

                                $holder .= "<a class='wrapper' href='" . $fimg . "' title=\""
                                            . $name . ': ' . $note. "\"><img class='logo' alt=\"" . $note . "\" id='" 
                                            . $id . "' src='" 
                                            . $simg . "' /><div class='long'>"
                                            . $long . "</div></a>";
                            }
                         }
                        }

                        #echo $holder;

                    ?>

                    <!--// test-data //-->
                    <a class='wrapper' href='http://www.universallifechurchministers.org/images/big_image/ConanObrien.jpg' title="Conan O'Brien: TV host, comedian, writer, producer and performer."><img class='logo' alt="TV host, comedian, writer, producer and performer." id='conanobrien' src='http://www.universallifechurchministers.org/images/conan-obrien-sm.jpg' /><div class='long'>[.....]</div></a>
                    <a class='wrapper' href='http://www.universallifechurchministers.org/images/big_image/RobDyrdek.jpg' title="Rob Dyrdek: Skateboarding Entrepreneur, Fantasy Factory on MTV."><img class='logo' alt="Skateboarding Entrepreneur, Fantasy Factory on MTV." id='robdyrdek' src='http://www.universallifechurchministers.org/images/rob-drydek-sm.jpg' /><div class='long'>[.....]</div></a>
                    <a class='wrapper' href='http://www.universallifechurchministers.org/images/big_image/Glann-Beck.jpg' title="Glenn Beck: Talk Radio Host"><img class='logo' alt="Talk Radio Host" id='glennbeck' src='http://www.universallifechurchministers.org/images/image1.jpg' /><div class='long'>[.....]</div></a>
                    <a class='wrapper' href='http://www.universallifechurchministers.org/images/big_image/Mel-Blanc.jpg' title="Mel Blanc: Voice Actor"><img class='logo' alt="Voice Actor" id='melblanc' src='http://www.universallifechurchministers.org/images/image2.jpg' /><div class='long'>[.....]</div></a>

                </div>
            </div>

        </div>
        <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
        <script type="text/javascript">
            $(function() {

              //remove js-disabled class
                $("#viewer").removeClass("js-disabled");

              //create new container for images
                $("<div>").attr("id", "container").css({ position:"absolute"}).width($(".wrapper").length * 170).height(170).appendTo("div#viewer");

                //add images to container
                $(".wrapper").each(function() {
                    $(this).appendTo("div#container");
                });

                //work out duration of anim based on number of images (1 second for each image)
                var duration = $(".wrapper").length * 2000;

                //store speed for later (distance / time)
                var speed = (parseInt($("div#container").width()) + parseInt($("div#viewer").width())) / duration;

                //set direction
                var direction = "rtl";

                //set initial position and class based on direction
                (direction == "rtl") ? $("div#container").css("left", $("div#viewer").width()).addClass("rtl") : $("div#container").css("left", 0 - $("div#container").width()).addClass("ltr") ;

                //animator function
                var animator = function(el, time, dir) {

                    //which direction to scroll
                    if(dir == "rtl") {

                      //add direction class
                        el.removeClass("ltr").addClass("rtl");

                        //animate the el
                        el.animate({ left:"-" + el.width() + "px" }, time, "linear", function() {

                            //reset container position
                            $(this).css({ left:$("div#imageScroller").width(), right:"" });

                            //restart animation
                            animator($(this), duration, "rtl");

                            //hide controls if visible
                            ($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;            

                        });
                    } else {

                      //add direction class
                        el.removeClass("rtl").addClass("ltr");

                        //animate the el
                        el.animate({ left:$("div#viewer").width() + "px" }, time, "linear", function() {

                            //reset container position
                            $(this).css({ left:0 - $("div#container").width() });

                            //restart animation
                            animator($(this), duration, "ltr");

                            //hide controls if visible
                            ($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;            
                        });
                    }
                }

                //start anim
                animator($("div#container"), duration, direction);

                //pause on mouseover
                $("a.wrapper").live("mouseover", function() {

                    //stop anim
                    $("div#container").stop(true);

                    //show controls
                    ($("div#controls").length == 0) ? $("<div>").attr("id", "controls").appendTo("div#outerContainer").css({ opacity:0.7 }).slideDown("slow") : null ;
                    ($("a#rtl").length == 0) ? $("<a>").attr({ id:"rtl", href:"#", title:"rtl" }).appendTo("#controls") : null ;
                    ($("a#ltr").length == 0) ? $("<a>").attr({ id:"ltr", href:"#", title:"ltr" }).appendTo("#controls") : null ;

                    //variable to hold trigger element
                    var title = $(this).attr("title");

                    //add p if doesn't exist, update it if it does
                    ($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
                });

                //restart on mouseout
                $("a.wrapper").live("mouseout", function(e) {

                    //hide controls if not hovering on them
                    (e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;

                    //work out total travel distance
                    var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width());

                    //work out distance left to travel
                    var distanceLeft = ($("div#container").hasClass("ltr")) ? totalDistance - (parseInt($("div#container").css("left")) + parseInt($("div#container").width())) : totalDistance - (parseInt($("div#viewer").width()) - (parseInt($("div#container").css("left")))) ;

                    //new duration is distance left / speed)
                    var newDuration = distanceLeft / speed;

                    //restart anim
                    animator($("div#container"), newDuration, $("div#container").attr("class"));

                });

                //handler for ltr button
                $("#ltr").live("click", function() {

                    //stop anim
                    $("div#container").stop(true);

                    //swap class names
                    $("div#container").removeClass("rtl").addClass("ltr");

                    //work out total travel distance
                    var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width());

                    //work out remaining distance
                    var distanceLeft = totalDistance - (parseInt($("div#container").css("left")) + parseInt($("div#container").width()));

                    //new duration is distance left / speed)
                    var newDuration = distanceLeft / speed;

                    //restart anim
                    animator($("div#container"), newDuration, "ltr");
                });

                //handler for rtl button
                $("#rtl").live("click", function() {

                    //stop anim
                    $("div#container").stop(true);

                    //swap class names
                    $("div#container").removeClass("ltr").addClass("rtl");

                    //work out total travel distance
                    var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width());

                    //work out remaining distance
                    var distanceLeft = totalDistance - (parseInt($("div#viewer").width()) - (parseInt($("div#container").css("left"))));

                    //new duration is distance left / speed)
                    var newDuration = distanceLeft / speed;

                    //restart anim
                    animator($("div#container"), newDuration, "rtl");
                });
            });
        </script>
  </body>
</html>
  • 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-26T14:27:33+00:00Added an answer on May 26, 2026 at 2:27 pm

    This line under the “rtl” logic tells the element to keep sliding until -632px (the width of the element).

        //animate the el
        el.animate({
            left: "-" + el.width() + "px"
        }, time, "linear", function() {
    

    Take off the + “px” and use ‘-=’ instead!

        //animate the el
        el.animate({
            left: "-=" + el.width()
        }, time, "linear", function() {
    

    I don’t really understand why you are taking this approach though. Why not just use this, which would slide it just until it leaves “viewer”?

        //animate the el
        el.animate({
            left: ($('div#viewer').offset().left - $('div#container').outerWidth()) + "px"
        }, time, "linear", function() {
    

    Also, why is #container so wide? Why not just let it remain the width of the contents? Does it really need to be as wide as .wrapper?

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

Sidebar

Related Questions

I have this script, running on a links list: $('li#linkcat-25 a').bind('click', function (e) {
I have a script running a batch of very similar queries. All of them,
I have a PHP script running on XAMPP in Windows XP that will open
Suppose we have a BASH script running some commands in the background. At some
I have a PHP script with infinite loop. I need this script running forever.
I have a Perl/POE/Tk script running on Win32 ActivePerl that calls executables using system
I have a php script that is running in CLI and I want to
I have a Python script that is running a few ls commands. This script
I have a script that I'm running from the home directory to search for
I have a script in place and running that allows me to move an

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.