Post

What if... it wasn't a mistake? 😅 If it animated like that on purpose? IME these types of non-straightforward transitions generate more "delight" - even though it's wrong!

...and after re-reading your article one more time, I think I found the culprit: my `translate` property depends on both (animated) custom properties: `--pan-x` and `--scale`. Hence the non-linearity :-(

...which is unfortunate. Apparently the right way is to trigger the change by setting the final value for my custom properties and transition the (computed) transform/scale values. But I need to trigger the action via the JS Animations API.

Bringing the tapped subject into the centre & zooming in means the transform-origin is different to the tapped area. E.g. the case in the article, the transform-origin isn't within the cat's head. You could work it out I guess, but that maths seems harder.

Also, if you wanted to handle an additional zoom to another position, I guess you'd need to animate the transform-origin? I haven't tried it, but I wonder if that would also produce a non-linear animation.

If you tap/ click something in the image, the scale would bring that point dead in the middle. The necessary transform-origin is computed from the position of the tapped point and the scale. Moving another point in the middle by changing the transform-origin wouldn't have the same issue.