refactor(legacy): remove unused waveform related code (#3003)

Co-authored-by: Thomas Göttgens <tgoettgens@mail.com>
Co-authored-by: Kyle Robbertze <paddatrapper@users.noreply.github.com>
This commit is contained in:
Thomas Göttgens 2024-05-05 21:15:11 +02:00 committed by GitHub
parent a556b73d2a
commit 064c435b09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 62 additions and 1146 deletions

View file

@ -4,19 +4,14 @@ var wavesurfer = [];
window.addEventListener("load",()=>{
let op=window.inputKnobsOptions||{};
op.knobWidth=op.knobWidth||op.knobDiameter||64;
op.knobHeight=op.knobHeight||op.knobDiameter||64;
op.sliderWidth=op.sliderWidth||op.sliderDiameter||128;
op.sliderHeight=op.sliderHeight||op.sliderDiameter||20;
op.switchWidth=op.switchWidth||op.switchDiameter||24;
op.switchHeight=op.switchHeight||op.switchDiameter||24;
op.fgcolor=op.fgcolor||"#f00";
op.bgcolor=op.bgcolor||"#000";
op.knobMode=op.knobMode||"linear";
op.sliderMode=op.sliderMode||"relative";
let styles=document.createElement("style");
styles.innerHTML=
`input[type=range].input-knob,input[type=range].input-slider{
`input[type=range].input-slider{
-webkit-appearance:none;
-moz-appearance:none;
border:none;
@ -28,52 +23,24 @@ window.addEventListener("load",()=>{
background-color:transparent;
touch-action:none;
}
input[type=range].input-knob{
width:${op.knobWidth}px; height:${op.knobHeight}px;
}
input[type=range].input-slider{
width:${op.sliderWidth}px; height:${op.sliderHeight}px;
}
input[type=range].input-knob::-webkit-slider-thumb,input[type=range].input-slider::-webkit-slider-thumb{
input[type=range].input-slider::-webkit-slider-thumb{
-webkit-appearance:none;
opacity:0;
}
input[type=range].input-knob::-moz-range-thumb,input[type=range].input-slider::-moz-range-thumb{
input[type=range].input-slider::-moz-range-thumb{
-moz-appearance:none;
height:0;
border:none;
}
input[type=range].input-knob::-moz-range-track,input[type=range].input-slider::-moz-range-track{
input[type=range].input-slider::-moz-range-track{
-moz-appearance:none;
height:0;
border:none;
}
input[type=checkbox].input-switch,input[type=radio].input-switch {
width:${op.switchWidth}px;
height:${op.switchHeight}px;
-webkit-appearance:none;
-moz-appearance:none;
background-size:100% 200%;
background-position:0% 0%;
background-repeat:no-repeat;
border:none;
border-radius:0;
background-color:transparent;
}
input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked {
background-position:0% 100%;
}`;
document.head.appendChild(styles);
let makeKnobFrames=(fr,fg,bg)=>{
let r=
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="${fr*64}" viewBox="0 0 64 ${fr*64}" preserveAspectRatio="none">
<defs><g id="K"><circle cx="32" cy="32" r="30" fill="${bg}"/>
<line x1="32" y1="28" x2="32" y2="7" stroke-linecap="round" stroke-width="6" stroke="${fg}"/></g></defs>
<use xlink:href="#K" transform="rotate(-135,32,32)"/>`;
for(let i=1;i<fr;++i)
r+=`<use xlink:href="#K" transform="translate(0,${64*i}) rotate(${-135+270*i/fr},32,32)"/>`;
return r+"</svg>";
}
let makeHSliderFrames=(fr,fg,bg,w,h)=>{
let r=
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${w}" height="${fr*h}" viewBox="0 0 ${w} ${fr*h}" preserveAspectRatio="none">
@ -85,46 +52,6 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
}
return r+"</svg>";
}
let makeVSliderFrames=(fr,fg,bg,w,h)=>{
let r=
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${w}" height="${fr*h}" viewBox="0 0 ${w} ${fr*h}" preserveAspectRatio="none">
<defs><rect id="B" x="0" y="0" width="${w}" height="${h}" rx="${w/2}" ry="${w/2}" fill="${bg}"/>
<circle id="K" x="0" y="0" r="${w/2*0.9}" fill="${fg}"/></defs>`;
for(let i=0;i<fr;++i){
r+=`<use xlink:href="#B" transform="translate(0,${h*i})"/>`;
r+=`<use xlink:href="#K" transform="translate(${w/2} ${h*(i+1)-w/2-i*(h-w)/100})"/>`;
}
return r+"</svg>";
}
let initSwitches=(el)=>{
let w,h,d,fg,bg;
if(el.inputKnobs)
return;
el.inputKnobs={};
el.refresh=()=>{
let src=el.getAttribute("data-src");
d=+el.getAttribute("data-diameter");
let st=document.defaultView.getComputedStyle(el,null);
w=parseFloat(el.getAttribute("data-width")||d||st.width);
h=parseFloat(el.getAttribute("data-height")||d||st.height);
bg=el.getAttribute("data-bgcolor")||op.bgcolor;
fg=el.getAttribute("data-fgcolor")||op.fgcolor;
el.style.width=w+"px";
el.style.height=h+"px";
if(src)
el.style.backgroundImage="url("+src+")";
else {
let minwh=Math.min(w,h);
let svg=
`<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h*2}" viewBox="0 0 ${w} ${h*2}" preserveAspectRatio="none">
<g><rect fill="${bg}" x="1" y="1" width="${w-2}" height="${h-2}" rx="${minwh*0.25}" ry="${minwh*0.25}"/>
<rect fill="${bg}" x="1" y="${h+1}" width="${w-2}" height="${h-2}" rx="${minwh*0.25}" ry="${minwh*0.25}"/>
<circle fill="${fg}" cx="${w*0.5}" cy="${h*1.5}" r="${minwh*0.25}"/></g></svg>`;
el.style.backgroundImage="url(data:image/svg+xml;base64,"+btoa(svg)+")";
}
};
el.refresh();
};
let initKnobs=(el)=>{
let w,h,d,fg,bg;
if(el.inputKnobs){
@ -140,22 +67,9 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
bg=el.getAttribute("data-bgcolor")||op.bgcolor;
fg=el.getAttribute("data-fgcolor")||op.fgcolor;
ik.sensex=ik.sensey=200;
if(el.className.indexOf("input-knob")>=0)
ik.itype="k";
else{
if(w>=h){
ik.itype="h";
ik.sensex=w-h;
ik.sensey=Infinity;
el.style.backgroundSize="auto 100%";
}
else{
ik.itype="v";
ik.sensex="Infinity";
ik.sensey=h-w;
el.style.backgroundSize="100% auto";
}
}
ik.sensex=w-h;
ik.sensey=Infinity;
el.style.backgroundSize="auto 100%";
el.style.width=w+"px";
el.style.height=h+"px";
ik.frameheight=h;
@ -169,18 +83,11 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
ik.sprites=0;
if(ik.sprites>=1)
el.style.backgroundSize=`100% ${(ik.sprites+1)*100}%`;
else if(ik.itype!="k"){
el.style.backgroundColor=bg;
el.style.borderRadius=Math.min(w,h)*0.25+"px";
}
el.style.backgroundColor=bg;
el.style.borderRadius=Math.min(w,h)*0.25+"px";
}
else{
let svg;
switch(ik.itype){
case "k": svg=makeKnobFrames(101,fg,bg); break;
case "h": svg=makeHSliderFrames(101,fg,bg,w,h); break;
case "v": svg=makeVSliderFrames(101,fg,bg,w,h); break;
}
let svg=makeHSliderFrames(101,fg,bg,w,h);
ik.sprites=100;
el.style.backgroundImage="url(data:image/svg+xml;base64,"+btoa(svg)+")";
el.style.backgroundSize=`100% ${(ik.sprites+1)*100}%`;
@ -209,12 +116,7 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
let rc=el.getBoundingClientRect();
let cx=(rc.left+rc.right)*0.5,cy=(rc.top+rc.bottom)*0.5;
let dx=ev.clientX,dy=ev.clientY;
let da=Math.atan2(ev.clientX-cx,cy-ev.clientY);
if(ik.itype=="k"&&op.knobMode=="circularabs"){
dv=ik.valrange.min+(da/Math.PI*0.75+0.5)*(ik.valrange.max-ik.valrange.min);
el.setValue(dv);
}
if(ik.itype!="k"&&op.sliderMode=="abs"){
if(op.sliderMode=="abs"){
dv=(ik.valrange.min+ik.valrange.max)*0.5+((dx-cx)/ik.sensex-(dy-cy)/ik.sensey)*(ik.valrange.max-ik.valrange.min);
el.setValue(dv);
}
@ -235,40 +137,10 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
if(ev.touches)
ev = ev.touches[0];
let dx=ev.clientX-ik.dragfrom.x,dy=ev.clientY-ik.dragfrom.y;
let da=Math.atan2(ev.clientX-cx,cy-ev.clientY);
switch(ik.itype){
case "k":
switch(op.knobMode){
case "linear":
dv=(dx/ik.sensex-dy/ik.sensey)*(ik.valrange.max-ik.valrange.min);
if(ev.shiftKey)
dv*=0.2;
el.setValue(ik.dragfrom.v+dv);
break;
case "circularabs":
if(!ev.shiftKey){
dv=ik.valrange.min+(da/Math.PI*0.75+0.5)*(ik.valrange.max-ik.valrange.min);
el.setValue(dv);
break;
}
case "circularrel":
if(da>ik.dragfrom.a+Math.PI) da-=Math.PI*2;
if(da<ik.dragfrom.a-Math.PI) da+=Math.PI*2;
da-=ik.dragfrom.a;
dv=da/Math.PI/1.5*(ik.valrange.max-ik.valrange.min);
if(ev.shiftKey)
dv*=0.2;
el.setValue(ik.dragfrom.v+dv);
}
break;
case "h":
case "v":
dv=(dx/ik.sensex-dy/ik.sensey)*(ik.valrange.max-ik.valrange.min);
if(ev.shiftKey)
dv*=0.2;
el.setValue(ik.dragfrom.v+dv);
break;
}
dv=(dx/ik.sensex-dy/ik.sensey)*(ik.valrange.max-ik.valrange.min);
if(ev.shiftKey)
dv*=0.2;
el.setValue(ik.dragfrom.v+dv);
};
ik.pointerup=()=>{
document.removeEventListener("mousemove",ik.pointermove);
@ -300,19 +172,8 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
let v=(el.value-ik.valrange.min)/(ik.valrange.max-ik.valrange.min);
if(ik.sprites>=1)
el.style.backgroundPosition="0px "+(-((v*ik.sprites)|0)*ik.frameheight)+"px";
else{
switch(ik.itype){
case "k":
el.style.transform="rotate("+(270*v-135)+"deg)";
break;
case "h":
el.style.backgroundPosition=((w-h)*v)+"px 0px";
break;
case "v":
el.style.backgroundPosition="0px "+(h-w)*(1-v)+"px";
break;
}
}
else
el.style.backgroundPosition=((w-h)*v)+"px 0px";
ik.valueold=el.value;
}
};
@ -325,13 +186,9 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
el.addEventListener("click",function (event){ event.stopPropagation(); });
}
let refreshque=()=>{
let elem=document.querySelectorAll("input.input-knob,input.input-slider");
let elem=document.querySelectorAll("input.input-slider");
for(let i=0;i<elem.length;++i)
procque.push([initKnobs,elem[i]]);
elem=document.querySelectorAll("input[type=checkbox].input-switch,input[type=radio].input-switch");
for(let i=0;i<elem.length;++i){
procque.push([initSwitches,elem[i]]);
}
}
let procque=[];
refreshque();
@ -497,7 +354,7 @@ function secondaryLabelInterval(pxPerSec) {
}
function renderWaveform(track_id, selector_id, url, cuein, cueout, gain_level, default_gain) {
function renderWaveform(track_id, selector_id, url, cuein, cueout) {
var trackid = "t"+track_id;
var a = cuein.split(':'); // split it at the colons
@ -613,15 +470,5 @@ function renderWaveform(track_id, selector_id, url, cuein, cueout, gain_level, d
//Volume to Gain deciSteps(gainNum(gain_level))
eTrack.setVolume(0.6);
document.querySelector("#volume-"+ track_id).value = eTrack.getVolume();
var volumeInput = document.querySelector("#volume-"+ track_id);
var onChangeVolume = function (e) {
//eTrack.setVolume(e.target.value);
};
volumeInput.addEventListener('input', onChangeVolume);
volumeInput.addEventListener('change', onChangeVolume);
return eTrack;
}

View file

@ -1,424 +0,0 @@
/*!
* wavesurfer.js minimap plugin 4.6.0 (2024-02-05)
* https://wavesurfer-js.org
* @license BSD-3-Clause
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("WaveSurfer", [], factory);
else if(typeof exports === 'object')
exports["WaveSurfer"] = factory();
else
root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["minimap"] = factory();
})(this, () => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/plugin/minimap/index.js":
/*!*************************************!*\
!*** ./src/plugin/minimap/index.js ***!
\*************************************/
/***/ ((module, exports) => {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = void 0;
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/*eslint no-console: ["error", { allow: ["warn"] }] */
/**
* @typedef {Object} MinimapPluginParams
* @desc Extends the `WavesurferParams` wavesurfer was initialised with
* @property {?string|HTMLElement} container CSS selector or HTML element where
* the map should be rendered. By default it is simply appended
* after the waveform.
* @property {?boolean} deferInit Set to true to manually call
* `initPlugin('minimap')`
*/
/**
* Renders a smaller version waveform as a minimap of the main waveform.
*
* @implements {PluginClass}
* @extends {Observer}
* @example
* // es6
* import MinimapPlugin from 'wavesurfer.minimap.js';
*
* // commonjs
* var MinimapPlugin = require('wavesurfer.minimap.js');
*
* // if you are using <script> tags
* var MinimapPlugin = window.WaveSurfer.minimap;
*
* // ... initialising wavesurfer with the plugin
* var wavesurfer = WaveSurfer.create({
* // wavesurfer options ...
* plugins: [
* MinimapPlugin.create({
* // plugin options ...
* })
* ]
* });
*/
var MinimapPlugin = exports["default"] = /*#__PURE__*/function () {
function MinimapPlugin(params, ws) {
var _this = this;
_classCallCheck(this, MinimapPlugin);
this.params = Object.assign({}, ws.params, {
showRegions: false,
regionsPluginName: params.regionsPluginName || 'regions',
showOverview: false,
overviewBorderColor: 'green',
overviewBorderSize: 2,
// the container should be different
container: false,
height: Math.max(Math.round(ws.params.height / 4), 20)
}, params, {
scrollParent: false,
fillParent: true
});
// if container is a selector, get the element
if (typeof params.container === 'string') {
var el = document.querySelector(params.container);
if (!el) {
console.warn("Wavesurfer minimap container ".concat(params.container, " was not found! The minimap will be automatically appended below the waveform."));
}
this.params.container = el;
}
// if no container is specified add a new element and insert it
if (!params.container) {
this.params.container = ws.util.style(document.createElement('minimap'), {
display: 'block'
});
}
this.drawer = new ws.Drawer(this.params.container, this.params);
this.wavesurfer = ws;
this.util = ws.util;
/**
* Minimap needs to listen for the `ready` and `waveform-ready` events
* to work with the `MediaElement` backend. The moment the `ready` event
* is called is different (and peaks would not load).
*
* @type {string}
* @see https://github.com/katspaugh/wavesurfer.js/issues/736
*/
this.renderEvent = ws.params.backend === 'MediaElement' ? 'waveform-ready' : 'ready';
this.overviewRegion = null;
this.regionsPlugin = this.wavesurfer[this.params.regionsPluginName];
this.drawer.createWrapper();
this.createElements();
var isInitialised = false;
// ws ready event listener
this._onShouldRender = function () {
// only bind the events in the first run
if (!isInitialised) {
_this.bindWavesurferEvents();
_this.bindMinimapEvents();
isInitialised = true;
}
// if there is no such element, append it to the container (below
// the waveform)
if (!document.body.contains(_this.params.container)) {
ws.container.insertBefore(_this.params.container, null);
}
if (_this.regionsPlugin && _this.params.showRegions) {
_this.regions();
}
_this.render();
};
this._onAudioprocess = function (currentTime) {
_this.drawer.progress(_this.wavesurfer.backend.getPlayedPercents());
};
// ws seek event listener
this._onSeek = function () {
return _this.drawer.progress(ws.backend.getPlayedPercents());
};
// event listeners for the overview region
this._onScroll = function (e) {
if (!_this.draggingOverview) {
_this.moveOverviewRegion(e.target.scrollLeft / _this.ratio);
}
};
this._onMouseover = function (e) {
if (_this.draggingOverview) {
_this.draggingOverview = false;
}
};
var prevWidth = 0;
this._onResize = ws.util.debounce(function () {
if (prevWidth != _this.drawer.wrapper.clientWidth) {
prevWidth = _this.drawer.wrapper.clientWidth;
_this.render();
_this.drawer.progress(_this.wavesurfer.backend.getPlayedPercents());
}
});
this._onZoom = function (e) {
_this.render();
};
this.wavesurfer.on('zoom', this._onZoom);
}
_createClass(MinimapPlugin, [{
key: "init",
value: function init() {
if (this.wavesurfer.isReady) {
this._onShouldRender();
}
this.wavesurfer.on(this.renderEvent, this._onShouldRender);
}
}, {
key: "destroy",
value: function destroy() {
window.removeEventListener('resize', this._onResize, true);
window.removeEventListener('orientationchange', this._onResize, true);
this.wavesurfer.drawer.wrapper.removeEventListener('mouseover', this._onMouseover);
this.wavesurfer.un(this.renderEvent, this._onShouldRender);
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();
}
}, {
key: "regions",
value: function regions() {
var _this2 = this;
this.regions = {};
this.wavesurfer.on('region-created', function (region) {
_this2.regions[region.id] = region;
_this2.drawer.wrapper && _this2.renderRegions();
});
this.wavesurfer.on('region-updated', function (region) {
_this2.regions[region.id] = region;
_this2.drawer.wrapper && _this2.renderRegions();
});
this.wavesurfer.on('region-removed', function (region) {
delete _this2.regions[region.id];
_this2.drawer.wrapper && _this2.renderRegions();
});
}
}, {
key: "renderRegions",
value: function renderRegions() {
var _this3 = this;
var regionElements = this.drawer.wrapper.querySelectorAll('region');
var i;
for (i = 0; i < regionElements.length; ++i) {
this.drawer.wrapper.removeChild(regionElements[i]);
}
Object.keys(this.regions).forEach(function (id) {
var region = _this3.regions[id];
var width = _this3.getWidth() * ((region.end - region.start) / _this3.wavesurfer.getDuration());
var left = _this3.getWidth() * (region.start / _this3.wavesurfer.getDuration());
var regionElement = _this3.util.style(document.createElement('region'), {
height: 'inherit',
backgroundColor: region.color,
width: width + 'px',
left: left + 'px',
display: 'block',
position: 'absolute'
});
regionElement.classList.add(id);
_this3.drawer.wrapper.appendChild(regionElement);
});
}
}, {
key: "createElements",
value: function createElements() {
this.drawer.createElements();
if (this.params.showOverview) {
this.overviewRegion = this.util.style(document.createElement('overview'), {
top: 0,
bottom: 0,
width: '0px',
display: 'block',
position: 'absolute',
cursor: 'move',
border: this.params.overviewBorderSize + 'px solid ' + this.params.overviewBorderColor,
zIndex: 2,
opacity: this.params.overviewOpacity
});
this.drawer.wrapper.appendChild(this.overviewRegion);
}
}
}, {
key: "bindWavesurferEvents",
value: function bindWavesurferEvents() {
window.addEventListener('resize', this._onResize, true);
window.addEventListener('orientationchange', this._onResize, true);
this.wavesurfer.on('audioprocess', this._onAudioprocess);
this.wavesurfer.on('seek', this._onSeek);
if (this.params.showOverview) {
this.wavesurfer.on('scroll', this._onScroll);
this.wavesurfer.drawer.wrapper.addEventListener('mouseover', this._onMouseover);
}
}
}, {
key: "bindMinimapEvents",
value: function bindMinimapEvents() {
var _this4 = this;
var positionMouseDown = {
clientX: 0,
clientY: 0
};
var relativePositionX = 0;
var seek = true;
// the following event listeners will be destroyed by using
// this.unAll() and nullifying the DOM node references after
// removing them
if (this.params.interact) {
this.drawer.wrapper.addEventListener('click', function (event) {
_this4.fireEvent('click', event, _this4.drawer.handleEvent(event));
});
this.on('click', function (event, position) {
if (seek) {
_this4.drawer.progress(position);
_this4.wavesurfer.seekAndCenter(position);
} else {
seek = true;
}
});
}
if (this.params.showOverview) {
this.overviewRegion.addEventListener('mousedown', function (event) {
_this4.draggingOverview = true;
relativePositionX = event.layerX;
positionMouseDown.clientX = event.clientX;
positionMouseDown.clientY = event.clientY;
});
this.drawer.wrapper.addEventListener('mousemove', function (event) {
if (_this4.draggingOverview) {
_this4.moveOverviewRegion(event.clientX - _this4.drawer.container.getBoundingClientRect().left - relativePositionX);
}
});
this.drawer.wrapper.addEventListener('mouseup', function (event) {
if (positionMouseDown.clientX - event.clientX === 0 && positionMouseDown.clientX - event.clientX === 0) {
seek = true;
_this4.draggingOverview = false;
} else if (_this4.draggingOverview) {
seek = false;
_this4.draggingOverview = false;
}
});
}
}
}, {
key: "render",
value: function render() {
var len = this.drawer.getWidth();
var peaks = this.wavesurfer.backend.getPeaks(len, 0, len);
this.drawer.drawPeaks(peaks, len, 0, len);
this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());
if (this.params.showOverview) {
//get proportional width of overview region considering the respective
//width of the drawers
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.container.offsetWidth / this.ratio;
this.overviewPosition = 0;
this.moveOverviewRegion(this.wavesurfer.drawer.wrapper.scrollLeft / this.ratio);
this.overviewRegion.style.width = this.overviewWidth + 'px';
}
}
}, {
key: "moveOverviewRegion",
value: function moveOverviewRegion(pixels) {
if (pixels < 0) {
this.overviewPosition = 0;
} else if (pixels + this.overviewWidth < this.drawer.container.offsetWidth) {
this.overviewPosition = pixels;
} else {
this.overviewPosition = this.drawer.container.offsetWidth - this.overviewWidth;
}
this.overviewRegion.style.left = this.overviewPosition + 'px';
if (this.draggingOverview) {
this.wavesurfer.drawer.wrapper.scrollLeft = this.overviewPosition * this.ratio;
}
}
}, {
key: "getWidth",
value: function getWidth() {
return this.drawer.width / this.params.pixelRatio;
}
}], [{
key: "create",
value:
/**
* Minimap plugin definition factory
*
* This function must be used to create a plugin definition which can be
* used by wavesurfer to correctly instantiate the plugin.
*
* @param {MinimapPluginParams} params parameters use to initialise the plugin
* @return {PluginDefinition} an object representing the plugin
*/
function create(params) {
return {
name: 'minimap',
deferInit: params && params.deferInit ? params.deferInit : false,
params: params,
staticProps: {},
instance: MinimapPlugin
};
}
}]);
return MinimapPlugin;
}();
module.exports = exports.default;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __webpack_require__("./src/plugin/minimap/index.js");
/******/
/******/ return __webpack_exports__;
/******/ })()
;
});
//# sourceMappingURL=wavesurfer.minimap.js.map

File diff suppressed because one or more lines are too long