irishwill200 irishwill200 - 2 months ago 6
HTML Question

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

I want the text to slide in and then when it gets centered wait for a few then continue and repeat the process. Anyone know how to do this?

Below is my code:

<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>


Then i have JS to do a timer but its not always right since its constantly timing itself:

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

Answer

Here is a code found on 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>