There is a timer. How to make it so that when you hover the mouse over the picture the timer stopped? Need using mousemove .
- oneSo what's the question then? Stop the timer at the event mousemove - Vadim Leshkevich
|
1 answer
var isPause = false, timer = 0; document.getElementById(ид_таймера).addEventListener('mousemove', function() { isPause = true; }); document.getElementById(ид_таймера).addEventListener('mouseout', function() { isPause = false; }) setInterval(function() { if(!isPause) { timer++; }; }, 1); There are isPause and timer variables. If isPause returns false, add to timer 1 (you can use another method). Onmousemove (when the timer is overlaid stop) - isPause => true, onmouseout (when the timer is not reversed) - isPause => false
At leisure, read => https://learn.javascript.ru/introduction-browser-events
- It looks like you have a typo - instead of ID_Timer you most likely have in mind the image element. - A. Gusev
|