Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS animation delay from # of children
    text
    copied!<p>I'm trying to write a java script that offsets the start and loop delays of CSS animations. the offset should be based off of the number of images in the containing div. I'm not very experienced with javascript so any help would be appreciated.</p> <p>JavaScript:</p> <pre><code>function bannersImgOffset(){ var photoBanners = document.getElementsByClassName("photoBanner"); for(var i=0; i &lt; photoBanners.length; i++){ var bannerChildren = i.getChildNodes; var loopDelay = bannerChildren.length*5; for(i=0, i&gt;bannerChildren.length, i++){ var imageDelay = (i*5); i.style.webkitanimation = "bannerCycle 5s linear infinite " + loopDelay + "s"; i.style.mozanimation = "bannerCycle 5s linear infinite " + loopDelay + "s"; i.style.msanimation = "bannerCycle 5s linear infinite " + loopDelay + "s"; i.style.oanimation = "bannerCycle 5s linear infinite " + loopDelay + "s"; i.style.animation = "bannerCycle 5s linear infinite " + loopDelay + "s"; i.style.webkitanimationDelay = imageDelay + "s"; i.style.mozanimationDelay = imageDelay + "s"; i.style.msanimationDelay = imageDelay + "s"; i.style.oanimationDelay = imageDelay + "s"; i.style.animationDelay = imageDelay + "s"; } } } </code></pre> <p>html:</p> <pre><code> &lt;div class="photoBanner"&gt; &lt;img src="Image01.jpg" alt=""&gt; &lt;img src="Image02.jpg" alt=""&gt; &lt;img src="Image03.jpg" alt=""&gt; &lt;img src="Image04.jpg" alt=""&gt; &lt;img src="Image05.jpg" alt=""&gt; &lt;/div&gt; </code></pre> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload