Add elasticity to ScrollPool, stop movement on mouse scroll or slider change

This commit is contained in:
Sinai 2021-04-22 03:57:34 +10:00
parent 31fa786574
commit fc26452f64
2 changed files with 8 additions and 1 deletions

View File

@ -752,7 +752,8 @@ namespace UnityExplorer.UI
var scrollRect = mainObj.AddComponent<ScrollRect>();
scrollRect.movementType = ScrollRect.MovementType.Clamped;
scrollRect.inertia = false;
scrollRect.inertia = true;
scrollRect.elasticity = 0.125f;
scrollRect.scrollSensitivity = 15;
scrollRect.horizontal = false;
scrollRect.vertical = true;

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Core.Input;
using UnityExplorer.UI.Models;
namespace UnityExplorer.UI.Widgets
@ -350,6 +351,9 @@ namespace UnityExplorer.UI.Widgets
if (WritingLocked)
return;
if (InputManager.MouseScrollDelta != Vector2.zero)
ScrollRect.StopMovement();
if (!SetRecycleViewBounds(true))
RefreshCells();
@ -506,6 +510,8 @@ namespace UnityExplorer.UI.Widgets
return;
this.WritingLocked = true;
ScrollRect.StopMovement();
// normalize the scroll position for the scroll bounds.
// this translates the value into saying "point at the center of the height of the viewport"
var scrollHeight = NormalizedScrollBounds.y - NormalizedScrollBounds.x;