JSFiddle - React, Tailwind, and code Playground
HTML
<div id="view1" class="view">
<header>
<h1>This is page 1</h1>
</header>
<article>
<p>Tap me anywhere to go to the next view</p>
</article>
<footer>
<p>This is my footer</p>
</footer>
</div>
<div id="view2" class="view">
<header>
<h1>This is page 2</h1>
</header>
</div>
CSS
body.transitioning {
overflow: hidden
}
div.view {
display: none;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
/*overflow: hidden;*/
float: left;
}
div.view.active,
div > div.view {
display: block;
}
div.view header {
background-color: #05b8e2;
padding: 10px 0;
height: 20px;
}
div.view header h1 {
font-weight: bold;
color: #fff;
text-align: center;
text-shadow: 0 -1px 0 rgba(0,0,0,0.1);
font-size: 18px;
line-height: 20px;
}
div.view article {
background-color: #eee;
padding: 10px;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
overflow-y: auto
}
div.view footer {
background-color: #111;
color: #fff;
height: 35px;
border-top: 1px solid #000;
}
div.view footer p {
line-height: 35px;
text-align: center;
}
#transitioner {
position: absolute;
top: 0;
-webkit-transition: all 0.2s ease-in-out;
}
JavaScript
var viewport;
$(function() {
viewport = {
width: $(window).width(),
height: $(window).height()
};
$('.view').css({ width: viewport.width, height: viewport.height });
$('.view').first().addClass('active');
$('.view').each(function() {
var body_height = $(this).outerHeight();
if($(this).children('header').length > 0) { body_height -= $(this).children('header').outerHeight(); }
if($(this).children('footer').length > 0) { body_height -= $(this).children('footer').outerHeight(); }
$(this).children('article').height(body_height);
});
$('#view1 article').click(function() { GotoView($('#view2')); });
});
// Function to go to another view:
function GotoView(view)
{
var roller = $('<div id="transitioner" />');
roller.width((viewport.width * 2)).height(viewport.height);
var current = $('.view.active').clone(true, true);
$('.view.active').remove();
current.prependTo(roller);
var new_view = view.clone(true, true);
view.remove();
new_view.appendTo(roller);
roller.appendTo($('body'));
$('body').addClass('transitioning');
$("body")[0].offsetWidth;
//window.setTimeout(function() { roller.css({ left: 0 - viewport.width }) }, 2000);
roller.css({ left: 0 - viewport.width });
}