Skip to content

Commit 2a333b9

Browse files
authored
Fix: [Record] restore interact and cursor width on destoy (#3375)
1 parent 93692b8 commit 2a333b9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/plugins/record.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class RecordPlugin extends BasePlugin<RecordPluginEvents, RecordPluginOptions> {
4545
private mediaRecorder: MediaRecorder | null = null
4646
private dataWindow: Float32Array | null = null
4747
private isWaveformPaused = false
48+
private originalOptions = { cursorWidth: 1, interact: true }
4849

4950
/** Create an instance of the Record plugin */
5051
constructor(options: RecordPluginOptions) {
@@ -101,6 +102,10 @@ class RecordPlugin extends BasePlugin<RecordPluginEvents, RecordPluginOptions> {
101102
const duration = this.options.scrollingWaveformWindow
102103

103104
if (this.wavesurfer) {
105+
this.originalOptions = {
106+
cursorWidth: this.wavesurfer.options.cursorWidth,
107+
interact: this.wavesurfer.options.interact,
108+
}
104109
this.wavesurfer.options.cursorWidth = 0
105110
this.wavesurfer.options.interact = false
106111
this.wavesurfer.load('', [this.dataWindow], duration)
@@ -240,6 +245,11 @@ class RecordPlugin extends BasePlugin<RecordPluginEvents, RecordPluginOptions> {
240245

241246
/** Destroy the plugin */
242247
public destroy() {
248+
if (this.wavesurfer) {
249+
this.wavesurfer.options.cursorWidth = this.originalOptions.cursorWidth
250+
this.wavesurfer.options.interact = this.originalOptions.interact
251+
}
252+
243253
super.destroy()
244254
this.stopRecording()
245255
this.stopMic()

0 commit comments

Comments
 (0)