Skip to content

Commit c9ad8d5

Browse files
committed
Initial solution
1 parent 10972c1 commit c9ad8d5

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

src/renderer/main/MiddlePanelContainer.svelte

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@
2727
2828
let showFixedStickyContainer = false;
2929
let gridLayout;
30-
onMount(() => {
31-
function callback() {
32-
const stickyContainer = document.getElementById("sticky-container");
33-
const container = document.getElementById("container");
34-
const contRect = container.getBoundingClientRect();
35-
const stickyRect = stickyContainer.getBoundingClientRect();
36-
const threshold = -15;
37-
38-
showFixedStickyContainer = !(
39-
stickyRect.bottom <
40-
contRect.bottom + threshold
41-
);
42-
}
4330
44-
const observer = new ResizeObserver(callback).observe(gridLayout);
45-
window.addEventListener("resize", callback, true);
31+
function handleResize(e) {
32+
const stickyContainer = document.getElementById("sticky-container");
33+
const container = document.getElementById("container");
34+
const contRect = container.getBoundingClientRect();
35+
const stickyRect = stickyContainer.getBoundingClientRect();
36+
const threshold = -15;
37+
38+
showFixedStickyContainer = !(
39+
stickyRect.bottom <
40+
contRect.bottom + threshold
41+
);
42+
}
43+
44+
onMount(() => {
45+
window.addEventListener("resize", handleResize, true);
4646
});
4747
4848
let showModuleHangingDialog = false;
@@ -90,6 +90,7 @@
9090

9191
<GridLayout
9292
bind:component={gridLayout}
93+
on:resize={handleResize}
9394
class="absolute z-[0] items-center flex flex-col self-center"
9495
>
9596
<div

src/renderer/main/grid-layout/GridLayout.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<script>
2+
import { watchResize } from "svelte-watch-resize";
23
import { writable } from "svelte/store";
34
import { runtime } from "../../runtime/runtime.store.js";
45
import { appSettings } from "../../runtime/app-helper.store.js";
56
import Device from "./grid-modules/Device.svelte";
67
import { fade, fly } from "svelte/transition";
78
import { derived } from "svelte/store";
9+
import { createEventDispatcher } from "svelte";
810
911
export let component;
1012
13+
const dispatch = createEventDispatcher();
14+
1115
const devices = writable([]);
1216
let columns = 0;
1317
let rows = 0;
@@ -36,6 +40,10 @@
3640
3741
$: handleScalingChange($scalingPercent);
3842
43+
function handleResize(e) {
44+
dispatch("resize");
45+
}
46+
3947
function handleScalingChange(value) {
4048
calculateLayoutDimensions(rotation, columns, rows, value);
4149
}
@@ -141,7 +149,11 @@
141149
}
142150
</script>
143151

144-
<layout-container class="{$$props.class} " bind:this={component}>
152+
<layout-container
153+
class="{$$props.class} "
154+
bind:this={component}
155+
use:watchResize={handleResize}
156+
>
145157
<div
146158
style="width: {layoutWidth}px; height: {layoutHeight}px;"
147159
class="relative"

0 commit comments

Comments
 (0)