You can position the images using the polar equations of a circumference and make the animation by increasing the angle every so often.
Depending on the speed at which you want it to rotate you can change the variable anguloor the time you want it to update with the setInterval. Depending on the number of images you have and their separation modifies nand r.
Here is an example that you can run:
const circles = document.querySelectorAll('.element')
const n = 6; // numero de circulos
const r = 120 // radio
let angulo = 0;
let originX = circles[0].offsetLeft
let originY = circles[0].offsetTop
setInterval(() => {
angulo += 0.01
circles.forEach((element,i) =>{
element.style.left = `${originX + r*Math.cos(angulo + 2*Math.PI/n*i)}px`
element.style.top = `${originY + r*Math.sin(angulo + 2*Math.PI/n*i)}px`})
},20)
You can position the images using the polar equations of a circumference and make the animation by increasing the angle every so often.
Depending on the speed at which you want it to rotate you can change the variable
angulo
or the time you want it to update with thesetInterval
. Depending on the number of images you have and their separation modifiesn
andr
.Here is an example that you can run: