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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:57:07+00:00 2026-05-15T13:57:07+00:00

I want to enable drag-and-drop behaviour on my Web application. I have an image

  • 0

I want to enable drag-and-drop behaviour on my Web application. I have an image I want to drag. The image is behind another one that has transparent sections so that you can see the image beneath it. I do not want to change the order of the images. My thinking is I should use another layer on top of both images that is transparent and use it as a proxy to transfer events to the image I want to drag. jQuery UI’s draggable function will not allow me to transfer the events in real-time i.e. I cannot hook into what it is doing while the drag is taking place, only when it is completed.

Is there a JavaScript library or jQuery plugin that will allow me to enable drag-and-drop on an element and have it transfer those events to another element in real-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-15T13:57:08+00:00Added an answer on May 15, 2026 at 1:57 pm

    Maybe I don’t understand what you are trying to accomplish, but you should be able to drag and drop overlapping images without any trouble (demo).

    Just wrap both images in a div and then make the div draggable:

    CSS (no need to make .dragme position relative, because it is done in the draggable script)

    .dragme img {
     position: absolute;
     top: 0;
     left: 0;
    }
    

    HTML

    <div class="dragme">
     <img src="image1.gif">
     <img src="image2.gif">
    </div>
    

    Script

    $(".dragme").draggable();
    

    I updated the demo, this isn’t pretty and there might be a better way, but basically this puts an invisible overlay over the frame, then positions the image while the overlay is being dragged.

    CSS

    #draggable, #droppable {
     width: 450px;
     height: 250px;
     padding: 0.5em;
     margin: 10px;
     background: #ddd;
     color:#000;
    }
    .dragme {
     position: relative;
     width: 100px;
     padding: 5px;
    }
    .dragme img {
     position: absolute;
     top: 55px;
     left: 30px;
    }
    .demo {
     width: 500px;
    }
    .border {
     position: absolute;
     top: 75px;
     left: 30px;
     z-index: 1;
    }
    

    HTML

    <div class="demo">
     <div class="border">
      <img src="http://www.imageuploading.net/image/thumbs/large/border-564.png">
     </div>
     <div id="draggable" class="ui-widget-content">
      <p>Drag from here</p>   
      <div class="dragme">
       <img src="http://i142.photobucket.com/albums/r117/SaltyDonut/Icons/evilpuppy.gif">
      </div>
     </div>
     <div id="droppable">
      <p>Drop here</p>
     </div>
    </div>
    

    Script (The demo uses $(document).ready because jsFiddle doesn’t like $(window).load)

    $(window).load(function(){
     // cycle through draggable divs (in case there are more than one)
     $(".dragme").each(function(){
      var img = $(this).find('img');
      var pos = img.position();
      // create div overlay on image
      $('<div/>', {
       class : 'overlay',
       css: {
        position: 'relative',
        top: pos.top,
        left: pos.left,
        width: img.outerWidth(),
        height: img.outerHeight(),
        zIndex: 100
       }
      })
       // save original image position
       .data('pos', [pos.left, pos.top])
       .appendTo($(this));
    
      // make overlay draggable
      $(this).find('.overlay').draggable({
       containment : '.demo',
       revert: true,
       revertDuration: 0,
       handle: 'div',
       // drag overlay and image
       drag: function(e,ui){
        img = $(this).parent().find('img');
        img.css({
         top: ui.position.top,
         left: ui.position.left
        });
       },
       // make image revert
       stop: function(e,ui){
        pos = $(this).data('pos');
        $(this).parent().find('img').animate({left: pos[0], top: pos[1] },500);
       }
      });
     });
    
     $("#droppable").droppable({
      drop : function(e,ui) {
       // append entire div wrapper (.dragme)
       ui.helper.parent().appendTo($(this));
      }
     });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF 4 app which I want to enable drag and drop
I want to enable drag and drop from our windows forms based application to
I have a Flex3 project with 2 HorizontalList controls; one of which has drag
How I can enable the drag and drop event on jlabel ? I have
I have a list of li elements that I need to allow drag/drop into
I want to create one puzzle which enables user to drag and drop images
I want to enable the drag and drop feature over a JLabel by overriding
I have 2 spark lists with items, drag&drop enabled (mxml application, flash builder 4).
I want to enable all disabled commands in Emacs such as downcase-region - that
I know that when a drag/drop operation is completed, upon receiving a MouseUp or

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.