Fixed a typo bug with drag scrolling in scroll containers

This commit is contained in:
Nic Barker 2024-08-24 21:22:54 +12:00
parent d5cd05aedc
commit 9c5b90e71b
2 changed files with 4 additions and 3 deletions

5
clay.h
View File

@ -780,6 +780,7 @@ typedef struct
Clay_Vector2 pointerOrigin;
Clay_Vector2 scrollMomentum;
Clay_Vector2 scrollPosition;
Clay_Vector2 previousDelta;
float momentumTime;
uint32_t elementId;
bool openThisFrame;
@ -2229,9 +2230,9 @@ void Clay_UpdateScrollContainers(bool isPointerActive, Clay_Vector2 scrollDelta,
float oldYScrollPosition = highestPriorityScrollData->scrollPosition.y;
highestPriorityScrollData->scrollPosition.y = highestPriorityScrollData->scrollOrigin.y + (Clay__pointerPosition.y - highestPriorityScrollData->pointerOrigin.y);
highestPriorityScrollData->scrollPosition.y = CLAY__MAX(CLAY__MIN(highestPriorityScrollData->scrollPosition.y, 0), -(highestPriorityScrollData->contentSize.height - highestPriorityScrollData->boundingBox.height));
scrollDeltaX = highestPriorityScrollData->scrollPosition.x - oldYScrollPosition;
scrollDeltaY = highestPriorityScrollData->scrollPosition.y - oldYScrollPosition;
}
if (scrollDeltaX > -0.1f && scrollDeltaX < 0.1f && scrollDeltaY > -0.1f && scrollDeltaY < 0.1f && highestPriorityScrollData->momentumTime > 0.5f) {
if (scrollDeltaX > -0.1f && scrollDeltaX < 0.1f && scrollDeltaY > -0.1f && scrollDeltaY < 0.1f && highestPriorityScrollData->momentumTime > 0.15f) {
highestPriorityScrollData->momentumTime = 0;
highestPriorityScrollData->pointerOrigin = Clay__pointerPosition;
highestPriorityScrollData->scrollOrigin = highestPriorityScrollData->scrollPosition;

View File

@ -221,7 +221,7 @@
window.touchDown = false;
let zeroTimeout = null;
addEventListener("wheel", (event) => {
window.mouseWheelXThisFrame = event.deltaX * -0.1;
window.mouseWheelXThisFrame = event.deltaX * 0.1;
window.mouseWheelYThisFrame = event.deltaY * -0.1;
clearTimeout(zeroTimeout);
zeroTimeout = setTimeout(() => {