Skip to content

Commit

Permalink
Merge pull request katspaugh#561 from rozap/master
Browse files Browse the repository at this point in the history
Add zoom event
  • Loading branch information
katspaugh committed Oct 27, 2015
2 parents f3760c6 + d46437d commit 8d94d2b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ General events:
* `ready` – When audio is loaded, decoded and the waveform drawn.
* `scroll` - When the scrollbar is moved. Callback will receive a `ScrollEvent` object.
* `seek` – On seeking. Callback will receive (float) progress [0..1].
* `zoom` – On zooming. Callback will receive (integer) minPxPerSec.

Region events (exposed by the Regions plugin):

Expand Down Expand Up @@ -165,7 +166,7 @@ After doing that, use `wavesurfer.addRegion()` to create Region objects.

### Exposed Methods

* `addRegion(options)` – Creates a region on the waveform. Returns a `Region` object. See [Region Options](#region-options), [Region Methods](#region-methods) and [Region Events](#region-events) below.
* `addRegion(options)` – Creates a region on the waveform. Returns a `Region` object. See [Region Options](#region-options), [Region Methods](#region-methods) and [Region Events](#region-events) below.
* **Note:** You cannot add regions until the audio has finished loading, otherwise the `start:` and `end:` properties of the new region will be set to `0`, or an unexpected value.
* `clearRegions()` – Removes all regions.
* `enableDragSelection(options)` – Lets you create regions by selecting.
Expand Down
4 changes: 3 additions & 1 deletion plugin/wavesurfer.regions.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ WaveSurfer.Region = {

this.bindInOut();
this.render();

this.wavesurfer.on('zoom', this.updateRender.bind(this));
this.wavesurfer.fireEvent('region-created', this);

},

/* Update region params. */
Expand Down Expand Up @@ -143,6 +144,7 @@ WaveSurfer.Region = {
this.wrapper.removeChild(this.element);
this.element = null;
this.fireEvent('remove');
this.wavesurfer.un('zoom', this.updateRender.bind(this));
this.wavesurfer.fireEvent('region-removed', this);
}
},
Expand Down
1 change: 1 addition & 0 deletions src/wavesurfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ var WaveSurfer = {
this.seekAndCenter(
this.getCurrentTime() / this.getDuration()
);
this.fireEvent('zoom', pxPerSec);
},

/**
Expand Down

0 comments on commit 8d94d2b

Please sign in to comment.