S
S
Sergey Burduzha2018-01-29 00:49:09
JavaScript
Sergey Burduzha, 2018-01-29 00:49:09

Why is clearInterval not working?

I created a simple slider https://jsfiddle.net/serii/otoj13zn/1/
By clicking on the picture, setInterval is launched, and the active class is set to the parent.
If I click again, the active class is removed, and setInterval should clear and the sliders should end.
But clearInterval doesn't work.
Does anyone have time to take a look?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2018-01-29
@serii81

It is necessary to split the loopSlider into two different functions:
1. Switching the state on click (toggle)
2. Timer function with a global timer identifier (animation / animation frame function)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question