87,997
社区成员




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$(".block").draggable({helper: 'clone',revert:true});
$(".drop").droppable({
accept: ".block",
activeClass: 'droppable-active',
hoverClass: 'droppable-hover',
drop: function(ev, ui) {
$(this).append("<br>Dropped!");
}
});
});
</script>
<style>.block {
position: absolute;
top: 5px;
left: 5px;
border: 2px solid #0090DF;
background-color: #68BFEF;
width: 75px;
height: 75px;
margin: 10px;
z-index: 100;
}
.drop {
background-color: #e9b96e;
border: 3px double #c17d11;
width: 150px;
height: 70px;
margin: 10px;
position: absolute;
top: 5px;
right: 5px;
opacity: 0.7;
overflow:auto;
}
.droppable-active {
opacity: 1.0;
}
.droppable-hover {
outline: 1px dotted black;
}</style>
</head>
<body>
<script src="http://dev.jquery.com/view/tags/ui/latest/ui/ui.core.js"></script>
<script src="http://dev.jquery.com/view/tags/ui/latest/ui/ui.draggable.js"></script>
<script src="http://dev.jquery.com/view/tags/ui/latest/ui/ui.droppable.js"></script>
<div class="block">drag me!</div>
<div class="drop">drop on me!</div>
</body>
</html>
mouseStop: function(e) {
//If we are using droppables, inform the manager about the drop
var dropped = false;
if ($.ui.ddmanager && !this.options.dropBehaviour)
var dropped = $.ui.ddmanager.drop(this, e);
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true) {
//===============================下面是被修改的
if(dropped){//如果在容器上释放了鼠标则直接把动画过程去掉
this.propagate("stop", e);
this.clear();
}
else//不在容器上释放则播放动画
{
var self = this;
$(this.helper).animate(this.originalPosition, parseInt(this.options.revert, 10) || 500, function() {
self.propagate("stop", e);
self.clear();
});
}
//=================================
} else {
this.propagate("stop", e);
this.clear();
}
return false;
}