wavesurfer
Version:
Interactive navigable audio visualization using Web Audio and Canvas
3 lines • 1.42 kB
JavaScript
/*! wavesurfer.js 1.3.4 (Sat, 25 Feb 2017 22:02:05 GMT)
* https://github.com/katspaugh/wavesurfer.js
* @license CC-BY-3.0 */!function(a,b){"function"==typeof define&&define.amd?define(["wavesurfer"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("wavesurfer.js")):b(WaveSurfer)}(this,function(a){"use strict";a.Cursor={init:function(a){var b=this;this.wavesurfer=a,this.drawer=this.wavesurfer.drawer,this.wrapper=this.drawer.wrapper,this.wrapper.addEventListener("mousemove",function(a){b.updateCursorPosition(b.drawer.handleEvent(a))}),this.wrapper.addEventListener("mouseenter",function(a){b.showCursor()}),this.wrapper.addEventListener("mouseleave",function(a){b.hideCursor()}),this.cursor=this.wrapper.appendChild(this.drawer.style(document.createElement("wave"),{position:"absolute",zIndex:3,left:0,top:0,bottom:0,width:"0",display:"block",borderRightStyle:"solid",borderRightWidth:"1px",borderRightColor:"black",opacity:".25",pointerEvents:"none"}))},updateCursorPosition:function(a){var b=Math.round(this.drawer.width*a)/this.drawer.params.pixelRatio-1;this.drawer.style(this.cursor,{left:b+"px"})},showCursor:function(){this.drawer.style(this.cursor,{display:"block"})},hideCursor:function(){this.drawer.style(this.cursor,{display:"none"})}},a.util.extend(a.Cursor,a.Observer),a.enableCursor=function(){this.cursor||(this.cursor=Object.create(a.Cursor),this.cursor.init(this))}});