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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:39:13+00:00 2026-05-21T08:39:13+00:00

jQuery UI Draggable offers a grid option which, when set, will snap your draggable

  • 0

jQuery UI Draggable offers a grid option which, when set, will snap your draggable element to a grid. The only problem I’m having with this is I still want it to animate before snapping.

If my grid is [500,500] then there will be no user feedback until the mouse covers a distance of 500px.

Is it possible to do a similar “snap to grid” thing but also animate at the same time?

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

    I presume you mean you want to snap to a grid after the user has finished dragging. In this case, you can make use of the draggable’s stop event and calculate the element’s offset.

    Assume you have a draggable contained within a parent element, starting at offset (0, 0), which is the top-left hand corner. You then apply a regular draggable effect to the element, and on stop you calculate its position and snap it to the nearest “cell”.

    The code for this would look something like:

    $(el).draggable({
      stop: function(e, ui) {
        var elem = ui.helper,
            left = elem.position().left,
            top  = elem.position().top;
    
        elem.css({
          left: left - (left%10),
          top: top - (top%10)
        });
      }
    });
    

    This code will always snap based on the element’s top-left pixel co-ordinate, and relies on the element being absolutely positioned and the parent being non-statically positioned (relative, absolute, etc.)

    ** Edit **

    I have created a quick demo – http://jsfiddle.net/LQwMe/1/

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

Sidebar

Related Questions

problem with passing variables (php, sql, jquery draggable) Hi, this is my problem: updating
i make a class of elements draggable like this jQuery(.drag).draggable(); jQuery(.drop).droppable({ accept: .drag, drop:
How do I make an element, e.g. a div, draggable using jQuery?
I have the following jQuery: $(document).ready(function () { $(.element).draggable(); $(.element).droppable({ drop: function () {
I'm creating a custom drag helper (in jQuery): $('.dragme', element).draggable({ appendTo: 'body', helper :
I have binded jquery events set for mouseenter mouseleave, as well as jquery draggable.
I'm trying to add a draggable element to my page, using the draggable jquery
If I left-click on a jquery draggable element, the mousedown event never reaches my
I am having an issue related jQuery draggable and droppable. Here is description something
I have two li elements which are jQuery draggable. When I drag and drop

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.