The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Can’t make circle to move Re: Can’t make circle to move


Hi guys, I don’t want to start new discussion and decided to continuing in the same. After circle started to move( with your greate help) and now i want it to stop. This is snippet of my function

var circle = document.getElementById("circle"),
computedStyle = window.getComputedStyle(circle, ""),
bodyWidth = document.body.clientWidth,
speed = 10,
step = 2,

function moveCircleLeft() {

var currentMarginLeft = parseInt(computedStyle.marginLeft);

if (currentMarginLeft < bodyWidth) {
timerLeft = setInterval(moveLeft, speed);
} else {

function moveLeft() {
currentMarginLeft += step; = currentMarginLeft + "px";

window.addEventListener("click", moveCircleLeft, false);

I think the problem in condition **(currentMarginLeft < bodyWidth)** Thanks for the help and I really red with shame