css - Heavy Javascript Lag with Sticky Divs (VanillaJS) -
i've been trying implement sticky div solution in replacement of fixed elements. because of theoretically better support system reduced window size on desktop browsers... (i.e. horizontal scrolling compatibility).
i've been implementing code below, , works flawlessly in firefox. however, in internet explorer, entire script lags , page becomes extremely jumpy.. since i'm overlaying bunch of divs, creates bit of mess in terms of presentation. there way speed script point run nicely in internet explorer , other untested browsers?
window.onload = (function() { var oa_sticky = document.getelementsbyclassname('sticky_div'); var oia_sticky_offsets_temp = new array(); (i = 0; < oa_sticky.length; i++) { oia_sticky_offsets_temp.push(new array(oa_sticky[i], (oa_sticky[i].offsettop))); } var oia_sticky_offsets = oia_sticky_offsets_temp; stick_div(oia_sticky_offsets); window.onscroll = function() { stick_div(oia_sticky_offsets); } }); function stick_div(oia_sticky_offsets) { var doc = document.documentelement; (i = 0; < oia_sticky_offsets.length; i++) { oia_sticky_offsets[i][0].style.top = (doc.scrolltop + oia_sticky_offsets[i][1]) + "px"; } } any on getting respond faster appreciated.
thanks.
Comments
Post a Comment