From 9c5b90e71b476c77de6979365235933bc83e5a94 Mon Sep 17 00:00:00 2001 From: Nic Barker Date: Sat, 24 Aug 2024 21:22:54 +1200 Subject: [PATCH] Fixed a typo bug with drag scrolling in scroll containers --- clay.h | 5 +++-- examples/clay-official-website/index.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/clay.h b/clay.h index 0251a4c..8436831 100644 --- a/clay.h +++ b/clay.h @@ -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; diff --git a/examples/clay-official-website/index.html b/examples/clay-official-website/index.html index b53f19f..61f7226 100644 --- a/examples/clay-official-website/index.html +++ b/examples/clay-official-website/index.html @@ -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(() => {