mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-10-28 23:05:55 +00:00
perf: make visual effects and heroes more resilient
This commit is contained in:
1 parent
091f9043ee
commit
53a64328d7
6 files changed
+28
-7
No files matched your search
@@ -23,9 +23,18 @@ function setBackgroundBlur(targetId, scrollDivisor = 300, disableBlur = false, i
|
||||
blurElement.style.opacity = scroll / scrollDivisor;
|
||||
}
|
||||
};
|
||||
let framePending = false;
|
||||
const requestBlurUpdate = () => {
|
||||
if (framePending) return;
|
||||
framePending = true;
|
||||
window.requestAnimationFrame(() => {
|
||||
framePending = false;
|
||||
updateBlur();
|
||||
});
|
||||
};
|
||||
blurElement.setAttribute("role", "presentation");
|
||||
blurElement.setAttribute("tabindex", "-1");
|
||||
window.addEventListener("scroll", updateBlur);
|
||||
window.addEventListener("scroll", requestBlurUpdate, { passive: true });
|
||||
updateBlur();
|
||||
}
|
||||
|
||||
@@ -33,7 +42,12 @@ document.querySelectorAll("script[data-blur-id]").forEach((script) => {
|
||||
const targetId = script.getAttribute("data-blur-id");
|
||||
const scrollDivisor = Number(script.getAttribute("data-scroll-divisor") || 300);
|
||||
const isMenuBlur = targetId === "menu-blur";
|
||||
const settings = JSON.parse(localStorage.getItem("a11ySettings") || "{}");
|
||||
let settings = {};
|
||||
try {
|
||||
settings = JSON.parse(localStorage.getItem("a11ySettings") || "{}");
|
||||
} catch (_) {
|
||||
settings = {};
|
||||
}
|
||||
const disableBlur = settings.disableBlur || false;
|
||||
setBackgroundBlur(targetId, scrollDivisor, disableBlur, isMenuBlur);
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
{{ $resource := .resource }}
|
||||
{{ $spec := .spec }}
|
||||
{{ $result := $resource }}
|
||||
{{ with try ($resource.Resize $spec) }}
|
||||
{{ with .Value }}{{ $result = . }}{{ end }}
|
||||
{{ end }}
|
||||
{{ return $result }}
|
||||
@@ -42,7 +42,7 @@
|
||||
{{ $featuredURL = .RelPermalink }}
|
||||
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
|
||||
{{ $size := site.Store.Get "backgroundImageWidth" }}
|
||||
{{ $featuredURL = (.Resize $size).RelPermalink }}
|
||||
{{ $featuredURL = (partial "functions/resize.html" (dict "resource" . "spec" $size)).RelPermalink }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
{{ $featuredURL = .RelPermalink }}
|
||||
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
|
||||
{{ $size := site.Store.Get "backgroundImageWidth" }}
|
||||
{{ $featuredURL = (.Resize $size).RelPermalink }}
|
||||
{{ $featuredURL = (partial "functions/resize.html" (dict "resource" . "spec" $size)).RelPermalink }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
{{ $featuredURL = .RelPermalink }}
|
||||
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
|
||||
{{ $size := site.Store.Get "backgroundImageWidth" }}
|
||||
{{ $featuredURL = (.Resize $size).RelPermalink }}
|
||||
{{ $featuredURL = (partial "functions/resize.html" (dict "resource" . "spec" $size)).RelPermalink }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
{{ $backgroundURL = .RelPermalink }}
|
||||
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
|
||||
{{ $size := site.Store.Get "backgroundImageWidth" }}
|
||||
{{ $backgroundURL = (.Resize $size).RelPermalink }}
|
||||
{{ $backgroundURL = (partial "functions/resize.html" (dict "resource" . "spec" $size)).RelPermalink }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@@ -74,7 +74,7 @@
|
||||
{{ $featuredURL = .RelPermalink }}
|
||||
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
|
||||
{{ $size := site.Store.Get "backgroundImageWidth" }}
|
||||
{{ $featuredURL = (.Resize $size).RelPermalink }}
|
||||
{{ $featuredURL = (partial "functions/resize.html" (dict "resource" . "spec" $size)).RelPermalink }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
Reference in new issue
Block a user