I am trying to make a div both re-sizable and draggable with jquery. However the implementation seems to be pretty buggy.
I found several similar questions, but no solution.
I tried using several position
configurations and also tried the refreshPositions
option, nothing worked.
The bugs I experience:
I have minimized the example.
This is reproducible in all browsers, all though the fiddle seems to break in IE 10 and opera.
$(".child")
.draggable({
containment: "parent",
cursor: "move"
}).resizable({
handles: "s,e",
containment: "parent",
minHeight: 50,
minWidth: 50
});
See here for a full but simple example.
http://jsfiddle.net/jxY8M/
How could I fix this containment issue?
This is a problem with the UI draggable itself, the issue has already been reported here
The fixes in your case are (at least in the latest version of Chrome which I'm working on) to
padding
to the parent, demo found here
border
to the parent, demo found here
margin
to the child, demo found here
overflow:hidden
to the parent, demo found here. I have no idea why this one works, but it seems to do the job perfectlyThe 5px threshold could be only pertinent to the example, some playing might be necessary in order to get the correct value in your actual case. Some other examples I saw needed less padding or border width, I suppose it's based on how large the elements are somehow, but I'm not sure. I did test the fifth solution in their examples and it seemed to work there as well
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With