Slightly improve performance of stalker award

pull/213/head
Chuck 2023-10-11 23:03:34 -07:00
parent 51b1d5d644
commit bd5323ca01
2 changed files with 10 additions and 6 deletions

View File

@ -2,6 +2,8 @@ img.cursor-stalker {
position: absolute;
height: 28px;
width: 28px;
top: 0;
left: 0;
background-repeat: no-repeat;
background-size: 100% auto;
z-index: 1000000000;

View File

@ -64,8 +64,11 @@ function stalker(i) {
function placestalker(stalker, x, y) {
stalker.x = x;
stalker.y = y;
stalker.img.style.left = stalker.x + "px";
stalker.img.style.top = stalker.y + "px";
const left = stalker.x + "px";
const top = stalker.y + "px";
stalker.img.style.top = `0`;
stalker.img.style.left = `0`;
stalker.img.style.transform = `translate(${left}, ${top})`
}
function makeCircle() {
@ -73,10 +76,9 @@ function makeCircle() {
current -= rotation;
for (let i = count - 1; i > -1; --i) {
stalker = stalkers[i];
stalker.img.style.top =
Math.round(stalker.y + a * Math.sin((current + i) / spacing) - 15) + "px";
stalker.img.style.left =
Math.round(stalker.x + a * Math.cos((current + i) / spacing)) + "px";
const top = Math.round(stalker.y + a * Math.sin((current + i) / spacing) - 15) + "px";
const left = Math.round(stalker.x + a * Math.cos((current + i) / spacing)) + "px";
stalker.img.style.transform = `translate(${left}, ${top})`
}
}