HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<head>
<link href='https://fonts.googleapis.com/css?family=Asap:700,700italic' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="background">
<div class="star star-1" id="firststar"></div>
<div class="fof-wrapper">
<div class="animated-bounce mybounce">
<div class="fof-wrapper-inner bounceInLeft">
<img src="http://redonion.se/img/codepen/fof/fof-ball3.png" width="372" height="372" class="fof-ball" />
<div id="fireplace"></div>
</div><!--fof-wrapper-inner-->
</div><!--animated bounce-->
<ul class="flags-wrapper">
<li class="wow slideInLeft"><div class="flag-se"></div></li>
<li><p class="wow flipInY">VS.</p></li>
<li class="wow slideInRight"><div class="flag-ire"></div></li>
<li class="wow slideInUp">MONDAY June 13, 18:00 @ Stade de France</li>
</ul><!--flags-wrapper-->
</div><!--fof-wrapper-->
<h1 class="tlt tlt-top" data-in-effect="flipInY" >EUROPEAN</h1>
<h1 class="tlt" data-in-effect="flipInY">CHAMPIONSHIPS</h1>
</div><!--background-->
</body>
<script src="http://redonion.se/js/vendor/wow/wow.min.js"></script>
<script>
new WOW().init();
</script>
/*Body and Background*/
body{
background-color: #000;
display:block;
width:100%;
height:100vh;
overflow-x: hidden;
}
.background{
background-image:url('http://redonion.se/img/codepen/fof/background-galaxy.jpg');
background-repeat: repeat;
z-index: -1;
width: 100%;
height: 100%;
min-height: 1000px;
position: relative;
background-position: 0px 0px;
animation: animatedBackground 10s linear infinite;
}
@keyframes animatedBackground {
0% { background-position: 0 0; }
100% { background-position: -300px 0; }
}
@-moz-keyframes animatedBackground {
0% { background-position: 0 0; }
100% { background-position: -300px 0; }
}
@-webkit-keyframes animatedBackground {
0% { background-position: 0 0; }
100% { background-position: -300px 0; }
}
@-ms-keyframes animatedBackground {
0% { background-position: 0 0; }
100% { background-position: -300px 0; }
}
@-o-keyframes animatedBackground {
0% { background-position: 0 0; }
100% { background-position: -300px 0; }
}
/*FOF-WRAPPER----------------------------------------*/
.fof-wrapper{
z-index: 10;
top: 50%;
left: 50%;
margin-left: -185px;
margin-top: -185px;
box-sizing:border-box;
position: absolute;
}
/*FOF-WRAPPER-INNER----------------------------------*/
.fof-wrapper-inner:after, .fof-wrapper-inner:before{
width:370px;
height:370px;
border-radius:50%;
content:'';
display:block;
position: absolute;
top: 50%;
left: 50%;
margin-left: -185px;
margin-top: -185px;
animation: fireanimation 1s ease-in-out infinite alternate;
-moz-animation: fireanimation 1s ease-in-out infinite alternate;
-webkit-animation: fireanimation 1s ease-in-out infinite alternate;
-o-animation: fireanimation 1s ease-in-out infinite alternate;
transform:rotate(-90deg);
z-index: 0;
}
.fof-wrapper-inner:before{
animation: fireanimation .65s ease-in-out infinite alternate;
-moz-animation: fireanimation .65s ease-in-out infinite alternate;
-webkit-animation: fireanimation .65s ease-in-out infinite alternate;
-o-animation: fireanimation .65s ease-in-out infinite alternate;
background: -moz-linear-gradient(left, rgba(255,246,204,0.5) 0%, rgba(255,255,255,0) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(left, rgba(255,246,204,0.5) 0%,rgba(255,255,255,0) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right, rgba(255,246,204,0.5) 0%,rgba(255,255,255,0) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#80fff6cc', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 */
z-index: 1;
}
/*FOF-BALL-------------------------------------------*/
.fof-ball{
display:block;
margin:0 auto;
box-sizing:border-box;
-webkit-animation:spin 2s linear infinite;
-moz-animation:spin 2s linear infinite;
animation:spin 2s linear infinite;
}
/*MORE ANIMATIONS--------------------------------------*/
.animated-bounce{
-webkit-animation-duration: 2s;
animation-duration: 2s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
/*ROTATE*/
@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }
@keyframes mybounce {
from, 20%, 53%, 80%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
40%, 43% {
-webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
-webkit-transform: translate3d(0, -40px, 0);
transform: translate3d(0, -40px, 0);
}
70% {
-webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
-webkit-transform: translate3d(0, -30px, 0);
transform: translate3d(0, -30px, 0);
}
90% {
-webkit-transform: translate3d(0,-2px,0);
transform: translate3d(0,-2px,0);
}
}
.mybounce {
-webkit-animation-name: mybounce;
animation-name: mybounce;
-webkit-transform-origin: center bottom;
transform-origin: center bottom;
}
/*bounce in left*/
@keyframes bounceInLeft {
from, 60%, 75%, 90%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
0% {
-webkit-transform: translate3d(-3000px, 0, 0);
transform: translate3d(-3000px, 0, 0);
}
60% {
-webkit-transform: translate3d(25px, 0, 0);
transform: translate3d(25px, 0, 0);
}
75% {
-webkit-transform: translate3d(-10px, 0, 0);
transform: translate3d(-10px, 0, 0);
}
90% {
-webkit-transform: translate3d(5px, 0, 0);
transform: translate3d(5px, 0, 0);
}
to {
-webkit-transform: none;
transform: none;
}
}
.bounceInLeft {
-webkit-animation-name: bounceInLeft;
animation-name: bounceInLeft;
-webkit-animation-duration: 4s;
animation-duration: 4s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
/*FIRE*/
.fire {
animation: fireanimation 1s ease-in-out infinite alternate;
-moz-animation: fireanimation 1s ease-in-out infinite alternate;
-webkit-animation: fireanimation 1s ease-in-out infinite alternate;
-o-animation: fireanimation 1s ease-in-out infinite alternate;
}
@keyframes fireanimation{
0% {box-shadow:
0 -2px 20px rgba(0, 15, 132, 0.72),
0 -15px 15px #fefcc9,
0 5px 5px #feec85,
0 -25px 45px #ffae34,
0 0px 50px #ec760c,
0 0 20px #fefcc9,
10px -10px 30px #feec85,
-20px -20px 40px #ffae34,
20px -40px 50px #ec760c,
-20px -60px 60px #cd4606,
0 -80px 70px #973716,
10px -90px 80px #451b0e;
opacity:0.3;
}
100% {box-shadow:
0 0px 20px rgba(0, 15, 132, 0.72),
0 -10px 15px #fefcc9,
0 5px 2px #feec85,
0 -23px 40px #ffae34,
0 2px 50px #ec760c,
0 0 20px #fefcc9,
10px -10px 30px #fefcc9,
-20px -20px 40px #feec85,
22px -42px 60px #ffae34,
-22px -58px 50px #ec760c,
0 -82px 80px #cd4606,
10px -90px 80px #973716;
opacity:0.65;
}
}
/*STARS-------------------------------------------------------*/
#firststar{
display:none;
}
.star {
width: 1px;
height: 1px;
position: absolute;
border-radius:50%;
z-index: -1;
z-index: 2;
}
.star-1 {
width:5px;height:5px;
background: #999;
box-shadow: 0px 0px 4px rgba(255,255,255,0.8),
0px 0px 12px rgba(255,255,255,0.8),
0px 0px 50px rgba(255,255,255,0.6),
0px 0px 16px rgba(255,255,255,0.6);
background: -moz-radial-gradient(center, ellipse cover, rgba(255,251,153,1) 0%, rgba(255,253,204,0.5) 50%, rgba(255,255,255,0.6) 100%); /* FF3.6-15 */
background: -webkit-radial-gradient(center, ellipse cover, rgba(255,251,153,1) 0%,rgba(255,253,204,0.5) 50%,rgba(255,255,255,0.6) 100%); /* Chrome10-25,Safari5.1-6 */
background: radial-gradient(ellipse at center, rgba(255,251,153,1) 0%,rgba(255,255,255,0.6) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fffb99', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
.star-2 {
background: #aaa;
width:2px;height:2px;
box-shadow: 0px 0px 4px rgba(255,255,255,0.8),
0px 0px 12px rgba(255,255,255,0.8),
0px 0px 50px rgba(255,255,255,0.6),
0px 0px 16px rgba(255,255,255,0.6);
background: -moz-radial-gradient(center, ellipse cover, rgba(255,251,153,1) 0%, rgba(255,253,204,0.5) 50%, rgba(255,255,255,0.6) 100%); /* FF3.6-15 */
background: -webkit-radial-gradient(center, ellipse cover, rgba(255,251,153,1) 0%,rgba(255,253,204,0.5) 50%,rgba(255,255,255,0.6) 100%); /* Chrome10-25,Safari5.1-6 */
background: radial-gradient(ellipse at center, rgba(255,251,153,1) 0%,rgba(255,255,255,0.6) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fffb99', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
.star-3 {
background: #7454ff;
width:3px;height:3px;
box-shadow: 0px 0px 4px rgba(255,255,255,0.8),
0px 0px 12px rgba(255,255,255,0.8),
0px 0px 50px rgba(255,255,255,0.6),
0px 0px 16px rgba(255,255,255,0.6);
background: -moz-radial-gradient(center, ellipse cover, rgba(255,251,153,1) 0%, rgba(255,253,204,0.5) 50%, rgba(255,255,255,0.6) 100%); /* FF3.6-15 */
background: -webkit-radial-gradient(center, ellipse cover, rgba(255,251,153,1) 0%,rgba(255,253,204,0.5) 50%,rgba(255,255,255,0.6) 100%); /* Chrome10-25,Safari5.1-6 */
background: radial-gradient(ellipse at center, rgba(255,251,153,1) 0%,rgba(255,255,255,0.6) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fffb99', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
.star-4 {
background: #ff8282;
width:2px;height:2px;
box-shadow: 0px 0px 4px rgba(255,255,255,0.8),
0px 0px 12px rgba(255,255,255,0.8),
0px 0px 50px rgba(255,255,255,0.6),
0px 0px 16px rgba(255,255,255,0.6);
background: -moz-radial-gradient(center, ellipse cover, rgba(255,251,153,1) 0%, rgba(255,253,204,0.5) 50%, rgba(255,255,255,0.6) 100%); /* FF3.6-15 */
background: -webkit-radial-gradient(center, ellipse cover, rgba(255,251,153,1) 0%,rgba(255,253,204,0.5) 50%,rgba(255,255,255,0.6) 100%); /* Chrome10-25,Safari5.1-6 */
background: radial-gradient(ellipse at center, rgba(255,251,153,1) 0%,rgba(255,255,255,0.6) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fffb99', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
.star-5 {
background: #ccc;
}
.star-6 {
background: #c9c9c9;
}
.star-7 {
background: #d4d4d4;
}
.star-8 {
background: #ddd;
}
.star-9 {
background: #e3e3e3;
}
.star-10 {
background: #fff;
width: 2px;
height: 1px;
}
/*TAIL-------------------------------------------------*/
#fireplace{
position: absolute;
height: auto;
width: auto;
min-height: 370px;
top: 200px;
left: 370px;
z-index: -25;
}
.FireImage{
position: absolute;
top:-550px;
right: 200px;
}
/*TITLE--------------------------------------------------------*/
h1{
margin:0 auto;
padding:1em 0 0 0;
}
.tlt{
font-family:'Asap', Helvetica, Arial, sans-serif;
font-size: 62px;
font-weight: bold;
font-style:italic;
text-align: center;
}
.tlt, .tlt span{
color:#FFF;
background: -webkit-linear-gradient(top, #f5f6f6 0%, #dbdedc 21%, #fff 49%, #787979 80%, #f5f6f6 100%); /* Chrome10-25,Safari5.1-6 */
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.tlt.tlt-top{
font-size: 48px;
margin-bottom:-62px;
}
/*FLAGS--------------------------------------------*/
.flags-wrapper{
list-style-type: none;
color: #FFF;
text-align: center;
width: 100%;
margin:7em auto 0 auto;
padding:0;
position: absolute;
}
.flags-wrapper li{
display: inline-block;
font-family: 'Asap', Helvetica, Arial, sans-serif;
}
.flags-wrapper li p{
font-size: 48px;
font-style: italic;
margin:0 32px;
position: relative;
top: -13px;
}
.flags-wrapper li p,
.flags-wrapper li{
background: -webkit-linear-gradient(top, #f5f6f6 0%, #dbdedc 21%, #fff 49%, #787979 80%, #f5f6f6 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.flags-wrapper li:last-of-type{
display: block;
font-size:18px;
}
.flag-se, .flag-ire{
background-image:url('http://redonion.se/img/codepen/fof/flag-se.jpg');
background-repeat: no-repeat;
background-position: 50% 50%;
background-size: cover;
width: 100px;
height: 60px;
display: block;
}
.flag-ire{
background-image: url('http://redonion.se/img/codepen/fof/flag-ire.jpg');
}
//STARS
var width = $(window).width();
var height = $('.background').height();
var star_count = 200;
var stars = new Array;
for ( i=1; i<= star_count; i++ ) {
var rand_x = Math.floor((Math.random()*width)+1);
var rand_y = Math.floor((Math.random()*height)+1);
var rand_color = Math.floor((Math.random()*10)+1);
var speed = Math.floor((Math.random()*5)+1);
var element = document.createElement('div');
element.className = "star star-" + rand_color;
element.style.left = rand_x + "px";
element.style.top = rand_y + "px";
element.setAttribute("data-speed", speed);
document.body.appendChild( element );
stars[i] = element;
}
window.setInterval(function(){
for ( i=1; i<stars.length; i++ ) {
var left = stars[i].style.left;
if ( left === "0px" ) {
stars[i].style.left = (width - 10) + "px";
} else {
stars[i].style.left = parseInt( left ) - stars[i].getAttribute("data-speed") + "px";
}
}
},1000/60);
//FIRE
var numOfFireElements = 10;
var fireElementImages = [];
var fireElements = [];
loadImages();
initFireAnimation();
function loadImages()
{
for(var i = 1; i < 8; i++)
{
fireElementImages[i] = new Image();
fireElementImages[i].src = "http://redonion.se/img/codepen/fof/fire-" + i + ".png";
fireElementImages[i].id = i;
$(fireElementImages[i]).addClass('FireImage');
$(fireElementImages[i]).load(function()
{
console.log("Image Load Complete: " + this.id);
});
}
}
function initFireAnimation()
{
for(var i = 0; i < numOfFireElements; i++)
{
fireElements[i] = document.createElement('div');
for(var p = 0; p < fireElementImages.length; p++)
{
$(fireElements[i]).append($(fireElementImages[p]).clone(true));
}
$(fireElements[i]).addClass('FireElement');
$(fireElements[i]).css({ left: (i * 2) + "px"});
$('#fireplace').append(fireElements[i]);
loopFireElement(fireElements[i]);
}
}
function loopFireElement($element)
{
var elementImages = $($element).children().toArray();
var randomVisibleElement = Math.floor(Math.random() * fireElementImages.length);
for(var i = 0; i < elementImages.length; i++)
{
if(i != randomVisibleElement)
{
TweenMax.to(elementImages[i], 0, {autoAlpha: 0});
}else
{
TweenMax.to(elementImages[i], 0, {autoAlpha: 1});
}
}
TweenMax.to($element, 0, {scaleX: 0, scaleY: 0, rotation: 0, autoAlpha: 1 });
var animationDuration = Math.random() * 0.4 + 0.4;
var animationDelay = Math.random() * 0.2;
TweenMax.to($element, animationDuration * 0.75, { delay: animationDuration * 0.25 + animationDelay,
autoAlpha: 0});
TweenMax.to($element, animationDuration, { scaleX: Math.random() * 0.6 + 0.4,
scaleY: Math.random() * 0.6 + 0.4,
delay: animationDelay,
onComplete: loopFireElement,
onCompleteParams: [$element]});
}
//TEXTILLATE
/*
* textillate.js
* https://jschr.github.com/textillate
* MIT licensed
*
* Copyright (C) 2012-2013 Jordan Schroter
*/
(function ($) {
"use strict";
function isInEffect (effect) {
return /In/.test(effect) || $.inArray(effect, $.fn.textillate.defaults.inEffects) >= 0;
};
function isOutEffect (effect) {
return /Out/.test(effect) || $.inArray(effect, $.fn.textillate.defaults.outEffects) >= 0;
};
function stringToBoolean(str) {
if (str !== "true" && str !== "false") return str;
return (str === "true");
};
// custom get data api method
function getData (node) {
var attrs = node.attributes || []
, data = {};
if (!attrs.length) return data;
$.each(attrs, function (i, attr) {
var nodeName = attr.nodeName.replace(/delayscale/, 'delayScale');
if (/^data-in-*/.test(nodeName)) {
data.in = data.in || {};
data.in[nodeName.replace(/data-in-/, '')] = stringToBoolean(attr.nodeValue);
} else if (/^data-out-*/.test(nodeName)) {
data.out = data.out || {};
data.out[nodeName.replace(/data-out-/, '')] =stringToBoolean(attr.nodeValue);
} else if (/^data-*/.test(nodeName)) {
data[nodeName.replace(/data-/, '')] = stringToBoolean(attr.nodeValue);
}
})
return data;
}
function shuffle (o) {
for (var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
}
function animate ($t, effect, cb) {
$t.addClass('animated ' + effect)
.css('visibility', 'visible')
.show();
$t.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
$t.removeClass('animated ' + effect);
cb && cb();
});
}
function animateTokens ($tokens, options, cb) {
var that = this
, count = $tokens.length;
if (!count) {
cb && cb();
return;
}
if (options.shuffle) $tokens = shuffle($tokens);
if (options.reverse) $tokens = $tokens.toArray().reverse();
$.each($tokens, function (i, t) {
var $token = $(t);
function complete () {
if (isInEffect(options.effect)) {
$token.css('visibility', 'visible');
} else if (isOutEffect(options.effect)) {
$token.css('visibility', 'hidden');
}
count -= 1;
if (!count && cb) cb();
}
var delay = options.sync ? options.delay : options.delay * i * options.delayScale;
$token.text() ?
setTimeout(function () { animate($token, options.effect, complete) }, delay) :
complete();
});
};
var Textillate = function (element, options) {
var base = this
, $element = $(element);
base.init = function () {
base.$texts = $element.find(options.selector);
if (!base.$texts.length) {
base.$texts = $('<ul class="texts"><li>' + $element.html() + '</li></ul>');
$element.html(base.$texts);
}
base.$texts.hide();
base.$current = $('<span>')
.html(base.$texts.find(':first-child').html())
.prependTo($element);
if (isInEffect(options.in.effect)) {
base.$current.css('visibility', 'hidden');
} else if (isOutEffect(options.out.effect)) {
base.$current.css('visibility', 'visible');
}
base.setOptions(options);
base.timeoutRun = null;
setTimeout(function () {
base.options.autoStart && base.start();
}, base.options.initialDelay)
};
base.setOptions = function (options) {
base.options = options;
};
base.triggerEvent = function (name) {
var e = $.Event(name + '.tlt');
$element.trigger(e, base);
return e;
};
base.in = function (index, cb) {
index = index || 0;
var $elem = base.$texts.find(':nth-child(' + ((index||0) + 1) + ')')
, options = $.extend(true, {}, base.options, $elem.length ? getData($elem[0]) : {})
, $tokens;
$elem.addClass('current');
base.triggerEvent('inAnimationBegin');
base.$current
.html($elem.html())
.lettering('words');
// split words to individual characters if token type is set to 'char'
if (base.options.type == "char") {
base.$current.find('[class^="word"]')
.css({
'display': 'inline-block',
// fix for poor ios performance
'-webkit-transform': 'translate3d(0,0,0)',
'-moz-transform': 'translate3d(0,0,0)',
'-o-transform': 'translate3d(0,0,0)',
'transform': 'translate3d(0,0,0)'
})
.each(function () { $(this).lettering() });
}
$tokens = base.$current
.find('[class^="' + base.options.type + '"]')
.css('display', 'inline-block');
if (isInEffect(options.in.effect)) {
$tokens.css('visibility', 'hidden');
} else if (isOutEffect(options.in.effect)) {
$tokens.css('visibility', 'visible');
}
base.currentIndex = index;
animateTokens($tokens, options.in, function () {
base.triggerEvent('inAnimationEnd');
if (options.in.callback) options.in.callback();
if (cb) cb(base);
});
};
base.out = function (cb) {
var $elem = base.$texts.find(':nth-child(' + ((base.currentIndex||0) + 1) + ')')
, $tokens = base.$current.find('[class^="' + base.options.type + '"]')
, options = $.extend(true, {}, base.options, $elem.length ? getData($elem[0]) : {})
base.triggerEvent('outAnimationBegin');
animateTokens($tokens, options.out, function () {
$elem.removeClass('current');
base.triggerEvent('outAnimationEnd');
if (options.out.callback) options.out.callback();
if (cb) cb(base);
});
};
base.start = function (index) {
setTimeout(function () {
base.triggerEvent('start');
(function run (index) {
base.in(index, function () {
var length = base.$texts.children().length;
index += 1;
if (!base.options.loop && index >= length) {
if (base.options.callback) base.options.callback();
base.triggerEvent('end');
} else {
index = index % length;
base.timeoutRun = setTimeout(function () {
base.out(function () {
run(index)
});
}, base.options.minDisplayTime);
}
});
}(index || 0));
}, base.options.initialDelay);
};
base.stop = function () {
if (base.timeoutRun) {
clearInterval(base.timeoutRun);
base.timeoutRun = null;
}
};
base.init();
}
$.fn.textillate = function (settings, args) {
return this.each(function () {
var $this = $(this)
, data = $this.data('textillate')
, options = $.extend(true, {}, $.fn.textillate.defaults, getData(this), typeof settings == 'object' && settings);
if (!data) {
$this.data('textillate', (data = new Textillate(this, options)));
} else if (typeof settings == 'string') {
data[settings].apply(data, [].concat(args));
} else {
data.setOptions.call(data, options);
}
})
};
$.fn.textillate.defaults = {
selector: '.texts',
loop: false,
minDisplayTime: 2000,
initialDelay: 0,
in: {
effect: 'fadeInLeftBig',
delayScale: 1.5,
delay: 50,
sync: false,
reverse: false,
shuffle: false,
callback: function () {}
},
out: {
effect: 'hinge',
delayScale: 1.5,
delay: 50,
sync: false,
reverse: false,
shuffle: false,
callback: function () {}
},
autoStart: true,
inEffects: [],
outEffects: [ 'hinge' ],
callback: function () {},
type: 'char'
};
}(jQuery));
$(function () {
$('.tlt').textillate();
});
Also see: Tab Triggers