-2

I tried to replicate this effect but it snaps when you scroll up fast.

codesandox. How to make it pleasing on the eyes?

Suhas Rao
  • 67
  • 7
  • 1
    [Something in my web site or project doesn't work. Can I just paste a link to it?](https://meta.stackoverflow.com/q/254428/1427878) – CBroe Apr 18 '23 at 12:25

1 Answers1

0

Well figured it out. Had to limit the width the img element was getting. console.log() showed width was reaching infinity because of scrolling which thereby put a delay on the return animation.

const maxWidth = 700. // actual maximum width of the image. 

img.style.width = `${width <= maxWidth ? width : maxWidth}px`;
Suhas Rao
  • 67
  • 7