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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:53:26+00:00 2026-05-26T08:53:26+00:00

I have taken a look at this jQuery: snapped scrolling – possible? and this

  • 0

I have taken a look at this jQuery: snapped scrolling – possible? and this Scrollable Panel snap to elements on Scroll. But they don’t really answer the question I have.

I have a divs that’s really wide but same height as window. It moves to the left nicely when the user scrolls. But can I get this scroller to snap when the user stops scrolling.
So the container sits 28px to the left at the beginning and I want it to snap at the start and then every 207px after that depending which snap point the user is closer to.

---------------------
|-------------------|-------------------
|                   |                   |
|                   |                   |            
|-------------------|-------------------
---------------------

At the minute I am not using jQuery for much except the width of the container.

var numOfPosts = jQuery(".blog-post").length;
var div5 = numOfPosts/5;
var gutters = Math.ceil(div5)*10;
var posts = Math.ceil(div5)*197;
var postListWidth = gutters + posts + 9;
var w = jQuery(window).width();
var h = jQuery(window).height();
    if(postListWidth<=w){
        jQuery(".post-list").width(w-28);
    }else{
        jQuery(".post-list").width(postListWidth);
     }

Does anyone know the best way to achieve this? I would prefer to know the code so if there’s a solution can you explain it? I am learning jQuery but there’s loads I don’t know about -.-
Thanks very much for any help I get.

  • 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-26T08:53:26+00:00Added an answer on May 26, 2026 at 8:53 am

    I’m hoping you mean horizontal scroll snap. From your diagramm it looks more like that’s what you mean. If that’s the case, you could do something similiar to what’s demonstrated in this jsfiddle. It uses this scrollstop event plugin to know when to animate your scroll to the nearest interval. Using this plugin code (placed after the scrollstop plugin code):

    (function($) {      
        $.fn.scrollSnap = function(snapInterval) {
            var mousedown = false;
    
            function nearestInterval(n, iv) {
                return Math.round(n / iv) * iv;
            }
    
            function snapToInterval() {
                if(mousedown) {
                    $(window).one("mouseup", snapToInterval);
                } else {
                    var $this = $(this),
                        snapLeft = nearestInterval($this.scrollLeft(), snapInterval);
    
                    $(this).animate({scrollLeft: snapLeft});
                }
            }
    
            $(window).mousedown(function() { mousedown = true });
            $(window).mouseup(function() { mousedown = false });
    
            this.each(function() {
                $(this).bind("scrollstop", snapToInterval);
            });
        }
    })(jQuery);
    

    You’ll then be able to use this on elements with scrollbars:

    $("#scrollWrapper").scrollSnap(207);
    

    For a prebuilt solution, you might want to check out jQuery Tools Scrollable.

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

Sidebar

Related Questions

I have taken a look around Stack Overflow on the topic of onblur but
I have taken an image from UIImagePickerController , but the file looks too big
I have taken the backup of mysql database but when I am trying to
Take a look at this jsfiddle . I've used the jQuery dialogs before and
So this may be a little tricky, but take a look at the div
I am trying to use JQuery to parse a sitemap.xml to look like this
take a look at this validation demo: http://jquery.bassistance.de/validate/demo/ the error messages are placed on
I have written 1-2 jquery plugins but all of them fails when i try
I have a problem with the MSDropDown plugin for jQuery. Please take a look
I have taken and essentially lightly modified a jQuery image slider to operate how

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.