I wanted to make a simple temporary "Happy 2017" page on my site, and I've found on Code.pen a JS code for fireworks that looked pretty interesting:
https://codepen.io/chuongdang/pen/yzpDG
The code works wonderfully with a mouse, as the firework explodes exactly where you clicked, but it doesn't work at all with touch commands, making it not interactive at all on touch screens. I can see that the code calls mousedown, mousemove and mouseup events, but not touchstart and touchend:
if( timerTick >= timerTotal ) {
if( !mousedown ) {
fireworks.push( new Firework( cw / 2, ch, random( 0, cw ), random( 0, ch / 2 ) ) );
timerTick = 0;
}
} else {
timerTick++;
}
if( limiterTick >= limiterTotal ) {
if( mousedown ) {
fireworks.push( new Firework( cw / 2, ch, mx, my ) );
limiterTick = 0;
}
} else {
limiterTick++;
}
I guess that's the problem, but being a complete JS noob I lack the knowledge to make it recognize touch coordinates. Is there a simple way to do so?