feat: detect pan gesture direction and adjust values accordingly

This commit is contained in:
Adrian Castro
2024-02-14 22:38:18 +01:00
parent e72be7af6c
commit 3e4a6cc3b2

View File

@@ -108,15 +108,19 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ 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),