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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:24:12+00:00 2026-06-12T13:24:12+00:00

I have a carousel and I need to reposition the carousel slides based on

  • 0

I have a carousel and I need to reposition the carousel slides based on the current width of the browser. The rules I need to follow are:

browserWidth > 1200: do not reposition slide
browserWidth > 960 && browserWidth < 1200: move slide background X position based 
                                           on the formula (25/48*browserWidth)-625
browserWidth < 960: reposition background X position to -125px

I wrote some JavaScript to do this, but whenever I resize the browser the image starts to blink alot. I assume the computer is having trouble trying to re-render the background images since they are such high resolutions. Is there a way to fix this blinking problem?

$(window).resize(function() {
    var winW = $(window).width();
    if (winW > 960 && winW < 1200) {
        $('#' + carouselID).css('left', '600px' ); 
        var leftValue = ((25/48) * winW - 625) + 'px';
        var backgroundAtr = 'url(http://www.placehold.it/1200x800) ' + leftValue + ' top no-repeat';
        $('#' + carouselID + ' .slides .slide').css('background', backgroundAtr );
    } else if (winW <= 960) {
        $('#' + carouselID).css('left', '600px' ); 
        var leftValue = '-125px';
        var backgroundAtr = 'url(http://www.placehold.it/1200x800) ' + leftValue + ' top no-repeat';
        $('#' + carouselID + ' .slides .slide').css('background', backgroundAtr );
    } else if (winW >= 1200) {
        $('#' + carouselID).css('left', '50%' );
        var leftValue = 'left';
        var backgroundAtr = 'url(http://www.placehold.it/1200x800) ' + leftValue + ' top no-repeat';
        $('#' + carouselID + ' .slides .slide').css('background', backgroundAtr );
    }
});
  • 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-12T13:24:14+00:00Added an answer on June 12, 2026 at 1:24 pm

    I would suggest putting the resize code inside a timeout. Some browsers like to fire multiple resize events, which could be what is causing the flashing to occur. Try something like this:

    var timeout;
    $(window).resize(function() {
        clearTimeout(timeout);
        timeout = setTimeout(function () {
            var winW = $(window).width();
            if (winW > 960 && winW < 1200) {
                $('#' + carouselID).css('left', '600px' );
                var leftValue = ((25/48) * winW - 625) + 'px';
                var backgroundAtr = 'url(http://www.placehold.it/1200x800) ' + leftValue + ' top no-repeat';
                $('#' + carouselID + ' .slides .slide').css('background', backgroundAtr );
            } else if (winW <= 960) {
                $('#' + carouselID).css('left', '600px' );
                var leftValue = '-125px';
                var backgroundAtr = 'url(http://www.placehold.it/1200x800) ' + leftValue + ' top no-repeat';
                $('#' + carouselID + ' .slides .slide').css('background', backgroundAtr );
            } else if (winW >= 1200) {
                $('#' + carouselID).css('left', '50%' );
                var leftValue = 'left';
                var backgroundAtr = 'url(http://www.placehold.it/1200x800) ' + leftValue + ' top no-repeat';
                $('#' + carouselID + ' .slides .slide').css('background', backgroundAtr );
            }
        }, 10);
    });
    

    This will first clear a timeout, if there is one. Then it will set your resize code to execute in 10ms time. This should give the browser enough time to catch its breath, and stop firing multiple resize events – its basically a debounce function.

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

Sidebar

Related Questions

I am currently developing a site and have a need for a javascript-based carousel/slider
I have a modal containing a carousel with 2 slides with login and signup
I have a JQuery carousel which I have adapted for my needs. I need
I have multiple text based links i would like to connect into the carousel,
I need to tweak a jQuery carousel I have made using the excellent cycle
I have the cycle pulgin work on a page with a carousel. I need
i have an image carousel written in jquery. now i need to be able
I need to create a jQuery based carousel. On hovering over a carousel item
Ok, so I have a carousel that animates left and right. There is the
I have implemented the carousel on my webpage as follows <div class=container-fluid> <div id=myCarousel

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.