UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

33 lines (32 loc) 1.01 kB
const STRINGSYNC_RED = 'rgba(252, 53, 76, 0.8)'; export class SimpleCursor { element; constructor(element) { this.element = element; } static render(parent, color = STRINGSYNC_RED) { const element = document.createElement('div'); element.classList.add('vexml-cursor'); element.style.display = 'block'; element.style.position = 'absolute'; element.style.backgroundColor = color; parent.insertBefore(element, parent.firstChild); return new SimpleCursor(element); } /** Moves the cursor's position to the given rect. */ update(opts) { this.element.style.left = `${opts.x}px`; this.element.style.top = `${opts.y}px`; this.element.style.width = `${opts.w}px`; this.element.style.height = `${opts.h}px`; } remove() { this.element.remove(); } show() { this.element.style.display = 'block'; } hide() { this.element.style.display = 'none'; } }