Loading icon animation doesn't loop smoothly

Here is my code for the classic rolling dots loading icon
 
[lua]
local w, h = display.contentWidth, display.contentHeight
 
local dots = {}
local loadGroup = display.newGroup()
local n = 8 --number of dots
local del = 100 --delay
local t = del*n
local R, r = 30, 10 --radius of circle and dots
local pi = 3.14159
 
local function loop(i)
    dots[i].alpha=1
    dots[i].xScale=1
    dots[i].yScale=1
    transition.to(dots[i], {time=t, alpha=0, xScale=0.2, yScale=0.2, onComplete=function() loop(i) end})
end
 
for i=1, n do
    dots[i] = display.newCircle(loadGroup, R*math.cos(i*2*pi/n), R*math.sin(i*2*pi/n), r)
 
    dots[i].alpha=i/n
    dots[i].xScale=0.2+0.8*i/n
    dots[i].yScale=0.2+0.8*i/n
 
    transition.to(dots[i], {time=t*i/n, alpha=0, xScale=0.2, yScale=0.2, onComplete=function() loop(i) end})
end
 
loadGroup.x=w*0.5
loadGroup.y=h*0.5
[/lua]
 
It works but after a few laps, it starts to act weird.
I don’t know where the problem lies but if anyone knows of a solution or a separate method, I’d like to know.

By acting weird do you mean it stutters at the last dot?   If so changing the time in the transition on line 15 helps: time=t-200

It doesn’t stutter on my computer. What starts to happen after a while is that dots catch up to other dots and they loop at the same time instead of having a delay. It makes it look like the dots group together instead of spinning smoothly.

Looked like a nice spinner to me.

By acting weird do you mean it stutters at the last dot?   If so changing the time in the transition on line 15 helps: time=t-200

It doesn’t stutter on my computer. What starts to happen after a while is that dots catch up to other dots and they loop at the same time instead of having a delay. It makes it look like the dots group together instead of spinning smoothly.

Looked like a nice spinner to me.