In the vue project, the announcement is implemented to move to the left, and the mouse is still hovering

How to realize the effect of the message announcement gradually moving to the left in the vue project.


The code is as follows (example):

	var demo = document.getElementById("demo");
    var num = 0;
    this.myTime = setInterval(function() {
    
    
        num--;
        demo.style.marginLeft = num + "px";
        if (num <= -800) {
    
    
            num = 0;
        }
    }, 50);
    demo.addEventListener("mouseover", function() {
    
    
        clearInterval(myTime);
    });
    demo.addEventListener("mouseout", function() {
    
    
        myTime = setInterval(function() {
    
    
            num--;
            demo.style.marginLeft = num + "px";
            if (num <= -total) {
    
    
                num = 0;
            }
        }, 50);
    })

Guess you like

Origin blog.csdn.net/qq_42671194/article/details/108659918