javascript - WOW.js start animation when element is 60% in screen -
using wow.js, possible start animation when x% of element visible rather using offset value?
for example have element width , height of 300px, , if set x% 50% animation start when user has scrolled enough 150px of element on screen.
i looked on source code of wow.js , doesn't there's way specify offset percentage rather in pixels. here's how in javascript:
window.onload = function() { var elements = document.getelementsbyclassname("offsetme50"); var i; (i = 0; < elements.length; i++) { var offset = elements[i].clientheight * .5; //.5 = 50% elements[i].setattribute("data-wow-offset", offset); } }
this code run automatically after page loaded. set class="offsetme50"
html elements want.
Comments
Post a Comment