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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:41:25+00:00 2026-05-28T15:41:25+00:00

I have a little application where you can drag a box around in a

  • 0

I have a little application where you can drag a box around in a container, and also switch places with another one, which is buggy at the moment. They switch places like jQuery sortable, but I’m having a problem with Droppable. with the over event, it only activates once while holding down the mouse.

http://jsfiddle.net/44SAh/

This is what I have so far, try dragging a box down over another one, and then back up again, without letting go of the left mouse button. It starts to glitch. Thats because the over event only activates once per click. Is there a workaround for this, I want to be able to drag a box up and down and have the same consistency where they switch places, such as sortable. And no I can’t use sortable because the boxes have to be able to overlap to an extent, plus move around freely.

  • 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-28T15:41:27+00:00Added an answer on May 28, 2026 at 3:41 pm

    Here’s a working solution for you. Basically you cache the position when you start dragging something. Then when you are over a droppable, you swap the droppable’s position with the start position, update the draggable’s start position, and update the underlying droppable data structure to mark it as out, and correct the offset. Here’s a jsfiddle: http://jsfiddle.net/fordlover49/BwvK4/

    $(function() {
        $(".ui-widget-content").draggable({
            grid: [5, 5],
            start: function(event, ui) {
                // cache the position we were at when we started dragging.
                $(this).data("startPos", ui.position);
            },
            stack: ".ui-widget-content"
        });
    
        $(".ui-widget-content").droppable({
            tolerance: 'intersect',
            over: function(event, ui) {            
                var offset = $(ui.draggable).data("startPos");
                // update draggable's cached position to what the droppable was
                $(ui.draggable).data("startPos", {
                    top: $(this).position().top,
                    left: offset.left});
    
                // swap droppable positions with dragging's original pos.
                $(this).css("top", offset.top);
    
                // clear the over events, and update the droppable's offset.
                $(this).data("droppable").isout = 1;
                $(this).data("droppable").isover = 0;            
                $(this).data("droppable").offset = $(this).offset();
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little WinForms application with a tree view. I can drag and
I have programmed a little application in which you can register and edit your
I have written a little console application that uses s#arp. I can create an
I have a little application which uses regular expressions under VB6. It works perfectly
Hi I have created a little application to move some files around and put
I am writing a little application in android which would have a server part
Visual Studio 2010 Express, Windows Forms. Have made myself my first little application which
i have a little Application where i can choose items by pressing ^, 1,
I have a little PHP application in which I am attempting to display Google
I have little problem in my iPhone application code but can not identify. please

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.