peaks.js icon indicating copy to clipboard operation
peaks.js copied to clipboard

Question: initial zoom value

Open TaridaGeorge opened this issue 5 years ago • 2 comments

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],

TaridaGeorge avatar Nov 26 '20 12:11 TaridaGeorge

Thanks for reporting this. I'll take a look soon.

chrisn avatar Dec 01 '20 11:12 chrisn

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

jgentes avatar Mar 02 '21 15:03 jgentes