JSFiddle - React, Tailwind, and code Playground
HTML
<article class="timeline">
<!-- Loading -->
<div class="loading">
<div class="l-loader">
<div class="l-outercircle">
<div class="l-whitecircle"></div>
</div>
<div class="l-text">
<div class="l-text-1">Vennligst vent</div>
<div class="l-text-2">Laster bilder</div>
</div>
</div>
</div>
<div class="tl-footer">
<section class="tl-content">
<div class="wrapper">
<h1>Modnere</h1>
<p>Below is a short explanation of how the Pixastic library works and how to use it. There are also pages with details on the individual actions and effects available through Pixastic. These pages also feature small live demos where you can see the library in action.</p>
</div>
</section>
<nav class="tl-chapters">
<ul class="tl-nodes">
<li data-title="Header 1" data-titlestart="Header 1" data-titleend="Header 1" data-duration="2"><div class="node"></div><div class="text">Aenean dictum turpis imperdiet felis euismod et egestas metus mollis. Maecenas semper est a nisl condimentum pulvinar. Mauris eleifend condimentum turpis, aliquam lobortis lacus vulputate tincidunt.</div></li><li data-title="Header 2" data-titlestart="Header 2" data-titleend="Header 2" data-duration="2"><div class="node"></div><div class="text">Aenean dictum turpis imperdiet felis euismod et egestas metus mollis. Maecenas semper est a nisl condimentum pulvinar. Mauris eleifend condimentum turpis, aliquam lobortis lacus vulputate tincidunt.</div></li><li data-title="Header 3" data-titlestart="Header 3" data-titleend="Header 3" data-duration="2"><div class="node"></div><div class="text">Aenean dictum turpis imperdiet felis euismod et egestas metus mollis. Maecenas semper est a nisl condimentum pulvinar. Mauris eleifend condimentum turpis, aliquam lobortis lacus vulputate tincidunt.</div></li><li data-title="Header 4" data-titlestart="Header 4" data-titleend="Header 4" data-duration="2"><div class="node"></div><div class="text">Aenean dictum turpis imperdiet...
CSS
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/*! normalize.css v1.0.1 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/*
* Corrects `block` display not defined in IE 6/7/8/9 and Firefox 3.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section,
summary {
display: block;
}
/*
* Corrects `inline-block` display not defined in IE 6/7/8/9 and Firefox 3.
*/
audio,
canvas,
video {
display: inline-block;
*display: inline;
*zoom: 1;
}
/*
* Prevents modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/*
* Addresses styling for `hidden` attribute not present in IE 7/8/9, Firefox 3,
* and Safari 4.
* Known issue: no IE 6 support.
*/
[hidden] {
display: none;
}
/* ==========================================================================
Base
========================================================================== */
/*
* 1. Corrects text resizing oddly in IE 6/7 when body `font-size` is set using
* `em` units.
* 2. Prevents iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-size: 100%;
/* 1 */
-webkit-text-size-adjust: 100%;
/* 2 */
-ms-text-size-adjust: 100%;
/* 2 */
}
/*
* Addresses `font-family` inconsistency between `textarea` and other form
* elements.
*/
html,
button,
input,
select,
textarea {
font-family: sans-serif;
}
/*
* Addresses margins handled incorrectly in IE 6/7.
*/
body {
margin: 0;
}
/* ==========================================================================
Links
...
JavaScript
var config = {};
$(document).ready(function(){
config.window = $(window);
config.document = $(document);
config.body = $("body");
config.wWidth = config.window.width();
config.wHeight = config.window.height() - 90;
config.window.on("resize", function(){
config.wWidth = config.window.width();
config.wHeight = config.window.height() - 90;
resizeWindow();
});
// Timeline
config.timeline = new timeLine();
//resizeWindow();
});
/* TimeLine */
function timeLine(){
config.currentChapter = 0;
initTimeline();
// Set clip to loading div
TweenMax.to('.loading', 0, { clip: "rect(0 " + config.wWidth + "px " + config.wHeight + "px 0px)" });
// Start loading animation
TweenMax.to('.l-whitecircle', 1, {
scale: 0,
repeat: -1,
yoyo: true,
ease:Power2.easeInOut
});
var loadingTL = new TimelineMax({repeat: -1, ease:Power2.easeInOut});
loadingTL.to('.l-text-1', 1, { autoAlpha: 1, delay: 0.5});
loadingTL.to('.l-text-1', 1, { autoAlpha: 0, delay: 0.5});
loadingTL.to('.l-text-2', 1, { autoAlpha: 1, delay: 0.5});
loadingTL.to('.l-text-2', 1, { autoAlpha: 0, delay: 0.5});
// Set timeline footer pos
TweenMax.to('.tl-footer', 0, { y: +70 });
// Preload images
TweenMax.to('.loading', 1, {
clip: "rect(" + config.wHeight / 2 + "px " + config.wWidth + "px " + config.wHeight / 2 + "px 0px)",
onComplete: function () {
timeLineReady();
}
});
// Hide footer
TweenMax.to('.tl-footer', 0, { y: +70 });
// Init Timeline
function initTimeline() {
console.log('Timeline init');
// Set width for timeline
config.timeLineWidth = config.wWidth - 120;
$('.tl-nodes, .tl-bar').width(config.timeLineWidth);
$('.tl-nodes, .tl-bar').css('left', 60);
// How many chapters are there?
config.numNodes = $('.tl-nodes li').length - 1; // skip first
// Calc width for each chapter
config.nodeWidth = config.timeLineWidth / config.numNodes;
// Loop through all chapters
$('.tl-nodes li').each(function(index) {
if (...