Move the way to calculate diff position to the margin