Fix NaN margins when calculating scroll target