0

Function loop

Hi. Textmirror function smoothly changes the opacity of the text once to zero and back to one. If it is applied, as in line 36, then everything will be fine, but if you combine it with other functions, it goes into an infinite loop. I do not understand how why. https://code.sololearn.com/WaW0uMFEgKb1/?ref=app

1st Jan 2018, 1:29 PM
Илья Ланин
Илья Ланин - avatar
3 odpowiedzi
+ 13
I once had that problem too. Use a control variable to decide if the signum of the opacity change will be positive or negative. Or use it as a sign whether the opacity change has endes and start next one afterwards...
1st Jan 2018, 1:37 PM
Valen.H. ~
Valen.H. ~ - avatar
0
I found... There is a saying in Russian programmers:"global variables are evil". This is the case). Twice used one variable
1st Jan 2018, 2:27 PM
Илья Ланин
Илья Ланин - avatar
0
By the way do you know how to assign variables inside the function when using the "setInterval"? If you do so, then with each call, the variables will be reset to the initial values .
1st Jan 2018, 2:34 PM
Илья Ланин
Илья Ланин - avatar