Skip to content

Commit 93692b8

Browse files
authored
Fix: [Regions] region-in/out event for markers (#3374)
1 parent a6086db commit 93692b8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

examples/regions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ document.querySelector('input[type="checkbox"]').onclick = (e) => {
7676
{
7777
let activeRegion = null
7878
wsRegions.on('region-in', (region) => {
79+
console.log('region-in', region)
7980
activeRegion = region
8081
})
8182
wsRegions.on('region-out', (region) => {
83+
console.log('region-out', region)
8284
if (activeRegion === region) {
8385
if (loop) {
8486
region.play()

src/plugins/regions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,11 @@ class RegionsPlugin extends BasePlugin<RegionsPluginEvents, RegionsPluginOptions
379379
this.subscriptions.push(
380380
this.wavesurfer.on('timeupdate', (currentTime) => {
381381
// Detect when regions are being played
382-
const playedRegions = this.regions.filter((region) => region.start <= currentTime && region.end >= currentTime)
382+
const playedRegions = this.regions.filter(
383+
(region) =>
384+
region.start <= currentTime &&
385+
(region.end === region.start ? region.start + 0.05 : region.end) >= currentTime,
386+
)
383387

384388
// Trigger region-in when activeRegions doesn't include a played regions
385389
playedRegions.forEach((region) => {

0 commit comments

Comments
 (0)