[frontend/components] Use double for attachment view position calculation

This commit is contained in:
Lilian 2025-02-12 19:41:07 +01:00
parent 1701654f89
commit 5ef8e3581c
No known key found for this signature in database

View file

@ -58,8 +58,8 @@
} }
private ElementReference Scroller { get; set; } private ElementReference Scroller { get; set; }
private int ScrollWidth { get; set; } private double ScrollWidth { get; set; }
private int ScrollLeft { get; set; } private double ScrollLeft { get; set; }
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
@ -68,12 +68,10 @@
private async Task Scroll() private async Task Scroll()
{ {
// This should probably be moved to floating point. ScrollLeft = await Module.InvokeAsync<double>("getScrollLeft", Scroller);
// So the state transition happens sooner, i.e. at 2.5 vs 3?
ScrollLeft = await Module.InvokeAsync<int>("getScrollLeft", Scroller);
var fraction = ScrollWidth / _refs.Count; var fraction = ScrollWidth / _refs.Count;
var section = ScrollLeft / fraction; var section = ScrollLeft / fraction;
Focused = section; Focused = Convert.ToInt32(section); //ToInt32 rounds
} }
private async Task Next() private async Task Next()