Why is my lerp not working?

I’m trying to lerp a UI element between two locations. I also tried SmoothDamp.

public void Clicked()
{
    RectTransform rect = GetComponent<RectTransform>();
    if (opened)
    {
        start = transform.localPosition;
        while(currentTime <= smoothTime)
        {
            currentTime += Time.deltaTime;
            normalizedValue = currentTime / smoothTime;
            Debug.Log(normalizedValue + "opened");
            //rect.localPosition = Vector3.SmoothDamp(start, pos1, ref velocity, smoothSpeed);
            rect.anchoredPosition = Vector3.Lerp(start, pos1, normalizedValue);
        }
        currentTime = 0;
        opened = false;
    }
    else
    {
        start = transform.localPosition;
        while(currentTime <= smoothTime)
        {
            currentTime += Time.deltaTime;
            normalizedValue = currentTime / smoothTime;
            Debug.Log(normalizedValue + "closed");
            //rect.localPosition = Vector3.SmoothDamp(start, pos2, ref velocity, smoothSpeed);
            rect.anchoredPosition = Vector3.Lerp(start, pos2, normalizedValue);
        }
        currentTime = 0;
        opened = true;
    }
}

That’s going to do the whole movement in one go. You need to start by converting it to a coroutine and yielding after each incremental move.

If you don’t know what I mean by that, I would suggest searching this site for something like “moving using coroutine”