Skip to content

Commit

Permalink
Make touch events work a little better
Browse files Browse the repository at this point in the history
  • Loading branch information
crummy committed Aug 28, 2024
1 parent 09ebbc2 commit a6571de
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/components/VisualizationP5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,53 @@ export const VisualizationP5 = (p: p5, element: HTMLElement) => {
newClickListener(p.mouseX, p.mouseY, 0)
}

p.mouseReleased = () => {
p.touchStarted = (event) => {
// todo: should we go fullscreen?
if (!isInitialized) {
isInitialized = true
return
}
if (didClick(resetButton)) {
resetListener()
return
}
for (let instrument of instruments) {
if (didClick(instrument)) {
selectInstrumentListener(instrument.name)
selectedInstrument = instrument.name
return
}
}
if (event instanceof TouchEvent) {
for (let touch of event.changedTouches) {
newClickListener(touch.clientX, touch.clientY, touch.identifier)
}
}
}

p.touchEnded = (event) => {
if (event instanceof TouchEvent) {
for (let touch of event.changedTouches) {
clickStopListener(touch.identifier)
}
}
}

p.mouseReleased = () => {
clickStopListener(0)
}

p.touchMoved = (event) => {
if (!isInitialized) {
return
}
if (event instanceof TouchEvent) {
for (let touch of event.changedTouches) {
drawListener(touch.clientX, touch.clientY, touch.identifier)
}
}
}

p.mouseDragged = () => {
if (!isInitialized) {
return
Expand Down Expand Up @@ -207,4 +247,8 @@ export const VisualizationP5 = (p: p5, element: HTMLElement) => {
updateColumnCount,
updateProgress
}
}

class Ripples {

}

0 comments on commit a6571de

Please sign in to comment.