mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
refactor: centralize styling system usage
This commit is contained in:
1 parent
0df93ba204
commit
92794d47dc
15 files changed
+395
-80
No files matched your search
+12
-1
@@ -1,5 +1,12 @@
|
||||
// js/utils/mediaLoader.js
|
||||
|
||||
import { applyDynamicStyles } from "../ui/styleSystem.js";
|
||||
|
||||
function createBackgroundImageValue(src) {
|
||||
const safe = String(src).replace(/["\\)\n\r]/g, (match) => `\\${match}`);
|
||||
return `url("${safe}")`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple IntersectionObserver-based lazy loader for images (or videos).
|
||||
*
|
||||
@@ -46,7 +53,11 @@ export class MediaLoader {
|
||||
el.poster = fallbackSrc;
|
||||
}
|
||||
} else {
|
||||
el.style.backgroundImage = `url('${lazySrc}')`;
|
||||
applyDynamicStyles(
|
||||
el,
|
||||
{ backgroundImage: createBackgroundImageValue(lazySrc) },
|
||||
{ slot: "lazy-background" },
|
||||
);
|
||||
}
|
||||
|
||||
delete el.dataset.lazy;
|
||||
|
||||
Reference in new issue
Block a user