I am trying to get these child divs to snap on all sides to the inside of the parent DIV, but they are only snapping with the top and left sides of the inner and outer div.
I think my code is similar to the test code in the jQuery docs, except that in their code the snappable items are not children of the frame whereas in my example, they are children of the div I want them to snap to.
jQuery('.outer-icon-block').draggable({ snap: ".inner-box",snapMode:"both" });
.inner-box {
}
img {
width:50px;
}
.outer-box {
background-color: green;
position: relative;
width: 100%;
height:600px;
}
#outer-box {
box-shadow: 1px 1px 3px 2px #999999;
}
#manage-preview-inner {
width: 480px;
display: block;
margin-left: auto;
margin-right: auto;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<div id="manage-preview-inner">
<div id="outer-box" class="outer-box">
<div class="inner-box">
<div class="outer-icon-block outer-block ui-draggable ui-draggable-handle">1<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Emojione_1F613.svg/512px-Emojione_1F613.svg.png" style="outline: solid 1px white;"></div>
<div class="outer-icon-block outer-block ui-draggable ui-draggable-handle" style="position: relative;">2<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Emojione_1F613.svg/512px-Emojione_1F613.svg.png" style="outline: solid 1px white;"></div>
<div class="outer-icon-block outer-block ui-draggable ui-draggable-handle" style="position: relative;">3<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Emojione_1F613.svg/512px-Emojione_1F613.svg.png" style="outline: solid 1px white"></div>
</div>
</div>
</div>