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);
})