uis icon indicating copy to clipboard operation
uis copied to clipboard

No Item reload when using Mouse wheel

Open WorldpixelSoftware opened this issue 3 years ago • 2 comments

Hey,

I like the script so far and would like to use it, but within the Demo and my own project, when I use the scroll wheel to scroll the list of items, no new items are loaded and hence displayed in the scrollview. It only works for dragging the view up and down but not when using the Mouse scroll wheel or dragging the scrollbar.

I tried to load 100 items but after Item 8, no new is added and I can only scroll blank space.

If further information is needed, just let me know.

WorldpixelSoftware avatar Apr 08 '21 12:04 WorldpixelSoftware

It's because ScrollRect is updating by using velocity from component. Mouse wheel doesn't change this value. You can do a small workaround: compare the anchored position of content transform between previous frame and the current one. If these values are not the same, don't return from UpdateVertical or UpdateHorizontal.

More specifically, for example, for vertical scrolling, just change line 356 from:

if (position < 0 || _previousPosition == position || _scroll.velocity.y == 0f) {
    return;
}

... to something like this:

if (position < 0 || _previousPosition == position ||
    Mathf.Abs(_currentScrollValue.y - _previousScrollValue.y) < float.Epsilon) {
    return;
}

It's not really good solution due to high possible speed lag, but better than nothing. 😃

CheeryLee avatar Apr 08 '21 14:04 CheeryLee

Ok I'll see. Thank you.

WorldpixelSoftware avatar Apr 09 '21 12:04 WorldpixelSoftware