Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

change transition ms for first span

How can i make the first text in the slideshow to be showen after 300ms?

The transition time is 4 sec for all but i just want the first text to be showen after 300ms and after that everything else can be in transition of 4sec

I don’t want to wait 4 seconds til the slideshow starts

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The setInterval function is for the whole slideshow

setInterval(function(){
  $('.blurtext span.past').removeClass('past');
  $('.blurtext span.active').addClass('past').removeClass('active');
  $('.blurtext span.past + span').addClass('active');
  if ($('.blurtext span.active').length == 0){
    $('.blurtext span:nth-child(1)').addClass('active');
  }
}, 4000);
.blurtext {
  position: relative;
  width: 100vw;
  text-align: center;
  font-size: 10vw;
  height: 10vw;
  text-transform: uppercase;
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  color: #471C1A;
}
.blurtext span {
  position: absolute;
  display: block;
  width: 100%;
  text-align: center;
  opacity: 0;
  transform: perspective(100px) translateZ(10px);
  filter: blur(10px);
  letter-spacing: 0.1em;
}
.blurtext span.active {
  opacity: 1;
  transform: perspective(100px) translateZ(0px);
  filter: blur(0px);
  letter-spacing: 0.15em;
  transition: opacity 2000ms linear, transform 2000ms linear, filter 2000ms linear, letter-spacing 2000ms linear;
}
.blurtext span.past {
  opacity: 0;
  transform: perspective(100px) translateZ(-10px);
  filter: blur(10px);
  letter-spacing: 0.2em;
  transition: opacity 2000ms linear, transform 2000ms linear, filter 2000ms linear, letter-spacing 2000ms linear;
}

.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate3d(-50%, -50%, 0);
}
<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>CodePen - Blur Text Transition</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="./style.css">

</head>
<body>
<!-- partial:index.partial.html -->
<div class="center">
  <div class="blurtext">
    <span>This </span>
    <span>is</span>
    <span>your</span>
    <span>chance</span>
  </div>
</div>
<!-- partial -->
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script><script  src="./script.js"></script>

</body>
</html>

>Solution :

I think it’d work to just call the function initially on a separate timeout:

setTimeout(triggerNextSlide, 1000);

function triggerNextSlide() {
  $('.blurtext span.past').removeClass('past');
  $('.blurtext span.active').addClass('past').removeClass('active');
  $('.blurtext span.past + span').addClass('active');
  if ($('.blurtext span.active').length == 0){
    $('.blurtext span:nth-child(1)').addClass('active');
  }
}

setInterval(triggerNextSlide, 4000);
.blurtext {
  position: relative;
  width: 100vw;
  text-align: center;
  font-size: 10vw;
  height: 10vw;
  text-transform: uppercase;
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  color: #471C1A;
}
.blurtext span {
  position: absolute;
  display: block;
  width: 100%;
  text-align: center;
  opacity: 0;
  transform: perspective(100px) translateZ(10px);
  filter: blur(10px);
  letter-spacing: 0.1em;
}
.blurtext span.active {
  opacity: 1;
  transform: perspective(100px) translateZ(0px);
  filter: blur(0px);
  letter-spacing: 0.15em;
  transition: opacity 2000ms linear, transform 2000ms linear, filter 2000ms linear, letter-spacing 2000ms linear;
}
.blurtext span.past {
  opacity: 0;
  transform: perspective(100px) translateZ(-10px);
  filter: blur(10px);
  letter-spacing: 0.2em;
  transition: opacity 2000ms linear, transform 2000ms linear, filter 2000ms linear, letter-spacing 2000ms linear;
}

.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate3d(-50%, -50%, 0);
}
<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>CodePen - Blur Text Transition</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="./style.css">

</head>
<body>
<!-- partial:index.partial.html -->
<div class="center">
  <div class="blurtext">
    <span>This </span>
    <span>is</span>
    <span>your</span>
    <span>chance</span>
  </div>
</div>
<!-- partial -->
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script><script  src="./script.js"></script>

</body>
</html>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading