You can use the drag function that comes with jquery draggable. In the drag and drop function, you can simply check if the edges of the inner div are outside the borders of the div container.
If thay, increase the width or height of the container div.
You can use the position method, which is native in jquery ui, to check the positions of the top, bottom, left and right of both div tags.
Below are links to the api for more details on how these methods work.
Wirde source share