JSFiddle - React, Tailwind, and code Playground
by Thee Funklord
October 08, 2015
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/classie/1.0.1/classie.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"></script>
<div class="container-yoyo">
<div class="noooooo">
<a class="makeitanimate">click mee!</a>
</div>
<div id="theGrid" class="main-anim">
<section class="grid">
<a class="grid__item" href="#">
<h2 class="title title--preview">THING!</h2>
<div class="loader"></div>
</a>
</section>
<section class="content2">
<div class="scroll-wrap">
<p>Hi. I'm Mr. MeeSeeks.</p>
</div>
</section>
</div>
<!-- yes yes, I know there's no close button, I took it out for this demo...just run the function again-->
CSS
.noooooo {height:100vh; float: left; background: orange; position: absolute; width: 30%; padding: 2rem;}
.makeitanimate {padding:1rem; margin: 0.5rem; background:#437792; transition: background 250ms linear;z-index:9999;}
.makeitanimate:hover {background:red; }
body {
background: #9cbed7;
font-size: 13px;
font-family: Arial, sans-serif;
overflow: hidden;
}
a { outline: none; color: #81c483; text-decoration: none; }
.noscroll {overflow: hidden; }
/******************************* *********************************************************** Main content */
.main-anim { position: relative; z-index: 50; height: 100%; margin:0; }
.grid { position: relative; -webkit-transition: -webkit-transform 0.5s; transition: transform 0.5s; }
/****************************************************************************************** Overlay */
.grid::after {
content: '';
background: rgba(202, 202, 202, 0.74);
opacity: 0;
position: absolute;
pointer-events: none;
top: 0;
left: 0;
width: 100%;
height: 100%;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.view-single .grid::after { opacity: 1; }
/* Grid item */
.grid__item {
padding: 45px 55px 30px;
position: relative;
color: inherit;
width:50%; float: right;
background: #ffffff;
min-height: 300px;
cursor: pointer;
text-align: center;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-direction: normal;
-webkit-box-orient: vertical;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-justify-content: center;
justify-content: center;
}
.grid__item * { z-index: 10; }
.title { margin: 0; font-size: 1.875em; font-family: Arial, sans-serif; text-align: center; }
.title--preview {
-webkit-flex: 1;
flex: 1;
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content:...
JavaScript
$( "a.makeitanimate" ).on( "click", function() {
alert( 'Make this do what .grid__item does - i.e. clicking on this runs the loading animation to completion.');
});
/**
* main.js
* http://www.codrops.com
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2015, Codrops
* http://www.codrops.com
*/
(function() {
var bodyEl = document.body,
docElem = window.document.documentElement,
support = { transitions: Modernizr.csstransitions },
// transition end event name
transEndEventNames = { 'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd', 'msTransition': 'MSTransitionEnd', 'transition': 'transitionend' },
transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
onEndTransition = function( el, callback ) {
var onEndCallbackFn = function( ev ) {
if( support.transitions ) {
if( ev.target != this ) return;
this.removeEventListener( transEndEventName, onEndCallbackFn );
}
if( callback && typeof callback === 'function' ) { callback.call(this); }
};
if( support.transitions ) {
el.addEventListener( transEndEventName, onEndCallbackFn );
}
else {
onEndCallbackFn();
}
},
gridEl = document.getElementById('theGrid'),
gridItemsContainer = gridEl.querySelector('section.grid'),
contentItemsContainer = gridEl.querySelector('section.content2'),
gridItems = gridItemsContainer.querySelectorAll('.grid__item'),
contentItems = contentItemsContainer.querySelectorAll('.content__item'),
closeCtrl = contentItemsContainer.querySelector('.close-button-anim'),
current = -1,
lockScroll = false, xscroll, yscroll,
isAnimating = false;
/**
* gets the viewport width and height
* based on http://responsejs.com/labs/dimensions/
*/
function getViewport( axis ) {
var client, inner;
if( axis === 'x' ) {
client = docElem['clientWidth'];
inner =...