better spinning
This commit is contained in:
parent
ea44ba4440
commit
de8a561eda
14
script.js
14
script.js
|
@ -97,12 +97,14 @@ spinBtn.addEventListener("click", () => {
|
|||
|
||||
console.log(target)
|
||||
|
||||
let degrees = 360 / display.length;
|
||||
|
||||
let rotationInterval = window.setInterval(() => {
|
||||
spinAmount *= 0.99
|
||||
if (slowing_down) {
|
||||
spinAmount = Math.max(0.1, spinAmount)
|
||||
} else {
|
||||
spinAmount = Math.max(2.5, spinAmount)
|
||||
spinAmount = Math.max(4, spinAmount)
|
||||
}
|
||||
|
||||
spinChart.options.rotation += spinAmount;
|
||||
|
@ -111,18 +113,20 @@ spinBtn.addEventListener("click", () => {
|
|||
if (spinChart.options.rotation >= 360) {
|
||||
spinChart.options.rotation -= 360;
|
||||
}
|
||||
if (spinAmount <= 4 && target.minDegree - 20 <= 360-spinChart.options.rotation && 360-spinChart.options.rotation < target.maxDegree-target_degree) {
|
||||
if (spinAmount <= 5 && target.minDegree <= 360-spinChart.options.rotation && 360-spinChart.options.rotation < target.maxDegree - target_degree + (degrees/2) ) {
|
||||
//console.log(target_degree);
|
||||
console.log(spinAmount + " Decreasing more")
|
||||
slowing_down = true;
|
||||
spinAmount *= 0.8
|
||||
|
||||
spinAmount *= 0.9
|
||||
|
||||
if (spinAmount <= 0.1 && target.minDegree <= 360-spinChart.options.rotation && 360-spinChart.options.rotation < target.maxDegree-target_degree) {
|
||||
// spinChart.options.rotation = target_degree
|
||||
spinChart.update()
|
||||
text.innerHTML = `<p>Gruppe nummer ${target.value} skal præsentere!</p>`;
|
||||
clearInterval(rotationInterval);
|
||||
spinBtn.disabled = false;
|
||||
} else if (target.minDegree + 1 > 360-spinChart.options.rotation) {
|
||||
spinAmount = 0;
|
||||
console.log("halting");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user