Merge branch 'main' into 物品系统

This commit is contained in:
MuHua-123
2025-09-22 14:29:55 +08:00
3 changed files with 20 additions and 7 deletions
@@ -71,9 +71,16 @@ namespace MuHua {
} }
/// <summary> 视图滚轮滑动 </summary> /// <summary> 视图滚轮滑动 </summary>
private void ViewportWheel(WheelEvent evt) { private void ViewportWheel(WheelEvent evt) {
float x = Mathf.Clamp(evt.delta.x, -1, 1); float maxWidth = Viewport.resolvedStyle.width - Container.resolvedStyle.width;
float y = Mathf.Clamp(evt.delta.y, -1, 1); float minWidth = Mathf.Min(Viewport.resolvedStyle.width, Container.resolvedStyle.width);
UpdateValue(new Vector2(value.x - x, value.y - y)); float x = evt.delta.x * minWidth / maxWidth;
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;
value = value - new Vector2(x, y);
UpdateValue(value);
} }
/// <summary> 拖拽按下 </summary> /// <summary> 拖拽按下 </summary>
private void DraggerDown(PointerDownEvent evt) { private void DraggerDown(PointerDownEvent evt) {
@@ -76,8 +76,11 @@ namespace MuHua {
} }
/// <summary> 滚轮滑动 </summary> /// <summary> 滚轮滑动 </summary>
private void ViewportWheel(WheelEvent evt) { private void ViewportWheel(WheelEvent evt) {
float wheel = Mathf.Clamp(evt.delta.y, -1, 1); float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
UpdateValue(value - wheel); float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
float y = evt.delta.y * minHeight / maxHeight;
value = value - y;
UpdateValue(value);
} }
/// <summary> 拖拽按下 </summary> /// <summary> 拖拽按下 </summary>
private void DraggerDown(PointerDownEvent evt) { private void DraggerDown(PointerDownEvent evt) {
@@ -76,8 +76,11 @@ namespace MuHua {
} }
/// <summary> 滚轮滑动 </summary> /// <summary> 滚轮滑动 </summary>
private void ViewportWheel(WheelEvent evt) { private void ViewportWheel(WheelEvent evt) {
float wheel = Mathf.Clamp(evt.delta.y, -1, 1); float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
UpdateValue(value - wheel); float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
float y = evt.delta.y * minHeight / maxHeight;
value = value - y;
UpdateValue(value);
} }
/// <summary> 拖拽按下 </summary> /// <summary> 拖拽按下 </summary>
private void DraggerDown(PointerDownEvent evt) { private void DraggerDown(PointerDownEvent evt) {