Spring animation on html canvas

I have been trying to figure out how he made this spring animation where the spring does not redraw different waves on drag but simply expand the whole spring when you drag the weight without losing the structure of the original sine waves.

I tried but the waves get different


I see that he might be using https://react-spring.io/ But I want to create it without that framework

Oh! This is a great topic to dive deeper into. I think a library like react spring may be your best bet. Otherwise, you will have to manually take what is provided in basic form here and adapt it for your own needs: Introduction to Easing in JavaScript | KIRUPA