UNPKG

wavesurfer.js

Version:

Interactive navigable audio visualization using Web Audio and Canvas

7 lines 3.37 kB
/*! * wavesurfer.js 2.0.5 (Sun Mar 04 2018 20:10:16 GMT+0100 (CET)) * https://github.com/katspaugh/wavesurfer.js * @license BSD-3-Clause */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cursor",[],t):"object"==typeof exports?exports.cursor=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.cursor=t())}("undefined"!=typeof self?self:this,function(){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="localhost:8080/dist/plugin/",t(t.s=4)}({4:function(e,t,r){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),s=function(){function e(t,r){var n=this;o(this,e),this.defaultParams={hideOnBlur:!0,width:"1px",color:"black",opacity:"0.25",style:"solid",zIndex:4,customStyle:{}},this._onMousemove=function(e){var t=n.wavesurfer.container.getBoundingClientRect();n.updateCursorPosition(e.clientX-t.left)},this._onMouseenter=function(){return n.showCursor()},this._onMouseleave=function(){return n.hideCursor()},this.wavesurfer=r,this.style=r.util.style,this.cursor=null,this.params=r.util.extend({},this.defaultParams,t)}return n(e,null,[{key:"create",value:function(t){return{name:"cursor",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{enableCursor:function(){console.warn("Deprecated enableCursor!"),this.initPlugins("cursor")}},instance:e}}}]),n(e,[{key:"init",value:function(){var e=this.wavesurfer.container;this.cursor=e.appendChild(this.style(document.createElement("cursor"),this.wavesurfer.util.extend({position:"absolute",zIndex:this.params.zIndex,left:0,top:0,bottom:0,width:"0",display:"block",borderRightStyle:this.params.style,borderRightWidth:this.params.width,borderRightColor:this.params.color,opacity:this.params.opacity,pointerEvents:"none"},this.params.customStyle))),e.addEventListener("mousemove",this._onMousemove),this.params.hideOnBlur&&(e.addEventListener("mouseenter",this._onMouseenter),e.addEventListener("mouseleave",this._onMouseleave))}},{key:"destroy",value:function(){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){this.style(this.cursor,{left:e+"px"})}},{key:"showCursor",value:function(){this.style(this.cursor,{display:"block"})}},{key:"hideCursor",value:function(){this.style(this.cursor,{display:"none"})}}]),e}();t.default=s,e.exports=t.default}})}); //# sourceMappingURL=wavesurfer.cursor.min.js.map