我在div
容器中有一個或多個可拖動的可調整大小。當我拖動它們時,它們已經捕捉到了div
的邊緣,但是當我調整它們的大小時,我也需要它們捕捉邊緣。在我發現的一個擴展中,他們只能捕捉到其他可調整大小,而不是特定的div
。這個問題有沒有擴展?jquery resizable snap to div
的另一個問題是,當我加入aspectRatio: true
我可調整大小的,我無法改變它了,當它拖向div
,當它啪的邊緣... 更新:你現在可以測試一下,看看在片段。所以我想解決這個問題,並添加可調整大小的管理單元。
一些代碼片段:
$(".resizable").resizable({
\t containment: "#pagecontainer",
aspectRatio: true,
\t /*snap: "#pagecontainer", this doesn't work */
\t handles: 'n, s, e, w, nw, ne, se, sw'
});
$(".draggable").draggable({
\t containment: "#pagecontainer",
\t snap: "#pagecontainer",
\t scroll: false
});
.resizable {
\t position: absolute;
width: 100px; height: 100px;
border: 1px solid black;
z-index: 1;
}
#pagecontainer {
\t position: relative;
\t border: 2px solid #ccc;
\t padding: 0px;
\t float: left;
\t background-color: White;
width: 500px;
height: 300px;
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<div id="pagecontainer">
<div id="photoframe1" class="draggable resizable droppable frame ui-widget-content ui-state-active">
<p></p>
</div>
</div>
如果您不提供至少一些最低限度的代碼示例,我認爲我們不能幫助您。 JsFiddle或類似的東西當然是理想的 – JHolub