mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 16:43:25 +00:00
feat: detect pan gesture direction and adjust values accordingly
This commit is contained in:
@@ -108,15 +108,19 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ data }) => {
|
|||||||
const dragIsInHeaderOrFooter = event.y < 100 || event.y > 400;
|
const dragIsInHeaderOrFooter = event.y < 100 || event.y > 400;
|
||||||
if (dragIsInHeaderOrFooter) return;
|
if (dragIsInHeaderOrFooter) return;
|
||||||
|
|
||||||
|
const directionMultiplier = event.velocityY < 0 ? 1 : -1;
|
||||||
|
|
||||||
if (event.x > screenHalfWidth) {
|
if (event.x > screenHalfWidth) {
|
||||||
const change = -event.translationY / divisor;
|
const change =
|
||||||
|
directionMultiplier * Math.abs(event.velocityY / divisor);
|
||||||
const newVolume = Math.max(
|
const newVolume = Math.max(
|
||||||
0,
|
0,
|
||||||
Math.min(1, currentVolume.value + change),
|
Math.min(1, currentVolume.value + change),
|
||||||
);
|
);
|
||||||
runOnJS(handleVolumeChange)(newVolume);
|
runOnJS(handleVolumeChange)(newVolume);
|
||||||
} else {
|
} else {
|
||||||
const change = -event.translationY / divisor;
|
const change =
|
||||||
|
directionMultiplier * Math.abs(event.velocityY / divisor);
|
||||||
const newBrightness = Math.max(
|
const newBrightness = Math.max(
|
||||||
0,
|
0,
|
||||||
Math.min(1, brightness.value + change),
|
Math.min(1, brightness.value + change),
|
||||||
|
Reference in New Issue
Block a user