JSFiddle - React, Tailwind, and code Playground
by Keith Jeter
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css">
<div class="circ_wrap">
<div class="gods_logo pulse"></div>
<span class="cd-intro">
<h1 class="cd-headline zoom flt">
<span class="cd-words-wrapper">
<b class="is-visible">MEN</b>
<b>WOMEN</b>
<b>KIDS</b>
<b>EVERYONE</b>
</span>
</h1>
</span>
<div class="circ_circ"></div>
</div>
SCSS
.circ_wrap {
position: relative;
width: 300px;
height: 300px;
margin: 20px auto;
overflow: hidden;
.gods_logo {
position: absolute;
width: 200px;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
top: 77px;
content: url(http://galnova.com/A20/gods-v-logo.png);
}
.circ_circ {
width: 100%;
height: 100%;
content: url(http://galnova.com/A20/circ-circ.png);
-webkit-animation: spinn 20s infinite linear;
}
}
@-webkit-keyframes spinn {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
.pulse {
cursor: pointer;
box-shadow: 0 0 0 rgba(204,169,44, 0.4);
animation: pulse 2s infinite;
}
.pulse:hover {
animation: none;
}
/* -------------------------- */
/* --------------------------------
Primary style
-------------------------------- */
.cd-title {
position: relative;
height: 160px;
line-height: 230px;
text-align: center;
}
.cd-title h1 {
font-size: 2.4rem;
font-weight: 700;
}
@media only screen and (min-width: 768px) {
.cd-title {
line-height: 250px;
}
}
@media only screen and (min-width: 1170px) {
.cd-title {
height: 200px;
line-height: 300px;
}
.cd-title h1 {
font-size: 3rem;
}
}
.cd-intro {
/* width: 90%;
max-width: 768px; */
text-align: center;
}
.cd-intro {
/* margin: 4em auto; */
}
@media only screen and (min-width: 768px) {
.cd-intro {
/* margin: 5em auto; */
}
}
@media only screen and (min-width: 1170px) {
.cd-intro {
/* margin: 6em auto; */
}
}
.cd-headline {
font-size: 3rem;
line-height: 1.2;
}
@media only screen and (min-width: 768px) {
.cd-headline {
font-size: 4.4rem;
font-weight: 300;
}
}
@media only screen and (min-width: 1170px) {
.cd-headline {
font-size: 6rem;
}
}
.cd-words-wrapper {
display: inline-block;
position: relative;
text-align: left;
}
.cd-words-wrapper b {
display: inline-block;
position: absolute;
white-space: nowrap;
...
JavaScript
jQuery(document).ready(function($){
//set animation timing
var animationDelay = 2500,
//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 = 1500;
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'));
}
function singleLetters($words) {
$words.each(function(){
var word = $(this),
letters = word.text().split(''),
selected = word.hasClass('is-visible');
for (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);
if(headline.hasClass('loading-bar')) {
duration = barAnimationDelay;
setTimeout(function(){ headline.find('.cd-words-wrapper').addClass('is-loading') }, barWaiting);
} else if (headline.hasClass('clip')){
var spanWrapper = headline.find('.cd-words-wrapper'),
newWidth = spanWrapper.width() + 10
spanWrapper.css('width', newWidth);
} else if (!headline.hasClass('type') ) {
//assign to .cd-words-wrapper the width of its longest word
var words = headline.find('.cd-words-wrapper b'),
width = 0;
words.each(function(){
var wordWidth = $(this).width();
if (wordWidth > width) width =...