UNPKG

coherent-gameface-interaction-manager

Version:
43 lines (39 loc) 1.49 kB
<!DOCTYPE html> <html lang="en"> <head> <style> body { width: 100vw; margin: 0; padding: 0; height: 100vh; background-color: white; } </style> </head> <body> <h1> Swipe UP to change the background color to a random dark color, swipe DOWN to change to a random light color </h1> <script src="../../dist/touch-gestures.js"></script> <script> touchGestures.swipe({ element: document.body, callback: (direction) => { if (direction === 'top') { const r = Math.floor(Math.random() * 128); const g = Math.floor(Math.random() * 128); const b = Math.floor(Math.random() * 128); document.body.style.backgroundColor = `rgb(${r}, ${g}, ${b})`; } if (direction === 'bottom') { const r = Math.floor(Math.random() * 128) + 128; const g = Math.floor(Math.random() * 128) + 128; const b = Math.floor(Math.random() * 128) + 128; document.body.style.backgroundColor = `rgb(${r}, ${g}, ${b})`; } }, }); </script> </body> </html>