Animated Hero Text

by dledle2

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div id="highlighted">
   <div id="search-form" class="container">
      <div class="row">
         <div class="col-sm-12">
            <div class="mod-search block">
               <h1 class="home-image">
                  <img alt="WebCorpCo" class="img-responsive" src="https://www.solodev.com/assets/hero-form/logo2.png">
               </h1>
               <h2 class="home-title">
                  <section class="cd-intro" style="user-select: auto;">
                     <h2 class="cd-headline clip is-full-width font-accident-two-normal uppercase" style="user-select: auto;">
                        <span style="user-select: auto;">The Company of Choice for </span>
                        <span class="cd-words-wrapper" style="width: 81.5142px; user-select: auto; overflow: hidden;">
                        <b class="is-visible" style="user-select: auto;">Marketing</b>
                        <b class="is-hidden" style="user-select: auto;">Design</b>
                        <b class="is-hidden" style="user-select: auto;">Programming</b>
                        <b class="is-hidden" style="user-select: auto;">Training</b>
                        </span>
                     </h2>
                  </section>
               </h2>
               <div class="block-content">
                  <form action="#" class="hero-form form-inline" id="hero-form" method="post" role="form">
                     <div class="form-group">
                        <label class="control-label sr-only" for="services-select">Choose Type of Service</label> 
                        <select>
                           <option value="">
                              Choose Type of Service
                          ...

CSS

#search-form {
    top: 50%;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
}
#search-form {
    position: absolute;
    top: 250px;
    left: 0;
    right: 0;
    background-color: #2e2e2e;
    background-color: rgba(46,46,46,0.85);
    max-width: 800px;
    padding: 20px 20px 0;
    text-align: center;
    z-index: 1;
}
.home-image {
    text-align: center;
}
.home-title {
    font-family: Arial, Helvetica, Sans-Serif;
    color: #fff;
    font-weight: normal;
    text-align: center;
}
h2.home-title {
  font-size: 30px;
  margin-bottom: 10px;
}
h3.home-title {
  font-size: 17px;
  margin-top: 40px;
  
}
.home-title a {
  color: #22adea;
  text-decoration: none;
  transition: all 0.25s ease-in-out;
}
.home-title a:hover {
  color: #F0AD4E;
}
h1.home-image img {
    margin: 0 auto;
}
.img-responsive {
    display: block;
    max-width: 100%;
    height: auto;
}
.mod-search {
    padding-bottom: 30px;
}
.mod-search .block-content {
    padding-top: 10px;
}
.block .block-content {
    padding-top: 18px;
    clear: both;
}
.hero-form select {
    height: 38px;
    margin: 0 10px 0 0;
    border-radius: 0;
}
.hero-form input[type=text] {
    height: 38px;
    margin: 0 10px 0 0;
    border-radius: 0;
}
.hero-form input[type=submit] {
    font-size: 14px;
    background-color: #F0AD4E;
    height: 38px;
    border-radius: 0;
}
.heroimage {
    margin-bottom: 0px;
	background-image: url(https://www.solodev.com/assets/hero-form/hero-image.jpg);
	background-size: cover;
	width: 100%;
    min-height: 500px;
}
@media screen and (max-width: 768px) {
    .hero-form select {
	  width: 100%;
	}
}
body {
  display: block;
  background-color: #e7e7e7;
  overflow-x: hidden;
  overflow-y: auto;
  color: #2f2f2f;
  font: 13px/1.7 "Raleway", sans-serif;
  font-weight: 400;
  letter-spacing: 1px;
  -webkit-font-smoothing: antialiased;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
 ...

JavaScript

$(document).ready(function () {

	(function () {
            //set animation timing
            var animationDelay = 3500,
            //loading bar effect
                barAnimationDelay = 3800,
                barWaiting = barAnimationDelay - 3000, //3000 is the duration of the transition on the loading bar - set in the scss/css file
            //letters effect
                lettersDelay = 50,
            //type effect
                typeLettersDelay = 150,
                selectionDuration = 500,
                typeAnimationDelay = selectionDuration + 800,
            //clip effect
                revealDuration = 600,
                revealAnimationDelay = 2500;

            initHeadline();


            function initHeadline() {
                //insert <i> element for each letter of a changing word
                singleLetters($('.cd-headline.letters').find('b'));
                //initialise headline animation
                animateHeadline($('.cd-headline'));
                //set basic width on load
                $('.cd-words-wrapper').css('width', '200px');
            }

            function singleLetters($words) {
                $words.each(function(){
                    var word = $(this),
                        letters = word.text().split(''),
                        selected = word.hasClass('is-visible');
                    for (var i in letters) {
                        if(word.parents('.rotate-2').length > 0) letters[i] = '<em>' + letters[i] + '</em>';
                        letters[i] = (selected) ? '<i class="in">' + letters[i] + '</i>': '<i>' + letters[i] + '</i>';
                    }
                    var newLetters = letters.join('');
                    word.html(newLetters).css('opacity', 1);
                });
            }

            function animateHeadline($headlines) {
                var duration = animationDelay;
                $headlines.each(function(){
                    var headline = $(this);

        ...