Home > Software engineering >  change transition ms for first span
change transition ms for first span

Time:11-28

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

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

CodePudding user response:

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

  • Related