I've been working on a code to dynamically resize multiple divs. The original code only resized one element, but I modified it to handle multiple div resizers.
However, I'm facing an issue where there is a gap between the mouse and the div while resizing. My goal is to ensure each element is resized in relation to the exact mouse location relative to its parent position. I welcome any new approach that can change my perspective on this matter. It's not necessary to use the resize nodes; directly manipulating the div borders is also an option.
What I've accomplished so far:
- Made multiple divs resizable based on mouse location.
- Stored initial location information in a function.
- Calculated the difference between child and parent elements.
What I aim to achieve:
- Ensure that the div stays under the mouse location without any space between them during resizing.
After several attempts at resizing, I noticed a gap caused by margins and paddings of parent elements, resulting in resizing with a gap between the div and the mouse. A recursive solution is needed to accurately resize and reposition the divs. Another approach might involve calculating only x, y, w, h values inside the parent, but I need guidance on how to implement this effectively using the mouse...
For a clearer demonstration, you can refer to the following CodePen: https://codepen.io/BerkerYuceer/pen/gOYwqdb