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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:51:46+00:00 2026-05-27T06:51:46+00:00

function scrollContent(){ var div = $(‘#scrolling-content’), ul = $(‘ul.image’), // unordered list’s left margin

  • 0
function scrollContent(){
    var div = $('#scrolling-content'),
                 ul = $('ul.image'),
                 // unordered list's left margin
                 ulPadding = 0;

    //Get menu width
    var divWidth = div.width();

    //Remove scrollbars
    div.css({overflow: 'hidden'});

    //Find last image container
    var lastLi = ul.find('li:last-child');

    //When user move mouse over menu
    div.mousemove(function(e){

    //As images are loaded ul width increases,
    //so we recalculate it each time
    var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;   
    var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
      div.scrollLeft(left);
    });     
}

This is how I scroll my image list. The problem is that #scrolling-content element’s size is dynamic. It changes on window resize. Here;

$(window).resize(function() {
        $("#scrolling-content").css("width",$(window).width() + "px");
        $("#scrolling-content").css("height",($(window).height()-400) + "px");
});

So it has to recalculate the left value when user changes windows size. How sould I change script to do that? Recalling scrollContent() function with window.resize function is a noob solution I guess. And it creates conflict for IE.

  • 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-27T06:51:46+00:00Added an answer on May 27, 2026 at 6:51 am

    You could set the width on resize and make your function call the variable like so. This method turns your function into a js object and the window update resets the width var inside that object. Course now you call the function like this: scrollContent.scroll();

    var scrollContent = {
            width: 0,
            scroll:function(){
                var div = $('#scrolling-content'),
                         ul = $('ul.image'),
                         // unordered list's left margin
                         ulPadding = 0;
    
                //Get menu width
                scrollContent.width = div.width();
    
                //Remove scrollbars
                div.css({overflow: 'hidden'});
    
                //Find last image container
                var lastLi = ul.find('li:last-child');
    
                //When user move mouse over menu
                div.mousemove(function(e){
    
                //As images are loaded ul width increases,
                //so we recalculate it each time
                var left = (e.pageX - div.offset().left) * (ulWidth-scrollContent.width) / scrollContent.width;
                  div.scrollLeft(left);
                });
            }  
        };
    
    $(window).resize(function() {
            $("#scrolling-content").css("width",$(window).width() + "px");
            $("#scrolling-content").css("height",($(window).height()-400) + "px");
            scrollContent.width = $(window).width();
    });
    

    You can also just declare a standard js var and use that to keep things simple. I just prefer working with js objects to eliminate possible var interference.

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

Sidebar

Related Questions

function manageVoting() { $(div.votemaincontainer).each(function () { // variable Declaration and intialization. var myRating =
function paintOrders(DivId) { var container = '<div>'; $.each(DivId, function () { container += 'TXT'
function formatDate (input) { var datePart = input.match(/\d+/g), year = datePart[0].substring(2), // get only
function check(id){ var _id = document.getElementById(id); url = test.php?check=1&id= + _id; } i want
function has_thumbnail_image(&$post) { $content = $post->post_content; return preg_match('/<img[^>]+src=(.*?)[^>]*>/', $content, $results); } I need a
function all_images(&$post){ $content = $post->post_content; if(preg_match_all('/<img[^>]+src=(.*?)[^>]*>/', $content, $results)){ $i = 0; $count = count($results);
function runProcess(){ var todo = items.concat(); setTimeout(function(){ process(todo.shift()); if(todo.length > 0){ setTimeout(arguments.callee, 25); }
function openFile(file, object) { var extension = file.substr( (file.lastIndexOf('.') +1) ); var fileName =
function ExChgClsName(Obj,NameA,NameB){ var Obj=document.getElementById(Obj)?document.getElementById(Obj):Obj; Obj.className=Obj.className==NameA?NameB:NameA; } <a href=javascript:showMenu(2);> i am a newbie of the
function validateRequiredFields(formid) { var inputs = document.getElementsByClassName('required'); for(i=0;i<inputs.length;i++) { var FieldID = inputs[i].id; if(

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.