Two lerps in the same loop, but one takes longer, why?

I’m doing two lerps simultaneously, one for centering the camera, other for zooming, using this code:

IEnumerator centerCameraAndZoom(Vector2 source, Vector2 target, float duration, float zoomAmount) {

float t = 0;
while (t < 1) {

    // add the time
    t += Time.deltaTime / duration;

    // smooth it out (easing)
    var lerped = Mathf.SmoothStep(0.0f, 1.0f, t);

    // zoom in
    Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, zoomAmount, lerped);

    // move canvas center in the direction of the card
    canvas.GetComponent<RectTransform>().anchoredPosition = Vector2.Lerp(source, target, lerped);

    yield return null;
}

}
My problem is that, even though both are theorecitally lerping for the same speed (t is the same for both), the motion of the canvas center takes much longer, resulting on a delayed moving after zoom is done.

Any ideas on how to deal with this, while still keeping the code inside of a single loop?

The reason is because you have different sources. On the Camera orthographic size, your start point is the current size. On the position, your start point is the actual start point. So, the position is lerping. But the size actually isn’t. Each frame it will lerp a smaller and smaller amount since the gap will constantly be closing.

What you want to do is cache the orthographicSize when you start the lerp, and use that as the first argument in that line.