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 8785823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:27:30+00:00 2026-06-13T21:27:30+00:00

I have a jquery images scroller below that just scrolls horizontally left/right. The loop

  • 0

I have a jquery images scroller below that just scrolls horizontally left/right. The loop below could include an infinite number of images.

The problem I have is that while it scrolls left and right fine, once the images end you can just keep scrolling so essentially you’re just scrolling over white space!

How can I set a max scroll so that when the images end it won’t allow it to scroll anymore? Obviously the number of images is dynamic so it can have 1 or 100 images in there.

<div id="imgThumbs" class="scroller" style="position:relative;height:75px;width: 306px; overflow: hidden; white-space: nowrap;">
    <a href="#" id="left-button" style="left:14px;top:25px;position:absolute;">
        <img src="left-button.png" width="20" height="20" />
    </a>  
    <a href="#" id="right-button" style="right:14px;top:25px;position:absolute;">
        <img src="right-button.png" width="20" height="20" />                               
    </a>
    <div id="contentScroller">                         
    <?php $counter = 1; while(the_repeater_field('images')): ?>                     
        <a class="fancybox" rel="group" href="<?php echo the_sub_field('high_resolution_image'); ?>" style="text-decoration:none!IMPORTANT;color:white!IMPORTANT;" class="showImg">
            <img class="image-<?php echo $counter; ?>" src="<?php echo the_sub_field('image'); ?>" width="90" height="68" alt="<?php echo the_title(); ?> <?php echo $counter; ?>" />
        </a>
     <?php $counter++; endwhile; ?>
     </div>
</div>
<script>
    jQuery(document).ready(function ($) {
        $('#right-button').click(function() {
            $('#contentScroller').animate({
                marginLeft: "-=306px"
            }, "fast");
        });
        $('#left-button').click(function() {
            $('#contentScroller').animate({
                marginLeft: "+=306px"
            }, "fast");
        });                     
    });
</script> 

UPDATE

Here’s a fiddle – http://jsfiddle.net/jCskY/2/

  • 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-06-13T21:27:31+00:00Added an answer on June 13, 2026 at 9:27 pm

    Compare the marginLeft with the width calculated by the sum of content a‘s widths.

    If the margin passes the width, it should hide the button. Otherwise, it should show.

    Here is a snippet of how it would be implemented.

    Also, see this fiddle, for live example!

    var updateRightLeftButtons = function() {
        if (306 > (parseInt($('#contentScroller').css('marginLeft')) * -1)) {
            $('#left-button').hide();
        } else {
            $('#left-button').show();
        }
        if ((($('#contentScroller a').width() * $('#contentScroller a').length) - 306) < (parseInt($('#contentScroller').css('marginLeft')) * -1)) {
            $('#right-button').hide();
        } else {
            $('#right-button').show();
        }
    };
    $('#right-button').click(function() {
        updateRightLeftButtons();
        if ($(this).is(':visible'))
        $('#contentScroller').animate({
            marginLeft: "-=306px"
        }, "fast", updateRightLeftButtons);
    });
    $('#left-button').click(function() {
        updateRightLeftButtons();
        if ($(this).is(':visible'))
        $('#contentScroller').animate({
            marginLeft: "+=306px"
        }, "fast", updateRightLeftButtons);
    });
    updateRightLeftButtons();​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have put together an image scroller using jquery, like this function rotateImages(whichHolder, start)
I am trying to upload multiple images and I have a jquery plugin set
I have the following jQuery which I want to output a list of images.
I have a list of images inside divs and a jquery ui slider, when
I have played around and implemented JQuery cycle to create a carousel with images,
I have been creating an image gallery with jQuery, all is done. The images
I'm using jQuery validation plugin. I have two images: first background of label, when
I am creating my own carousel slideshow for images, using Jquery. Currently i have
I am using the Quickflip 2 plugin ( http://jonraasch.com/blog/quickflip-2-jquery-plugin/comment-page-3#comment-3562 ) to have images flip
I have a jQuery tools scroller set up with controls managing two separate divs

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.