Answer the question
In order to leave comments, you need to log in
How to pause animation in JS?
There is a code https://jsfiddle.net/hibinyru/549vkdhx/3/ - this is an animation of static images.
Question 1. In this case, how can I pause this animation by clicking on the picture?
Question 2. Why does the animation speed up when the loop is executed several times, the further the faster
Thanks in advance
PS. I'm not very good at JS :( I took the finished code and filed it for myself. I can't write something new
Answer the question
In order to leave comments, you need to log in
pattern = '<[^>]+>'
# выражение означает строку между символами < и >
# квантификатор + - один или более символов
# квантификатор * - ноль или более символов
# квантификатор ? - ноль или один символ
<abc def>
>>> import re
>>> string = '<p style="margin-left:10px;">text<b class="super-bold">bold text</b>.<p>'
>>> string2 = '<abc def>gfh>'
>>> pattern = '<[^>]+>'
>>>
>>> result = re.findall(pattern,string)
>>> print result
['<p style="margin-left:10px;">', '<b class="super-bold">', '</b>', '<p>']
>>>
>>> result2 = re.findall(pattern,string2)
>>> print result2
['<abc def>']
The result gets:
1) character < (<)
2) 1 or more characters other than > ([^>]+)
3) character > (>)
All this based on the regular expression <[^>]+>
<[^>]+>
The answer is simple: after opening, we look for everything that is inside until there is a closure.
those. (this is just an example FOR UNDERSTANDING, and the tag structure here, of course, is not correct):
or <a sdfsd>>>>>
- will be:<a sdfsd>
To “stop” a value, write it to a variable, which will allow you to start counting not from the very beginning. To be able to restore, write your interval to another variable and reset it for those events when you need it.
To eliminate speedup, check if you have a dependency on an incremented value or a nested loop.
function stopAnimation() {
clearInterval(function);
}
And the second, I don't even know how to solve
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question