修改滚动视图逻辑

This commit is contained in:
MuHua-123
2026-05-07 16:17:30 +08:00
parent 7c6acc5fa2
commit ef918588f5
2 changed files with 12 additions and 8 deletions
@@ -27,8 +27,9 @@ namespace MuHua {
FromRightToLeft = 1,
}
public float value;
public bool isDrag;
public float value;
public float rolling = 10;
public Vector3 originalPosition;
public Vector3 pointerPosition;
@@ -76,9 +77,10 @@ namespace MuHua {
}
/// <summary> 滚轮滑动 </summary>
private void ViewportWheel(WheelEvent evt) {
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
float y = evt.delta.y * minHeight / maxHeight;
// float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
// float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
// float y = evt.delta.y * minHeight / maxHeight;
float y = evt.delta.y * rolling;
value = value - y;
UpdateValue(value);
}
@@ -27,8 +27,9 @@ namespace MuHua {
FromBottomToTop = 1,
}
public float value;
public bool isDrag;
public float value;
public float rolling = 10;
public Vector3 originalPosition;
public Vector3 pointerPosition;
@@ -76,9 +77,10 @@ namespace MuHua {
}
/// <summary> 滚轮滑动 </summary>
private void ViewportWheel(WheelEvent evt) {
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
float y = evt.delta.y * minHeight / maxHeight;
// float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
// float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
// float y = evt.delta.y * minHeight / maxHeight;
float y = evt.delta.y * rolling;
value = value - y;
UpdateValue(value);
}