在Firefox </div>中发布后,Draggable <div>不会恢复到原始大小

时间:2015-03-20 16:35:43

标签: javascript jquery html css jquery-ui

采取这种拖延。它在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

1 个答案:

答案 0 :(得分:0)

适用于jQuery UI 1.9.2。在Firefox上。这样您就可以更好地控制draggable behaiour。

$(".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/