mirror of
https://github.com/nicbarker/clay.git
synced 2025-01-23 18:06:04 +00:00
Fixed a typo bug with drag scrolling in scroll containers
This commit is contained in:
parent
d5cd05aedc
commit
9c5b90e71b
5
clay.h
5
clay.h
@ -780,6 +780,7 @@ typedef struct
|
|||||||
Clay_Vector2 pointerOrigin;
|
Clay_Vector2 pointerOrigin;
|
||||||
Clay_Vector2 scrollMomentum;
|
Clay_Vector2 scrollMomentum;
|
||||||
Clay_Vector2 scrollPosition;
|
Clay_Vector2 scrollPosition;
|
||||||
|
Clay_Vector2 previousDelta;
|
||||||
float momentumTime;
|
float momentumTime;
|
||||||
uint32_t elementId;
|
uint32_t elementId;
|
||||||
bool openThisFrame;
|
bool openThisFrame;
|
||||||
@ -2229,9 +2230,9 @@ void Clay_UpdateScrollContainers(bool isPointerActive, Clay_Vector2 scrollDelta,
|
|||||||
float oldYScrollPosition = highestPriorityScrollData->scrollPosition.y;
|
float oldYScrollPosition = highestPriorityScrollData->scrollPosition.y;
|
||||||
highestPriorityScrollData->scrollPosition.y = highestPriorityScrollData->scrollOrigin.y + (Clay__pointerPosition.y - highestPriorityScrollData->pointerOrigin.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));
|
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->momentumTime = 0;
|
||||||
highestPriorityScrollData->pointerOrigin = Clay__pointerPosition;
|
highestPriorityScrollData->pointerOrigin = Clay__pointerPosition;
|
||||||
highestPriorityScrollData->scrollOrigin = highestPriorityScrollData->scrollPosition;
|
highestPriorityScrollData->scrollOrigin = highestPriorityScrollData->scrollPosition;
|
||||||
|
@ -221,7 +221,7 @@
|
|||||||
window.touchDown = false;
|
window.touchDown = false;
|
||||||
let zeroTimeout = null;
|
let zeroTimeout = null;
|
||||||
addEventListener("wheel", (event) => {
|
addEventListener("wheel", (event) => {
|
||||||
window.mouseWheelXThisFrame = event.deltaX * -0.1;
|
window.mouseWheelXThisFrame = event.deltaX * 0.1;
|
||||||
window.mouseWheelYThisFrame = event.deltaY * -0.1;
|
window.mouseWheelYThisFrame = event.deltaY * -0.1;
|
||||||
clearTimeout(zeroTimeout);
|
clearTimeout(zeroTimeout);
|
||||||
zeroTimeout = setTimeout(() => {
|
zeroTimeout = setTimeout(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user