Fixed step forward/backward issues with repeating cycles.

This commit is contained in:
William Brawner 2015-11-22 00:31:20 -06:00
parent 7ff49cbde0
commit 0a35efcfbb
8 changed files with 66 additions and 29 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -173,17 +173,17 @@ a:link, a:hover, a:visited, a:active {
to {right: 100%;}
}
.slideIn {
-moz-animation: slideIn 0.1s ease-in;
-webkit-animation: slideIn 0.1s ease-in;
-o-animation: slideIn 0.1s ease-in;
animation: slideIn 0.1s ease-in;
-moz-animation: slideIn 0.25s ease-in;
-webkit-animation: slideIn 0.25s ease-in;
-o-animation: slideIn 0.25s ease-in;
animation: slideIn 0.25s ease-in;
right: 0;
}
.slideOut {
-moz-animation: slideOut 0.1s ease-out;
-webkit-animation: slideOut 0.1s ease-out;
-o-animation: slideOut 0.1s ease-out;
animation: slideOut 0.1s ease-out;
-moz-animation: slideOut 0.25s ease-out;
-webkit-animation: slideOut 0.25s ease-out;
-o-animation: slideOut 0.25s ease-out;
animation: slideOut 0.25s ease-out;
right: 100%;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

View file

@ -43,12 +43,12 @@
}
};
$scope.timer = getSavedTimer();
console.log($scope.timer);
$scope.lowIntensityBeep = new Audio('audio/beep-09.mp3');
$scope.highIntensityBeep = new Audio('audio/button-42(1).mp3');
$scope.coolDownBeep = new Audio('audio/beep-10.mp3');
$scope.warmUp = true;
$scope.round = 1;
$scope.cycle = 1;
$scope.time = $scope.timer.warmUpTime;
$scope.settingsOpen = false;
$scope.closeSettings = false;
@ -79,6 +79,24 @@
$scope.highIntensityBeep.play();
$scope.startTimer();
}
$scope.startWarmUp = function() {
if ($scope.time == 0) {
$scope.warmUp = false;
$scope.setHighIntensity();
};
$scope.$apply(function() {
$scope.time--;
});
};
$scope.startCoolDown = function() {
if ($scope.time == 0) {
$scope.coolDown = false;
$scope.resetTimer();
};
$scope.$apply(function() {
$scope.time--;
});
};
$scope.startLowIntensity = function() {
if ($scope.time == 0) {
$scope.lowIntensity = false;
@ -89,31 +107,36 @@
});
};
$scope.startHighIntensity = function() {
if ($scope.time == 0) {
$scope.round++;
$scope.highIntensity = false;
if ($scope.round < $scope.timer.cycles) {
$scope.setLowIntensity();
} else {
$scope.cycle++;
if ($scope.cycle < $scope.timer.repeat) {
$scope.warmUp = true;
} else {
$scope.coolDown = true;
}
}
};
$scope.$apply(function() {
$scope.time--;
});
if ($scope.time == 0) {
$scope.round++;
$scope.highIntensity = false;
console.log("This runs");
if ($scope.round < $scope.timer.cycles) {
$scope.setLowIntensity();
} else {
$scope.cycle++;
// console.log($scope.cycle);
// console.log($scope.timer.repeat);
if ($scope.cycle < $scope.timer.repeat) {
$scope.warmUp = true;
$scope.setWarmUp();
} else {
$scope.coolDown = true;
$scope.setCoolDown();
}
}
};
$scope.$apply(function() {
$scope.time--;
});
};
$scope.startTimer = function() {
$scope.timerActive = true;
if ($scope.warmUp) {
$scope.countdown = setInterval($scope.startHighIntensity, 1000);
$scope.countdown = setInterval($scope.startWarmUp, 1000);
}
if ($scope.coolDown) {
$scope.countdown = setInterval($scope.startHighIntensity, 1000);
$scope.countdown = setInterval($scope.startCoolDown, 1000);
}
if ($scope.highIntensity) {
$scope.countdown = setInterval($scope.startHighIntensity, 1000);
@ -127,6 +150,14 @@
clearInterval($scope.countdown);
};
$scope.stepBack = function() {
if ($scope.warmUp) {
if ($scope.cycle != 1) {
$scope.warmUp = false;
$scope.cycle--;
$scope.setHighIntensity();
return;
};
};
if ($scope.lowIntensity) {
$scope.lowIntensity = false;
if ($scope.round == 1) {
@ -161,9 +192,14 @@
};
if ($scope.highIntensity) {
$scope.highIntensity = false;
if ($scope.round == $scope.timer.cycles) {
if ($scope.round == $scope.timer.cycles && $scope.cycle == $scope.timer.repeat) {
$scope.setCoolDown();
return;
} else if ($scope.round == $scope.timer.cycles && $scope.cycle < $scope.timer.repeat) {
$scope.cycle++;
$scope.round = 1;
$scope.setWarmUp();
return;
}
$scope.setLowIntensity();
$scope.round++;
@ -174,6 +210,7 @@
clearInterval($scope.countdown);
$scope.timerActive = false;
$scope.round = 1;
$scope.cycle = 1;
$scope.lowIntensity = false;
$scope.highIntensity = false;
$scope.coolDown = false;