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)
|
console.log(target)
|
||||||
|
|
||||||
|
let degrees = 360 / display.length;
|
||||||
|
|
||||||
let rotationInterval = window.setInterval(() => {
|
let rotationInterval = window.setInterval(() => {
|
||||||
spinAmount *= 0.99
|
spinAmount *= 0.99
|
||||||
if (slowing_down) {
|
if (slowing_down) {
|
||||||
spinAmount = Math.max(0.1, spinAmount)
|
spinAmount = Math.max(0.1, spinAmount)
|
||||||
} else {
|
} else {
|
||||||
spinAmount = Math.max(2.5, spinAmount)
|
spinAmount = Math.max(4, spinAmount)
|
||||||
}
|
}
|
||||||
|
|
||||||
spinChart.options.rotation += spinAmount;
|
spinChart.options.rotation += spinAmount;
|
||||||
|
@ -111,18 +113,20 @@ spinBtn.addEventListener("click", () => {
|
||||||
if (spinChart.options.rotation >= 360) {
|
if (spinChart.options.rotation >= 360) {
|
||||||
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")
|
console.log(spinAmount + " Decreasing more")
|
||||||
slowing_down = true;
|
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) {
|
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()
|
spinChart.update()
|
||||||
text.innerHTML = `<p>Gruppe nummer ${target.value} skal præsentere!</p>`;
|
text.innerHTML = `<p>Gruppe nummer ${target.value} skal præsentere!</p>`;
|
||||||
clearInterval(rotationInterval);
|
clearInterval(rotationInterval);
|
||||||
spinBtn.disabled = false;
|
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