We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ebca0ff + 1e94588 commit 8d94088Copy full SHA for 8d94088
assets/js/background-blur.js
@@ -1,15 +1,10 @@
1
-function setBackgroundBlur() {
2
- const scriptElement = document.currentScript;
3
- const targetId =
4
- scriptElement && scriptElement.getAttribute("data-target-id")
5
- ? scriptElement.getAttribute("data-target-id")
6
- : (console.error("data-target-id is null"), null);
+(() => {
+ const script = document.currentScript;
+ const targetId = script?.getAttribute("data-target-id");
7
8
window.addEventListener("scroll", () => {
9
const scroll = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
10
const backgroundBlur = document.getElementById(targetId);
11
backgroundBlur.style.opacity = scroll / 300;
12
});
13
-}
14
-
15
-setBackgroundBlur();
+})();
0 commit comments