Skip to content

Commit 8ddccd4

Browse files
committed
Merge Postpone quant rounding to use-site to avoid big size jumps due to rounded quant (mr-838)
7fe2e5b - fix(ext/cfx-ui): postpone quant rounding to use-site to avoid big size jumps due to rounded quant
2 parents af87aa8 + 7fe2e5b commit 8ddccd4

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

ext/cfx-ui/src/cfx/apps/mpMenu/services/ui/ui.mpMenu.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,20 @@ class MpMenuUiService implements IUiService {
4848
const meterNode = document.createElement('div');
4949
meterNode.style.width = 'var(--width)';
5050
meterNode.style.height = 'var(--height)';
51+
meterNode.style.position = 'fixed';
52+
meterNode.style.top = '0';
53+
meterNode.style.left = '0';
54+
meterNode.style.pointerEvents = 'none';
55+
meterNode.style.opacity = '0';
56+
meterNode.style.transform = 'translate(-100%, -100%)';
57+
document.body.appendChild(meterNode);
5158

5259
function calculateDimensions(bodyRect: DOMRect) {
5360
const style = getComputedStyle(meterNode);
5461

5562
const viewportWidth = parseFloat(style.getPropertyValue('width')) || bodyRect.width;
5663
const viewportHeight = parseFloat(style.getPropertyValue('height')) || bodyRect.height;
57-
// eslint-disable-next-line no-bitwise
58-
const quant = viewportHeight * 0.0055 | 0; // prevent subpixeling
64+
const quant = viewportHeight * 0.0055;
5965

6066
return {
6167
viewportWidth,

ext/cfx-ui/src/cfx/common/pages/ServersPage/ServersPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const ServersPage = observer(function ServersPage(props: ServersPageProps
7272
initialScrollOffset={initialScrollOffset}
7373
className={s.list}
7474
itemCount={list.sequence.length}
75-
itemHeight={UiService.quant * 9}
75+
itemHeight={Math.ceil(UiService.quant * 9)} // Ceil to avoid gaps between rows
7676
renderItem={renderItem}
7777
/>
7878
)}

ext/cfx-ui/src/cfx/common/parts/Server/ServerFilters/ServerFilters.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ const FiltersPopover = observer(function FiltersPopover(props: ServerFiltersProp
196196

197197
<VirtualScrollable
198198
itemCount={localesList.length}
199-
itemHeight={UiService.quant * 6}
199+
itemHeight={Math.ceil(UiService.quant * 6)}
200200
renderItem={(index) => (
201201
<LocaleFaucet config={config} locale={locales[localesList[index]]} />
202202
)}
@@ -222,7 +222,7 @@ const FiltersPopover = observer(function FiltersPopover(props: ServerFiltersProp
222222

223223
<VirtualScrollable
224224
itemCount={tagsList.length}
225-
itemHeight={UiService.quant * 6}
225+
itemHeight={Math.ceil(UiService.quant * 6)}
226226
renderItem={(index) => (
227227
<TagFaucet config={config} tag={tagsList[index]} count={tags[tagsList[index]].count} />
228228
)}

0 commit comments

Comments
 (0)