Skip to content

Commit 89da1e1

Browse files
authored
Merge pull request #17 from JadenTepper/scroll-fix
Mac Safari bad initial scaling fix and a scrolling fix
2 parents 1c29412 + f3675e1 commit 89da1e1

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/routes/+layout.svelte

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@
7171
name: 'padding',
7272
unit: 'px'
7373
},
74-
fontSize: {
75-
name: 'font-size',
76-
unit: 'rem'
77-
},
7874
fontWeight: {
7975
name: 'font-weight',
8076
unit: ''
@@ -129,6 +125,18 @@
129125
}
130126
})
131127
);
128+
onDestroy(
129+
settings.subscribe(['fontSize'], function (_key: string) {
130+
const remFontSize = settings.data.fontSize.value as number;
131+
132+
const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
133+
const pixelValue = remFontSize * rootFontSize;
134+
const roundedPixelValue = Math.round(pixelValue); // Round to nearest px
135+
const roundedRemFontSize = roundedPixelValue / rootFontSize;
136+
137+
document.body.style.setProperty('--font-size', roundedRemFontSize + "rem");
138+
})
139+
)
132140
onDestroy(
133141
settings.subscribe(Object.keys(cssVarIndex), function (key: string) {
134142
const name = cssVarIndex[key].name;

src/routes/app/+page.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@
276276
}
277277
}
278278
279+
function fixScroll(event: Event) {
280+
const el = event.currentTarget as HTMLDivElement;
281+
if (el.scrollTop !== 0) {
282+
el.scrollTop = 0;
283+
}
284+
}
285+
279286
// TODO:
280287
// add custom background color
281288
// add command K
@@ -350,7 +357,7 @@
350357
<div class="box-control">
351358
<BoxControl flowId={$selectedFlowId} />
352359
</div>
353-
<div class="flow" class:customScrollbar={settings.data.customScrollbar.value}>
360+
<div class="flow" class:customScrollbar={settings.data.customScrollbar.value} on:scroll={fixScroll}>
354361
<Flow on:focusFlow={focusFlow} flowId={$selectedFlowId} />
355362
</div>
356363
{/key}

0 commit comments

Comments
 (0)