<i style="--x:300px;--y:100px;"></i>

<button> Run the animation</button>

<div class="panel">
<div>Duration of X: <input type="range" min="0" max="1" step="0.1" value="1" name="Dx"></div>
<div>Duration of Y: <input type="range" min="0" max="1" step="0.1" value="0.5" name="Dy"></div>
</div>


<div class="debug"></div>
i{
  position:fixed;
  width:50px;
  height:50px;
  border-radius:50%;
  background:radial-gradient(at 30% 30%,#0000,#000a) red;
  left:var(--x);
  top: var(--y);
}
.start i {
  animation: x var(--dx,1s), y var(--dy,0.5s);
  animation-timing-function:cubic-bezier(.5,-1000,.5,1000);
  animation-iteration-count:infinite;
}

@keyframes x { to { left:calc(var(--x) + 1px); } }
@keyframes y { to { top :calc(var(--y) + 0.2px); } }


/**/
d {position:fixed;height:4px;width:4px;background:#222;border-radius:50%}
button {border:none;border-radius:10px;padding:10px 20px;cursor:pointer;position:fixed;bottom:20px;right:20px;font-family:sans-serif;font-size:30px;background:#c82629;color:#fff;}
.panel {position: fixed;top: 20px;right: 20px;padding: 10px;border: 1px solid;border-radius: 10px;background: #0001;font-family: sans-serif;}
.panel div:first-child {border-bottom: 1px solid;padding-bottom: 10px;margin-bottom: 10px;}
let elem = document.querySelector('i');
let start;

function debug(timestamp) {
  if (start === undefined)
    start = timestamp;
  const elapsed = timestamp - start;
  let rect = elem.getBoundingClientRect();
  document.querySelector('.debug').insertAdjacentHTML("afterbegin",'<d style="top:'+(rect.y + rect.height/2)+'px;left:'+(rect.x + rect.width/2)+'px;"></d>')

  if (elapsed < 10000) { 
    window.requestAnimationFrame(debug);
  }
}

function clear() {
	document.querySelector('.debug').innerHTML="&nbsp;";
  start=undefined;
  window.requestAnimationFrame(debug);
}


document.querySelector('[name=Dx]').addEventListener('change', function() {
  elem.style.setProperty("--dx", this.value+"s");
  clear()
});
document.querySelector('[name=Dy]').addEventListener('change', function() {
  elem.style.setProperty("--dy", this.value+"s");
  clear()
});
document.querySelector("button").addEventListener("click",function() {
  document.body.classList.add("start");
  window.requestAnimationFrame(debug);
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.