Calculate offset in calcOffset to avoid zooming error