I need to prevent user to drag an image inside canvas área. I make a video to show the situation: https://youtu.be/GK5_xANTnIs
The collision is already working when angle is "% 90":
// top-left corner
if (obj.getBoundingRect().top > 0 || obj.getBoundingRect().left > 0) {
obj.top = Math.min(obj.top, obj.top - obj.getBoundingRect().top);
obj.left = Math.min(obj.left, obj.left - obj.getBoundingRect().left);
}
// bot-right corner
if (obj.getBoundingRect().top + obj.getBoundingRect().height < obj.canvas.height || obj.getBoundingRect().left + obj.getBoundingRect().width < obj.canvas.width) {
obj.top = Math.max(obj.top, obj.canvas.height - obj.getBoundingRect().height + obj.top - obj.getBoundingRect().top);
obj.left = Math.max(obj.left, obj.canvas.width - obj.getBoundingRect().width + obj.left - obj.getBoundingRect().left);
}