diff --git a/index.html b/index.html index 5233f96..30671a1 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,8 @@ var poisson = poissons[poissons.length-1] poisson.style.top = coord_map.top; poisson.style.left = coord_map.left + (coord_map.width-poisson.getBoundingClientRect().width)*Math.random(); + poisson.setAttribute("pos", poisson.style.left.replace("px", "")); + poisson.setAttribute("i", 0); }, 1000); input.onkeyup = () => { @@ -52,6 +54,8 @@ var p = poissons[i]; var new_top = parseInt(p.style.top.replace("px", "")) + 10; p.style.top = new_top; + p.setAttribute("i", parseInt(p.getAttribute("i")) + 1); + p.style.left = parseInt(p.getAttribute('pos')) + Math.sin(parseInt(p.getAttribute('i')))*10; if (new_top > coord_map.height + coord_map.top - p.getBoundingClientRect().height) { p.remove(); }