Skip to content

Commit

Permalink
Regions plugin: Only add resize handles if resize prop is true (#3171)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyao84 authored Sep 11, 2023
1 parent 8bda65a commit e796e5a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions cypress/e2e/regions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,23 @@ describe('WaveSurfer Regions plugin tests', () => {
win.wavesurfer.destroy()
})
})

it('should not add resize handles if resize is set to false', () => {
cy.window().then((win) => {
const regionsPlugin = win.wavesurfer.getActivePlugins()[0]

const region = regionsPlugin.addRegion({
id: 'no-resize-region',
start: 1,
end: 5,
resize: false,
})

expect(region).to.be.an('object')
expect(region.element).to.be.an('HTMLDivElement')
expect(region.element.children).to.have.length(0)

win.wavesurfer.destroy()
})
})
})
2 changes: 1 addition & 1 deletion src/plugins/regions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class SingleRegion extends EventEmitter<RegionEvents> {
)

// Add resize handles
if (!isMarker) {
if (!isMarker && this.resize) {
const leftHandle = document.createElement('div')
leftHandle.setAttribute('data-resize', 'left')
leftHandle.setAttribute(
Expand Down

0 comments on commit e796e5a

Please sign in to comment.