拖放无法缩放

时间:2015-07-07 09:22:00

标签: javascript jquery drag-and-drop jquery-ui-draggable html5-draggable

我的应用程序具有拖放功能。但在缩放窗口拖放不能正常工作。这是代码。

<div class="scaled">
    <div class="draggable" id="draggable"></div>
    <div class="droppable" id="droppable"></div>
</div>

CSS代码

.draggable {
    height: 50px;
    width:50px;
    background-color: yellow;
}

.droppable {
    height: 50px;
    width:50px;
    border: 1px solid;
    margin-top: 50px;
}
.scaled {
     -ms-transform: scale(0.5,0.5); /* IE 9 */
    -webkit-transform: scale(0.5,0.5); /* Safari */
    transform: scale(0.5,0.5);   
}

Jquery代码

$( "#draggable" ).draggable();
$( "#droppable" ).droppable({
    drop: function( event, ui ) {
        alert()
    }
});

JsFiddle

1 个答案:

答案 0 :(得分:0)

您可以在拖动事件中更改拖放的位置。

基于Drag n Drop not working proper on scaling the container的代码

private static readonly Dictionary<Type, object> allSets = new Dictionary<Type, object>.Add(typeof(AppLog), AppLogs);

public CustomSet<TEntity> Set<TEntity>() where TEntity : class
{
    Type key = typeof (TEntity);       

    if (allSets.ContainsKey(key))
    {
        return (CustomSet<TEntity>)allSets[key];
    }
}