optimize the horizontalOffset and ScaleValue calculate