Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minimap styling issues and add support for zooming #1464

Merged
merged 3 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ process.traceDeprecation = true;

require('babel-register');
var webpackConfig = require('./build-config/webpack.prod.main.js');
webpackConfig.devtool = 'none';
joshsalverda marked this conversation as resolved.
Show resolved Hide resolved
var ci = process.env.TRAVIS || process.env.APPVEYOR;

// Chrome CLI options
Expand Down
24 changes: 15 additions & 9 deletions src/plugin/minimap.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ export default class MinimapPlugin {
);
}
});
this._onZoom = e => {
this.render();
};
this.wavesurfer.on('zoom', this._onZoom);
}

init() {
Expand All @@ -187,6 +191,7 @@ export default class MinimapPlugin {
this.wavesurfer.un('seek', this._onSeek);
this.wavesurfer.un('scroll', this._onScroll);
this.wavesurfer.un('audioprocess', this._onAudioprocess);
this.wavesurfer.un('zoom', this._onZoom);
this.drawer.destroy();
this.overviewRegion = null;
this.unAll();
Expand Down Expand Up @@ -248,10 +253,8 @@ export default class MinimapPlugin {
this.overviewRegion = this.util.style(
document.createElement('overview'),
{
height:
this.drawer.wrapper.offsetHeight -
this.params.overviewBorderSize * 2 +
'px',
top: 0,
bottom: 0,
width: '0px',
display: 'block',
position: 'absolute',
Expand Down Expand Up @@ -353,23 +356,26 @@ export default class MinimapPlugin {
this.ratio = this.wavesurfer.drawer.width / this.drawer.width;
this.waveShowedWidth = this.wavesurfer.drawer.width / this.ratio;
this.waveWidth = this.wavesurfer.drawer.width;
this.overviewWidth = this.drawer.width / this.ratio;
this.overviewWidth = this.drawer.container.offsetWidth / this.ratio;
this.overviewPosition = 0;
this.moveOverviewRegion(
this.wavesurfer.drawer.wrapper.scrollLeft / this.ratio
);
this.overviewRegion.style.width =
this.overviewWidth - this.params.overviewBorderSize * 2 + 'px';
this.overviewRegion.style.width = this.overviewWidth + 'px';
}
}

moveOverviewRegion(pixels) {
if (pixels < 0) {
this.overviewPosition = 0;
} else if (pixels + this.overviewWidth < this.drawer.width) {
} else if (
pixels + this.overviewWidth <
this.drawer.container.offsetWidth
) {
this.overviewPosition = pixels;
} else {
this.overviewPosition = this.drawer.width - this.overviewWidth;
this.overviewPosition =
this.drawer.container.offsetWidth - this.overviewWidth;
}
this.overviewRegion.style.left = this.overviewPosition + 'px';
if (this.draggingOverview) {
Expand Down