Skip to content

Commit 94687c5

Browse files
authored
Fix example drag behavior w/ mouseUp (#5190)
1 parent 7c7e846 commit 94687c5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/@react-aria/interactions/docs/useMove.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ function Example() {
115115
setEvents(events => [`move with pointerType = ${e.pointerType}, deltaX = ${e.deltaX}, deltaY = ${e.deltaY}`, ...events]);
116116
},
117117
onMoveEnd(e) {
118+
setPosition(({x, y}) => {
119+
// Clamp position on mouse up
120+
x = clamp(x);
121+
y = clamp(y);
122+
return {x, y};
123+
});
118124
setColor('black');
119125
setEvents(events => [`move end with pointerType = ${e.pointerType}`, ...events]);
120126
}

0 commit comments

Comments
 (0)