jlmakes / scrollreveal

Animate elements as they scroll into view.
https://scrollrevealjs.org/
22.3k stars 2.26k forks source link

Resizing elements on page makes scrollreveal behave erratically. #539

Open QuietNoise opened 3 years ago

QuietNoise commented 3 years ago

When resizeable elements on the page resize then tags with scroll reveal that are below on the page do not reveal properly. They either reveal too late / too early (depending how the said resizeable elements resized: got smaller or got bigger) or not reveal at all (those tags which are placed on the very bottom of the page). I was hoping the ScrollReveal().sync() would fix that but no hope. Similarly destroying and rebuilding the reveals doesn't work. I believe it is a bug introduced recently because I recall it was working with sync() before on some older version.

Bug demonstration: JSBin https://jsbin.com/vilajuziji/1/edit?html,css,js,output I've found JSBin very clunky. I've created same demonstation on codepen as well just in case. https://codepen.io/RhetoricalDude/pen/KKWByoM

In the demo above you have a big blue resizeable element which gets resized when clicked. When resized you can observe that tags below demonstrate the bug as they reveal too late. In commented JS part there are 3 unsuccessful attempts to use sync() and destroy() which you can play with to see they only make things worse by making reveal stop working altogether.

Edit: This works as expected in 4.0.5. Calling ScrollReveal().sync() in 4.0.5 properly refreshes all elements controlled by scrollreveal. Sample with 4.0.5 https://codepen.io/RhetoricalDude/pen/YzZjbwG

Environment

zhaihongbin commented 2 years ago

I encountered the same situation when using nextjs client routing, but version 4.0.5 still doesn't work

huskiesdev commented 2 years ago

@jlmakes I provided 3 demos :)

kannafay commented 5 months ago

Hi there, I changed the page height and I use sync() have not triggered correctly