Stefanowitsch Posted August 16 Share Posted August 16 Hi @bernhard! I noticed that the Scrollclass Feature has stopped working in RockFrontend (I am on version 3.19.0) https://www.baumrock.com/en/processwire/modules/rockfrontend/docs/javascript/ See line 258 of RockFrontend.js, the variable declaration for "j" is missing here: for (j = 0; j < attrs.length; j++) { This same goes for line 264: scrollpos = window.scrollY; Here is the updated snipped that will work: /** * Add/remove class on scroll position * * Usage: * <a href='#' rf-scrollclass='show@300'>Add class "show" at 300px scrollposition</a> * * Add multiple classes (thx @StefanThumann) * <a href='#' rf-scrollclass='show@300 show2@600'>Add class "show" at 300px scrollposition, "show2" at 600px</a> */ (function () { let scrollElements = document.querySelectorAll("[rf-scrollclass]"); for (let i = 0; i < scrollElements.length; i++) { let el = scrollElements[i]; let attrs = el.getAttribute("rf-scrollclass").split(" "); for (let j = 0; j < attrs.length; j++) { let parts = attrs[j].split("@"); if (parts.length != 2) return; let cls = parts[0]; let y = parts[1] * 1; window.addEventListener("scroll", function () { let scrollpos = window.scrollY; if (scrollpos >= y) el.classList.add(cls); else el.classList.remove(cls); }); } } })(); 1 Link to comment Share on other sites More sharing options...
bernhard Posted August 20 Share Posted August 20 Thx, I've added your suggested fix! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now