UNPKG

react-nextjs-record

Version:

Record Voice

24 lines (16 loc) 5.14 kB
'use strict'; var index = require('./index-26864645.js'); /*! * wavesurfer.js cursor plugin 5.2.0 (2021-08-16) * https://wavesurfer-js.org * @license BSD-3-Clause */ var wavesurfer_cursor_min = index.createCommonjsModule(function (module, exports) { !function(e,t){module.exports=t();}(self,(function(){return (()=>{var e={178:(e,t)=>{function i(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s);}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=function(){function e(t,i){var s=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultParams={hideOnBlur:!0,width:"1px",color:"black",opacity:"0.25",style:"solid",zIndex:4,customStyle:{},customShowTimeStyle:{},showTime:!1,followCursorY:!1,formatTimeCallback:null},this._onMousemove=function(e){var t=s.wavesurfer.container.getBoundingClientRect(),i=0,r=e.clientX-t.left,o=t.right<e.clientX+s.outerWidth(s.displayTime);s.params.showTime&&s.params.followCursorY&&(i=e.clientY-(t.top+t.height/2)),s.updateCursorPosition(r,i,o);},this._onMouseenter=function(){return s.showCursor()},this._onMouseleave=function(){return s.hideCursor()},this.wavesurfer=i,this.style=i.util.style,this.cursor=null,this.showTime=null,this.displayTime=null,this.params=Object.assign({},this.defaultParams,t);}var t,s,r;return t=e,r=[{key:"create",value:function(t){return {name:"cursor",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{},instance:e}}}],(s=[{key:"init",value:function(){this.wrapper=this.wavesurfer.container,this.cursor=this.wrapper.appendChild(this.style(document.createElement("cursor"),Object.assign({position:"absolute",zIndex:this.params.zIndex,left:0,top:0,bottom:0,width:"0",display:"flex",borderRightStyle:this.params.style,borderRightWidth:this.params.width,borderRightColor:this.params.color,opacity:this.params.opacity,pointerEvents:"none"},this.params.customStyle))),this.params.showTime&&(this.showTime=this.wrapper.appendChild(this.style(document.createElement("showTitle"),Object.assign({position:"absolute",zIndex:this.params.zIndex,left:0,top:0,bottom:0,width:"auto",display:"flex",opacity:this.params.opacity,pointerEvents:"none",height:"100%"},this.params.customStyle))),this.displayTime=this.showTime.appendChild(this.style(document.createElement("div"),Object.assign({display:"inline",pointerEvents:"none",margin:"auto",visibility:"hidden"},this.params.customShowTimeStyle))),this.displayTime.innerHTML=this.formatTime(0)),this.wrapper.addEventListener("mousemove",this._onMousemove),this.params.hideOnBlur&&(this.hideCursor(),this.wrapper.addEventListener("mouseenter",this._onMouseenter),this.wrapper.addEventListener("mouseleave",this._onMouseleave));}},{key:"destroy",value:function(){this.params.showTime&&this.cursor.parentNode.removeChild(this.showTime),this.cursor.parentNode.removeChild(this.cursor),this.wrapper.removeEventListener("mousemove",this._onMousemove),this.params.hideOnBlur&&(this.wrapper.removeEventListener("mouseenter",this._onMouseenter),this.wrapper.removeEventListener("mouseleave",this._onMouseleave));}},{key:"updateCursorPosition",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.style(this.cursor,{left:"".concat(e,"px")}),this.params.showTime){var s=this.wavesurfer.getDuration(),r=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,o=this.wavesurfer.drawer.getScrollX(),a=s/this.wavesurfer.drawer.width*o,n=Math.max(0,e/r*s)+a,h=this.formatTime(n);if(i){var l=this.outerWidth(this.displayTime);e-=l;}this.style(this.showTime,{left:"".concat(e,"px"),top:"".concat(t,"px")}),this.style(this.displayTime,{visibility:"visible"}),this.displayTime.innerHTML="".concat(h);}}},{key:"showCursor",value:function(){this.style(this.cursor,{display:"flex"}),this.params.showTime&&this.style(this.showTime,{display:"flex"});}},{key:"hideCursor",value:function(){this.style(this.cursor,{display:"none"}),this.params.showTime&&this.style(this.showTime,{display:"none"});}},{key:"formatTime",value:function(e){return e=isNaN(e)?0:e,this.params.formatTimeCallback?this.params.formatTimeCallback(e):[e].map((function(e){return [Math.floor(e%3600/60),("00"+Math.floor(e%60)).slice(-2),("000"+Math.floor(e%1*1e3)).slice(-3)].join(":")}))}},{key:"outerWidth",value:function(e){if(!e)return 0;var t=e.offsetWidth,i=getComputedStyle(e);return t+=parseInt(i.marginLeft+i.marginRight)}}])&&i(t.prototype,s),r&&i(t,r),e}();t.default=s,e.exports=t.default;}},t={};return function i(s){var r=t[s];if(void 0!==r)return r.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,i),o.exports}(178)})()})); }); var wavesurfer_cursor_min$1 = /*@__PURE__*/index.getDefaultExportFromCjs(wavesurfer_cursor_min); var wavesurfer_cursor_min$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), wavesurfer_cursor_min, { 'default': wavesurfer_cursor_min$1 })); exports.wavesurfer_cursor_min = wavesurfer_cursor_min$2; //# sourceMappingURL=wavesurfer.cursor.min-55de339b.js.map