<section id="anim">
<img id="denis" src="https://www.ibisc.univ-evry.fr/~dupont/Images/denis.jpg" alt="me">
</section>
js :
let me = --?-- ;
let body = --?-- ;
let angle = 0, lastTime = null;
let bodyW = body.getBoundingClientRect().width,
bodyMe = me.getBoundingClientRect().width;
function animate(time) {
if (lastTime != null)
angle+= (time - lastTime)* 0.001;
lastTime = time;
--?-- = (Math.cos(angle)* (bodyW-bodyMe)/2)+"px";
--?-- = --?--
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);