Skip to content

Commit 7561f25

Browse files
committed
Feedback
1 parent 2875785 commit 7561f25

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/Components/Web.JS/src/Virtualize.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ function init(dotNetHelper: DotNet.DotNetObject, spacerBefore: HTMLElement, spac
9494
// scrolling glitches.
9595
rangeBetweenSpacers.setStartAfter(spacerBefore);
9696
rangeBetweenSpacers.setEndBefore(spacerAfter);
97-
const rangeRect = rangeBetweenSpacers.getBoundingClientRect();
98-
const spacerSeparation = rangeRect.height;
97+
const spacerSeparation = rangeBetweenSpacers.getBoundingClientRect().height;
9998
const containerSize = entry.rootBounds?.height;
10099

101100
// Accumulate scale factors from all parent elements as they multiply together
@@ -107,7 +106,7 @@ function init(dotNetHelper: DotNet.DotNetObject, spacerBefore: HTMLElement, spac
107106
const computedStyle = getComputedStyle(element);
108107

109108
// Check for zoom property (applies uniform scaling)
110-
if (computedStyle.zoom && computedStyle.zoom !== 'normal' && computedStyle.zoom !== '1') {
109+
if (computedStyle.zoom && computedStyle.zoom !== '1') {
111110
scaleFactor *= parseFloat(computedStyle.zoom);
112111
}
113112

@@ -121,12 +120,10 @@ function init(dotNetHelper: DotNet.DotNetObject, spacerBefore: HTMLElement, spac
121120

122121
// Check for transform property (matrix form)
123122
if (computedStyle.transform && computedStyle.transform !== 'none') {
124-
// A 2D transform matrix has 6 values: matrix(scaleX, skewY, skewX, scaleY, translateX, translateY)
125-
const match = computedStyle.transform.match(/matrix\([^,]+,\s*[^,]+,\s*[^,]+,\s*([^,]+)/);
126-
if (match) {
127-
const scaleY = parseFloat(match[1]);
128-
scaleFactor *= scaleY;
129-
}
123+
// Parse the transform matrix using DOMMatrix to extract scaleY
124+
const matrix = new DOMMatrix(computedStyle.transform);
125+
// For vertical scrolling, we only need the Y-axis scale factor (d/m22)
126+
scaleFactor *= matrix.d;
130127
}
131128
element = element.parentElement;
132129
}

src/Components/test/testassets/BasicTestApp/VirtualizationScale.razor

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
<div id="virtualize" style="height: 200px; overflow: auto">
2-
<Virtualize ItemsProvider="@itemsProvider">
3-
<tr class="person"><span>@context.Name</span></tr>
4-
</Virtualize>
1+
<div style="scale: @ScaleX @ScaleY; transform-origin: top left;">
2+
<div id="virtualize" style="height: 200px; overflow: auto">
3+
<Virtualize ItemsProvider="@itemsProvider">
4+
<tr class="person"><span>@context.Name</span></tr>
5+
</Virtualize>
6+
</div>
57
</div>
68

9+
<input type="number" @bind="ScaleX" />
10+
<input type="number" @bind="ScaleY" />
11+
712
@code {
813
internal class Person
914
{
1015
public int Id { get; set; }
1116
public string Name { get; set; } = string.Empty;
1217
}
1318

19+
public double ScaleX { get; set; } = 1.0;
20+
public double ScaleY { get; set; } = 1.0;
21+
1422
private ItemsProviderDelegate<Person> itemsProvider = default!;
1523

1624
protected override void OnInitialized()
@@ -24,10 +32,3 @@
2432
};
2533
}
2634
}
27-
28-
<style>
29-
body {
30-
scale: 2 0.5;
31-
transform-origin: top left;
32-
}
33-
</style>

0 commit comments

Comments
 (0)