MCPcopy Create free account
hub / github.com/atomic14/ch32v003-audio / setupClickHandler

Method setupClickHandler

buzzer-studio/src/visualizer.ts:49–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47 }
48
49 private setupClickHandler() {
50 this.canvas.addEventListener('click', (e) => {
51 if (this.duration === 0) return;
52
53 const rect = this.canvas.getBoundingClientRect();
54 const clickX = e.clientX - rect.left + this.canvas.parentElement!.scrollLeft;
55
56 const padding = this.options.compact ? 10 : 40;
57 const leftPadding = this.options.showLabels ? padding : 10;
58 const timelineWidth = this.canvas.width - leftPadding - padding;
59 const relativeX = clickX - leftPadding;
60
61 if (relativeX >= 0 && relativeX <= timelineWidth) {
62 const clickedTime = (relativeX / timelineWidth) * this.duration;
63 this.currentTime = clickedTime;
64 this.draw();
65
66 if (this.onSeek) {
67 this.onSeek(clickedTime);
68 }
69 }
70 });
71 }
72
73 resize() {
74 const parent = this.canvas.parentElement;

Callers 1

constructorMethod · 0.95

Calls 1

drawMethod · 0.95

Tested by

no test coverage detected