Draggable 在 <div> Firefox 中发布后不会恢复到原来的大小



拿这个可拖动的。在Chrome中发布(+鼠标移动)后,它会恢复到原来的大小,但在Firefox中不会这样做。

<div id="container">
    <div class="drag"></div>
</div>

$(".drag").draggable({
    revert: true,
    containment: "#container"
});
.drag:hover {
width: 100px;
height: 90px;
margin-left: -5px;
margin-top: -7px;
line-height: 62px;
}
.drag {
    position: absolute;
    display: block;
    border: 1px solid black;
    width: 60px;
    height: 50px;
    float:left;
    margin: 5px;
    padding:0;
    padding-top: 5px;
    cursor: hand;
    cursor: pointer;
    border-radius: 51%;
    top: 40px;
    left: 100px;
    background-color: lightblue;
}
div#container {
    width: 100%;
    height: 700px;
    margin: 0;
    padding: 5px;
    position: relative;
}

为什么Firefox会有这样的行为,有什么可能的解决方案吗?

JSFiddle

适用于jQuery UI 1.9.2。在Firefox上。这将使您能够更好地控制draggable的行为

$(".drag").draggable({
    addClasses: false,
    revert: function (valid) {
        if (valid) {
            //Dropped in a valid location
        } else {
            //Dropped in an invalid location
        }
        return valid;
    },
    containment: "#container"
});

Wokring小提琴:http://jsfiddle.net/urahara/wtLx524g/1/

最新更新