fixes #8568 -- account for margins in offset