Skip to content

Commit

Permalink
improved lightshow
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Aug 15, 2024
1 parent 4a4bc75 commit f306e3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
21 changes: 10 additions & 11 deletions docs/assets/js/initLightshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@ document.addEventListener('DOMContentLoaded', function() {
const lightshow = new Lightshow(vortexLib, canvasId, options);
lightshow.start(); // Start the animation

// Get the press and release buttons
const pressButton = document.getElementById('vortex-press-button');
const releaseButton = document.getElementById('vortex-release-button');
const canvas = document.getElementById(canvasId);

// Connect the pressButton and releaseButton methods in Lightshow.js
pressButton.addEventListener('mousedown', function() {
lightshow.pressButton(); // Call pressButton when the button is pressed
// Handle mouse/touch press on the canvas
canvas.addEventListener('mousedown', function() {
lightshow.pressButton(); // Call pressButton on canvas mousedown
});

releaseButton.addEventListener('mouseup', function() {
lightshow.releaseButton(); // Call releaseButton when the button is released
// Handle mouse/touch release on the canvas
canvas.addEventListener('mouseup', function() {
lightshow.releaseButton(); // Call releaseButton on canvas mouseup
});

// Optionally handle touch events for mobile
pressButton.addEventListener('touchstart', function() {
// Handle touch events for mobile
canvas.addEventListener('touchstart', function() {
lightshow.pressButton(); // Call pressButton on touchstart
});

releaseButton.addEventListener('touchend', function() {
canvas.addEventListener('touchend', function() {
lightshow.releaseButton(); // Call releaseButton on touchend
});
});
Expand Down
5 changes: 4 additions & 1 deletion docs/led_selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ The led selection is always the first step after entering one of these menus.

<div id="lightshow-container" style="width: 100%; height: 400px;">
<canvas id="vortex-canvas"></canvas>
</div>
</div>

<button id="vortex-press-button">Press</button>
<button id="vortex-release-button">Release</button>

0 comments on commit f306e3d

Please sign in to comment.