katspaugh / wavesurfer.js

Audio waveform player
https://wavesurfer.xyz
BSD 3-Clause "New" or "Revised" License
8.8k stars 1.63k forks source link

region.setOptions({..}) does not modify the region's color #3879

Open omerman opened 1 month ago

omerman commented 1 month ago

Bug description

region.setOptions({..}) does not modify the region's color.

Environment

Minimal code snippet

Will provide minimal code snippet in the upcoming days, but incase you have a minimal repo of your own to work with, I thought I'd give you a head start

Expected result

region.setOptions({..}) should be able to update the region's color.

Obtained result

Screenshots

lucastheis commented 1 month ago

Regarding clearRegions(), see issue #3798.

katspaugh commented 1 month ago

Closing as a duplicate of #3798.

omerman commented 1 month ago

@katspaugh But the setOptions part is not duplicate, will this also be addressed? 😢

katspaugh commented 1 month ago

@omerman thanks for the sponsorship! I’ll prioritize this and the other regions issue. 👍

omerman commented 1 month ago

@katspaugh Thank you so much for your work 🙏

JanMisker commented 1 month ago

@omerman I had noticed something similar, it turns out that some of my regions were initially of zero-width implying they were internally marked as markers. And markers don't have a background color. Even after the regions were being extended to actual markers, they were still not picking up the color.

omerman commented 1 month ago

@JanMisker Im passing only the start arg, so I guess by default it is also used as a marker here is my code snippet:

regionsPlugin.addRegion({
          id: `tempo_${i}`,
          start: tempoItem,
          color: i === playerIndex ? colors.pink['500'] : colors.gray['400'], // init
          drag: false,
          resize: false,
        });

And because a color cannot be updated I have to remove the region and recreate it 😅

JanMisker commented 1 month ago

@omerman yeah that will be it; because you give no value for end, it is a marker and doesn't get a color.

omerman commented 1 month ago

@omerman yeah that will be it; because you give no value for end, it is a marker and doesn't get a color.

@JanMisker Just to make sure we are both on the same page, My regions have colors, but the update options method won't work when I try to update the color. I need to remove them and re-create them in order to make a color update

image