html - How to Stop infinite animation in javascript -
i have develop animation can see below.... animation goes infinite time.. have conditions.. 1.) if click button ball goes , down have stop on default position... 2.)if u click button second time shows 2 balls colliding... how rectify issues through javascript function animationone(cobj) { var circle = document.getelementbyid("circle" + cobj); var h = window.innerheight - 50; var btmpos = 0; var isforward = true; setinterval(function () { if (btmpos < h && isforward) { btmpos += 10; isforward = true; } else { if (btmpos > 20) { isforward = false; btmpos -= 10; } else { btmpos += 10; isforward = true; } } circle.style.bottom = btmpos + "px"; }, 100); }; body{ background-color: gray; position: relative; min-height