From a68aa24a224600c933447deff5de56b2f07c9b3d Mon Sep 17 00:00:00 2001 From: William Toohey Date: Wed, 30 Mar 2016 20:10:24 +1000 Subject: [PATCH] Fix broken invert on some maps --- src/js/HuesCore.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/js/HuesCore.js b/src/js/HuesCore.js index 39f2430..0123878 100644 --- a/src/js/HuesCore.js +++ b/src/js/HuesCore.js @@ -344,7 +344,8 @@ HuesCore.prototype.recalcBeatIndex = function() { let rhythm = this.currentSong.rhythm; let mapSoFar; if(this.beatIndex < 0) { - mapSoFar = build.slice(0, this.beatIndex + build.length); + // Clamp to 0 in case we've juuust started + mapSoFar = build.slice(0, Math.max(this.beatIndex + build.length, 0)); } else { // If the rhythm has an odd number of inverts, don't reset because it // alternates on each loop anyway @@ -765,7 +766,7 @@ HuesCore.prototype.toggleFullAuto = function() { }; HuesCore.prototype.setInvert = function(invert) { - this.invert = invert; + this.invert = !!invert; this.callEventListeners("invert", invert); };