Open panhe-xue opened 1 month ago
this.regions.forEach((region) => (region && region.remove()))
Hmm, weird. Regions are supposed to be removed from the list on the remove event:
https://github.com/katspaugh/wavesurfer.js/blob/main/src/plugins/regions.ts#L581
So we can only remove regions using events, not clearRegions? Because clearRegions is going to be a problem next time.
Hmm, weird. Regions are supposed to be removed from the list on the remove event:
https://github.com/katspaugh/wavesurfer.js/blob/main/src/plugins/regions.ts#L581
So we can only remove regions using events, not clearRegions? Because clearRegions is going to be a problem next time
No, the event is emitted when a region is removed. So when clear regions removes each region, it's supposed to emit a remove
event and get removed from the list.
No, the event is emitted when a region is removed. So when clear regions removes each region, it's supposed to emit a
remove
event and get removed from the list.
I see what you're said, How do I know when clearRegions has cleared all of them
No, the event is emitted when a region is removed. So when clear regions removes each region, it's supposed to emit a
remove
event and get removed from the list.I see what you're said, How do I know when clearRegions has cleared all of them
I can only use other variables to control, I can't get this moment from an event???
You don't need to use the event. All I'm saying is that clearRegions is supposed to remove each region from the this.regions
array thanks to an internal remove
event subscription. If it doesn't, there might be a bug.
clearRegions
When clearRegions called, you should make sure that addRegions cannot be executed, otherwise it will get messy
I see. You can probably call addRegion with a delay (setTimeout) as a workaround.
That doesn't work, I think of a way, could you have a look?
` public clearRegions() { // this.regions.forEach((region) => region.remove()) const regions = cloneDeep(this.regions) regions.forEach((region) => region.remove()) }
` That doesn't work, I think of a way, could you have a look?
` public clearRegions() { // this.regions.forEach((region) => region.remove()) const regions = cloneDeep(this.regions) this.regions = [] regions.forEach((region) => region.remove()) }
`
Bug description
The regions array is not cleared after the clearRegions method is called
Environment
Minimal code snippet
Expected result
Obtained result
Screenshots