From 97421acd0abaf538ab6997005b1ef6acdace0103 Mon Sep 17 00:00:00 2001 From: Nilesh Chavan Date: Tue, 18 Nov 2025 10:55:47 +0530 Subject: [PATCH] fix(UNT-T40021): seek functionality in horizontal list --- README.md | 1 + src/components/Waveform/Waveform.tsx | 7 ++++++- src/components/Waveform/WaveformTypes.ts | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 76bf1a5..075628c 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,7 @@ You can check out the full example at [Example](./example/src/App.tsx). | onChangeWaveformLoadState | - | ✅ | ❌ | ( state : boolean ) => void | callback function which returns the loading state of waveform candlestick. | | onError | - | ✅ | ❌ | ( error : Error ) => void | callback function which returns the error for static audio waveform | | showsHorizontalScrollIndicator | false | ❌ | ✅ | boolean | whether to show scroll indicator when live waveform is being recorded and total width is more than parent view width | +| isInHorizontalList | false | ✅ | ❌ | boolean | When true, indicates the waveform is rendered inside a horizontally scrolling list and enables correct seek/touch behavior while scrolling. | ##### Know more about [ViewStyle](https://reactnative.dev/docs/view-style-props), [PlayerState](#playerstate), and [RecorderState](#recorderstate) diff --git a/src/components/Waveform/Waveform.tsx b/src/components/Waveform/Waveform.tsx index cef932b..dc30065 100644 --- a/src/components/Waveform/Waveform.tsx +++ b/src/components/Waveform/Waveform.tsx @@ -64,6 +64,7 @@ export const Waveform = forwardRef((props, ref) => { candleHeightScale = 3, onChangeWaveformLoadState = (_state: boolean) => {}, showsHorizontalScrollIndicator = false, + isInHorizontalList = false, } = props as StaticWaveform & LiveWaveform; const viewRef = useRef(null); const scrollRef = useRef(null); @@ -576,7 +577,7 @@ export const Waveform = forwardRef((props, ref) => { const panResponder = useRef( PanResponder.create({ onStartShouldSetPanResponder: () => { - if (!isLayoutCalculated.current) { + if (!isLayoutCalculated.current || isInHorizontalList) { calculateLayout(); } @@ -584,6 +585,10 @@ export const Waveform = forwardRef((props, ref) => { }, onMoveShouldSetPanResponder: () => true, onPanResponderGrant: () => { + if (isInHorizontalList) { + calculateLayout(); + } + setPanMoving(true); (onPanStateChange as Function)(true); }, diff --git a/src/components/Waveform/WaveformTypes.ts b/src/components/Waveform/WaveformTypes.ts index c7eaa81..40502fb 100644 --- a/src/components/Waveform/WaveformTypes.ts +++ b/src/components/Waveform/WaveformTypes.ts @@ -29,6 +29,7 @@ export interface StaticWaveform extends BaseWaveform { ) => void; onChangeWaveformLoadState?: (state: boolean) => void; playbackSpeed?: PlaybackSpeedType; + isInHorizontalList?: boolean; } export interface LiveWaveform extends BaseWaveform {