There is a landing page. On the first block is a huge script that draws all sorts of nonsense on the canvas. Consequently, all this eats a resource and hangs on weak machines. There was a desire to stop this script when the first block of the page leaves the field of visibility. To stop it at all to draw there.
- TC, i.e. you, here you reformulated the question, but my answer is still relevant. I do not know what to add there. If you need something more, then give this huge script here, we'll stop it for you. Or try it yourself, where to start, I wrote (look at the requestAnimationFrame in it - this should be the main animation loop, but not necessarily, there are other options. - Darth
- Thanks for the answer. I reformulated so that it did not seem that I ask 2 different questions. Now I dig in the direction of your tips. - Dmitry N
|
1 answer
document.body.onscroll=function(){ if( document.body.scrollTop > header.offsetTop+header.offsetHeight ) $.animation.stop(); else $.animation.sdelat_zbs(); } - What is your evidence? :) - tutankhamun
- What is the question is the answer .. - Darth
- Press f12, replace $ .animation.stop () with alert ('stop') and drive on the stackoverflow header, it works for me - Darth
- Not an argument. If the question is not clear, it is worth asking clarifying questions. In the current edition is better. At least the main idea is visible - tutankhamun
- Well, yes, I forgot to translate into js "when scrolling" in the first version - Darth
|