Проверьте, перекрывают ли два прямоугольника холста JavaScript

// Where left, right, top and bottom are essentially edges

if (a.left >= b.right || a.top >= b.bottom || 
    a.right <= b.left || a.bottom <= b.top)
{
    // no overlap
}
else
{
    // overlap
}
Tanishq Vyas