Używam jquery UI draggable, do przesuwania elemenu w obrębie pola <div>
Chodzi mi o to w jaki sposób zrobić blokadę przesuwania elementu jeśli kursor myszy znajdzie się poza wyznaczonym polem?
<link rel="stylesheet" href="css/jquery-ui.css" /> <link rel="stylesheet" href="css/style.css" />
<div class="container-border"> <div id="draggable" class="draggable ui-widget-content"></div>
$(function() {
$("#draggable").draggable({
containment: "parent",
snap: true,
grid: [10, 10]
});
});
*{
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
body{
margin:0;
padding:0;
font-family: Arial;
font-size:12px;
width:auto;
height:auto;
margin: 0 auto 0 auto;
background: #fff;
padding-top: 10px;
color:#333333;
}
h1, h2, h3, h4, h5, h6, h7, h8, form, input, textarea, select, p{
margin: 0px;
padding: 0px;
}
a{
text-decoration: none;
color: #277093;
}
/*===============================================================================
=================*/
#draggable { width: 200px; height: 30px; }
.container-border{
height: 802px;
width: 602px;
border: 1px solid red;
margin: 0 auto 0 auto;
}
.container{
height: 800px;
width: 600px;
}
.draggable{
border: 1px solid #DDDDDD;
position: absolute;
}
.box {
position: absolute;
height: 98px;
width: 98px;
background: #CCF;
border: 1px solid #AAD;
text-align: center;
font-size: 10px;
cursor: move;
}