fix(sidebar): eliminate tap delay by triggering animation directly
The animation was waiting ~32ms for React's useEffect cycle before starting. Now handleAgentSelectMobile triggers the close animation immediately using withTiming on shared values, bypassing useEffect. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
344ef87b10
commit
75895b17d4
@@ -47,7 +47,9 @@ export function SlidingSidebar({ selectedAgentId }: SlidingSidebarProps) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Don't animate if we're in the middle of a gesture
|
// Don't animate if we're in the middle of a gesture
|
||||||
if (isGesturing.value) return;
|
if (isGesturing.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const width = isMobile ? windowWidth : DESKTOP_SIDEBAR_WIDTH;
|
const width = isMobile ? windowWidth : DESKTOP_SIDEBAR_WIDTH;
|
||||||
translateX.value = withTiming(isOpen ? 0 : -width, {
|
translateX.value = withTiming(isOpen ? 0 : -width, {
|
||||||
@@ -92,8 +94,17 @@ export function SlidingSidebar({ selectedAgentId }: SlidingSidebarProps) {
|
|||||||
|
|
||||||
// Mobile: close sidebar when agent is selected
|
// Mobile: close sidebar when agent is selected
|
||||||
const handleAgentSelectMobile = useCallback(() => {
|
const handleAgentSelectMobile = useCallback(() => {
|
||||||
close();
|
// Start animation immediately, don't wait for useEffect
|
||||||
}, [close]);
|
translateX.value = withTiming(-windowWidth, {
|
||||||
|
duration: ANIMATION_DURATION,
|
||||||
|
easing: ANIMATION_EASING,
|
||||||
|
});
|
||||||
|
backdropOpacity.value = withTiming(0, {
|
||||||
|
duration: ANIMATION_DURATION,
|
||||||
|
easing: ANIMATION_EASING,
|
||||||
|
});
|
||||||
|
close(); // Update state for consistency
|
||||||
|
}, [close, translateX, backdropOpacity, windowWidth]);
|
||||||
|
|
||||||
// Close gesture (swipe left to close when sidebar is open)
|
// Close gesture (swipe left to close when sidebar is open)
|
||||||
const closeGesture = Gesture.Pan()
|
const closeGesture = Gesture.Pan()
|
||||||
|
|||||||
Reference in New Issue
Block a user