Animate from current position to center of screen

Is there any way to animate a UI element zooming in from its position to the center of the screen? The position may vary so I’m not sure how to do this. I read about the LateUpdate() trick but I don’t think it’ll work for this.

This is untested code:

Vector3 startPos;
Vector3 endPos;

float startScale = 0; // change these as you like
float endScale = 1;

float scaleDuration = 1; // seconds

float interp; // short for interpolation - look it up if you aren't familiar, it's one of the most useful math tricks in programming

void Start()
{
    startPos = transform.position;
    endPos = new Vector3(0, 0, 0); // or wherever you want it
    interp = 0;
}

void Update()
{
    if (interp < 1)
    {
        interp += Time.deltaTime / duration;
        if (interp > 1) interp = 1;
    }
    transform.position = startPos * (1 - interp) + endPos * interp;
    transform.localScale = new Vector3(1, 1, 1) * (startScale * (1 - interp) + endScale * interp);
}