Gowtham - 2021-11-20

Hi Team,

You guys done a awesome job. I like this plugin, but I found some margin issue when I drag the draggable element inside a containment zone with prevent collision. please help me to resolve the issue.

Here is my code

<!doctype html>
<html>
<head>
<title>jQuery UI Draggable</title>
<style type="text/css">
#d1 {
    width: 120px;
    height: 120px;
    background-color :aqua;
    padding:20px;
    float:left;
    margin:5px;
    }
#d2 {
    width: 120px;
    height: 120px;
    background-color :orange;
    padding:20px;
    float:left;
    margin:5px;
    }
#d3 {
    width: 120px;
    height: 120px;
    background-color :yellow;
    padding:20px;
    float:left;
    margin:5px;
    }
</style>


  <script src="jquery-1.8.3.min.js"></script>  
     <script src="ui/jquery.ui.core.js"></script>
     <script src="ui/jquery.ui.widget.js"></script> 
     <script src="ui/jquery.ui.mouse.js"></script> 
     <script src="ui/jquery.ui.draggable.js"></script> 
       <script src="ui/jquery.ui.droppable.js"></script>
    <script src="jquery-collision.min.js"></script> 
     <script src="jquery-ui-draggable-collision.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">

</head>
<body>
<h1>Welcome to GeeksforGeeks</h1>
<div class="container">
<div class="row">
 <div class="col-md-3">
<div style="height: 600px;background: darkgray;"> 
<p>hello</p>
</div>
</div> 
<div class="col-md-9" id="parent" style="height: 600px;
    background: darkgray;">
<div id="d1">

<p>Drag Me Anywhere</p>

</div>
<div id="d1" class="butNotHere">

<p>Drag Me Anywhere</p>

</div>
<div id="d3">

<p>Drag Me Vertically</p>

</div>
</div>
</div>
</div>
<script type="text/javascript">
$( function() {
    $("#d1").draggable({
    containment: "#parent",
     obstacle: ".butNotHere",
            preventCollision: true,

            start: function (event, ui) {
                $(this).removeClass('butNotHere');
            },
            stop: function (event, ui) {                
                $(this).addClass('butNotHere');
                }
    });

} );
$( function() {
    $("#d2").draggable({axis:"x"});
} );
$( function() {
    $("#d3").draggable({axis :"y"});
} );
</script>
</body>
</html>