peaks.js
peaks.js copied to clipboard
Question: initial zoom value
Is it possible to set the initial zoom value? From what I can see it seems that the initial zoom value is equal to the first value from the zoomLevels array. I've tried to set the value after peaks.init like this:
const zoomView = self.peaksInstance.views.getView("zoomview"); zoomView.setZoom({ scale: 2048 });
but if I do this the 'Zoom in' button will not work until I press the 'Zoom out' button first.
my zoomLevels array:
zoomLevels: [512, 1024, 2048, 4096, 8192],
Thanks for reporting this. I'll take a look soon.
This works for me:
const peakOptions = {
containers: {
overview: document.getElementById(`overview-container`),
zoomview: document.getElementById(`zoomview-container`)
},
mediaElement: document.getElementById(`audio`),
webAudio: {
audioBuffer
},
pointMarkerColor: 'rgba(30, 139, 195, 1)',
zoomLevels: [128, 256, 512, 1024, 2048],
zoomWaveformColor: '#aaa',
overviewWaveformColor: 'rgba(89, 165, 89, 0.7)'
}
Peaks.init(peakOptions, function (err, waveform) {
waveform.zoom.setZoom(3) // 1024