Looking for a shareable component template? Go here --> sveltejs/component-template
This is a project that detects if rectangles intersects each other by calculating each line segment of rectangles
You can use also function called [getSnapped()] in order to snap rectangles each other when they come close enough.
First select target rectangle by clicking on it, and then drag any other rectangle onto target rectangle