Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 6 additions & 1 deletion src/components/Waveform/Waveform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const Waveform = forwardRef<IWaveformRef, IWaveform>((props, ref) => {
candleHeightScale = 3,
onChangeWaveformLoadState = (_state: boolean) => {},
showsHorizontalScrollIndicator = false,
isInHorizontalList = false,
} = props as StaticWaveform & LiveWaveform;
const viewRef = useRef<View>(null);
const scrollRef = useRef<ScrollView>(null);
Expand Down Expand Up @@ -576,14 +577,18 @@ export const Waveform = forwardRef<IWaveformRef, IWaveform>((props, ref) => {
const panResponder = useRef(
PanResponder.create({
onStartShouldSetPanResponder: () => {
if (!isLayoutCalculated.current) {
if (!isLayoutCalculated.current || isInHorizontalList) {
calculateLayout();
}

return true;
},
onMoveShouldSetPanResponder: () => true,
onPanResponderGrant: () => {
if (isInHorizontalList) {
calculateLayout();
}

setPanMoving(true);
(onPanStateChange as Function)(true);
},
Expand Down
1 change: 1 addition & 0 deletions src/components/Waveform/WaveformTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface StaticWaveform extends BaseWaveform {
) => void;
onChangeWaveformLoadState?: (state: boolean) => void;
playbackSpeed?: PlaybackSpeedType;
isInHorizontalList?: boolean;
}

export interface LiveWaveform extends BaseWaveform {
Expand Down