MCPcopy
hub / github.com/spicetify/cli / applyScrollingFix

Function applyScrollingFix

jsHelper/spicetifyWrapper.js:350–381  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

348
349// Based on https://blog.aziz.tn/2025/01/spotify-fix-lagging-issue-on-scrolling.html
350function applyScrollingFix() {
351 if (!Spicetify.Platform?.version) {
352 setTimeout(applyScrollingFix, 50);
353 return;
354 }
355
356 // Run only for 1.2.56 and lower
357 const version = Spicetify.Platform.version.split(".").map((i) => Number.parseInt(i, 10));
358 if (version[1] >= 2 && version[2] >= 57) return;
359
360 const scrollableElements = Array.from(document.querySelectorAll("*")).filter((el) => {
361 if (
362 el.id === "context-menu" ||
363 el.closest("#context-menu") ||
364 el.getAttribute("role") === "dialog" ||
365 el.classList.contains("popup") ||
366 el.getAttribute("aria-haspopup") === "true"
367 )
368 return false;
369
370 const style = window.getComputedStyle(el);
371 return style.overflow === "auto" || style.overflow === "scroll" || style.overflowY === "auto" || style.overflowY === "scroll";
372 });
373
374 for (const el of scrollableElements) {
375 if (!el.hasAttribute("data-scroll-optimized")) {
376 el.style.willChange = "transform";
377 el.style.transform = "translate3d(0, 0, 0)";
378 el.setAttribute("data-scroll-optimized", "true");
379 }
380 }
381}
382
383const observer = new MutationObserver(applyScrollingFix);
384

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected