, 당신은 사각형 테두리를 명중하기 전에 사용자에게 통지하지 않습니다 싶어? 이 사례에 드래그 이벤트를 사용하고이 이벤트의 위치를 식별 할 수 있습니다.
문서 : http://api.jqueryui.com/draggable/#event-drag
여기
인 JsFiddle : https://jsfiddle.net/yusrilmaulidanraji/uf44m36j/2/
$('.dragme').draggable({
containment: ".drag-parent",
drag: function(event, ui) {
\t if (ui.position.top == 1) {
//tell user the box almost hits the top
}
if (ui.position.left == 1) {
//tell user the box almost hits the left
}
}
});
.dragme {
border-radius: 0.5em;
width: 12em;
height: 8em;
padding: 1em;
font-family: "Montserrat", "Arial";
background-color: #00C5CD;
color: white;
}
.drag-parent {
border: 0.1em solid #BA064E;
width: 45em;
height: 20em;
}
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link href="//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet"/>
<div class="drag-parent">
<div class="dragme">Drag me!</div>
</div>
당신이 요소에의 오프셋 (offset) 발견'.drag' 이벤트와 함수를 작성해야 그것의 부모. – ntgCleaner
'stop' 이벤트가 발생하면 부모와 교차하는지 확인해야합니다. 'position' 속성이 도움이 될 수 있습니다. https://jsfiddle.net/d345k0/phfyqp4j/ – d345k0
샘플을 보내 주시겠습니까 – Parker