tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
remove debug stuff
awarm.space
1 year ago
14cfce44
52b932bb
+1
-32
2 changed files
expand all
collapse all
unified
split
app
layout.tsx
components
InitialPageLoadProvider.tsx
+1
-17
app/layout.tsx
···
41
41
dangerouslySetInnerHTML={{
42
42
__html: `
43
43
let listener = () => {
44
44
-
console.log("firing listener", window.innerHeight, window.innerWidth)
45
44
let el = document.querySelector(":root");
46
45
el.style.setProperty("--leaflet-height-unitless", window.innerHeight)
47
46
el.style.setProperty("--leaflet-width-unitless", window.innerWidth)
48
48
-
el.style.setProperty("--test", "THIS IS A TEST")
49
47
}
50
50
-
if (document.readyState === 'complete') {
51
51
-
listener();
52
52
-
} else {
53
53
-
document.addEventListener('DOMContentLoaded', listener);
54
54
-
}
48
48
+
listener()
55
49
window.addEventListener("resize", listener)
56
56
-
const styleObserver = new MutationObserver((mutations) => {
57
57
-
const currentValue = mutations[0].target.style.getPropertyValue('--leaflet-width-unitless');
58
58
-
console.log(currentValue)
59
59
-
console.log(mutations[0].target.style.getPropertyValue('--test'));
60
60
-
});
61
61
-
62
62
-
styleObserver.observe(document.documentElement, {
63
63
-
attributes: true,
64
64
-
attributeFilter: ['style'],
65
65
-
});
66
50
`,
67
51
}}
68
52
/>
-15
components/InitialPageLoadProvider.tsx
···
5
5
export const useInitialPageLoad = create(() => false);
6
6
export function InitialPageLoad(props: { children: React.ReactNode }) {
7
7
useEffect(() => {
8
8
-
let listener = () => {
9
9
-
console.log("firing listener", window.innerHeight, window.innerWidth);
10
10
-
document.documentElement.style.setProperty(
11
11
-
"--leaflet-height-unitless",
12
12
-
window.innerHeight.toString(),
13
13
-
);
14
14
-
document.documentElement.style.setProperty(
15
15
-
"--leaflet-width-unitless",
16
16
-
window.innerWidth.toString(),
17
17
-
);
18
18
-
};
19
19
-
window.addEventListener("resize", listener);
20
20
-
return () => window.removeEventListener("resize", listener);
21
21
-
});
22
22
-
useEffect(() => {
23
8
setTimeout(() => {
24
9
useInitialPageLoad.setState(() => true);
25
10
}, 80);