if (map_coords.y > middle_bg_coords.y) { dragObject.style.top = 0; } if (map_coords.x > middle_bg_coords.x) { dragObject.style.left = 0; } return false; }