From 3e4a6cc3b275dd2cd018db545be3f7b99095c17e Mon Sep 17 00:00:00 2001 From: Adrian Castro <22133246+castdrian@users.noreply.github.com> Date: Wed, 14 Feb 2024 22:38:18 +0100 Subject: [PATCH] feat: detect pan gesture direction and adjust values accordingly --- apps/expo/src/app/videoPlayer/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/expo/src/app/videoPlayer/index.tsx b/apps/expo/src/app/videoPlayer/index.tsx index e9d11dc..d27e88d 100644 --- a/apps/expo/src/app/videoPlayer/index.tsx +++ b/apps/expo/src/app/videoPlayer/index.tsx @@ -108,15 +108,19 @@ const VideoPlayer: React.FC = ({ data }) => { const dragIsInHeaderOrFooter = event.y < 100 || event.y > 400; if (dragIsInHeaderOrFooter) return; + const directionMultiplier = event.velocityY < 0 ? 1 : -1; + if (event.x > screenHalfWidth) { - const change = -event.translationY / divisor; + const change = + directionMultiplier * Math.abs(event.velocityY / divisor); const newVolume = Math.max( 0, Math.min(1, currentVolume.value + change), ); runOnJS(handleVolumeChange)(newVolume); } else { - const change = -event.translationY / divisor; + const change = + directionMultiplier * Math.abs(event.velocityY / divisor); const newBrightness = Math.max( 0, Math.min(1, brightness.value + change),