如何在字幕文本居中一些然后继续时停止字幕文本

How to stop marquee text when it gets centered for a few then continue

我希望文本滑入,然后当它居中时等待几秒钟,然后继续并重复该过程。有人知道怎么做吗?

下面是我的代码:

<marquee direction="left" id="artistslide">
    <span id="currentartist"><i class="fa fa-spinner fa-spin"></i></span>
</marquee>

<marquee direction="right" id="currentsongslide">
    <span id="currentsong"><i class="fa fa-spinner fa-spin"></i></span>
</marquee>

然后我有 JS 来做一个计时器,但它并不总是正确的,因为它不断地自己计时:

var start = true;
setInterval(passStartMarquee, 3000 );
// adjust the delay

function passStartMarquee() 
{
    if (start) {
      document.getElementById('currentsongslide').start();
      document.getElementById('artistslide').start();
      start = false;
     } else {
       document.getElementById('currentsongslide').stop();
       document.getElementById('artistslide').stop();
       start = true;
     }     
}

这是在 this tutorial

上找到的代码

.example1 {
  height: 50px;
  overflow: hidden;
  position: relative;
}
.example1 h3 {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: 0;
  line-height: 50px;
  text-align: center;
  /* Starting position */
  -moz-transform: translateX(100%);
  -webkit-transform: translateX(100%);
  transform: translateX(100%);
  /* Apply animation to this element */
  -moz-animation: example1 10s linear infinite;
  -webkit-animation: example1 10s linear infinite;
  animation: example1 10s linear infinite;
}
/* Move it (define the animation) */

@-moz-keyframes example1 {
  0% {
    -moz-transform: translateX(100%);
  }
  40% {
    -moz-transform: translateX(0%);
  }
  60% {
    -moz-transform: translateX(0%);
  }
  100% {
    -moz-transform: translateX(-100%);
  }
}
@-webkit-keyframes example1 {
  0% {
    -webkit-transform: translateX(100%);
  }
  40% {
    -webkit-transform: translateX(0%);
  }
  60% {
    -webkit-transform: translateX(0%);
  }
  100% {
    -webkit-transform: translateX(-100%);
  }
}
@keyframes example1 {
  0% {
    -moz-transform: translateX(100%);
    /* Firefox bug fix */
    -webkit-transform: translateX(100%);
    /* Firefox bug fix */
    transform: translateX(100%);
  }
  40% {
    -moz-transform: translateX(0%);
    /* Firefox bug fix */
    -webkit-transform: translateX(0%);
    /* Firefox bug fix */
    transform: translateX(0%);
  }
  60% {
    -moz-transform: translateX(0%);
    /* Firefox bug fix */
    -webkit-transform: translateX(0%);
    /* Firefox bug fix */
    transform: translateX(0%);
  }
  100% {
    -moz-transform: translateX(-100%);
    /* Firefox bug fix */
    -webkit-transform: translateX(-100%);
    /* Firefox bug fix */
    transform: translateX(-100%);
  }
}
<div class="example1">
  <h3>I'll pause so you can read me.</h3>
</div>

<div class="example1">
  <h3>I'll pause so you can read me.</h3>
</div>