I am using smoothStates default settings and I wanted to know if I can add a class to the main wrapper so I can change the background color of the site? I don't want to add another div under main as its just extra markup.
At the moment I can only add page-index and then the rest of the pages don´t change as smoothState doesn't load the page again.
EDIT: So I want to add a class for each page, like: page-index
, page-about
and so on.
I have a div like so:
<div id="main">
// stuff here
</div>
When you click on /news:
<div id="main" class="page-news">
// stuff here
</div>
My functions:
$(function(){
'use strict';
var options = {
prefetch: true,
cacheLength: 2,
onStart: {
duration: 250, // Duration of our animation
render: function ($container) {
// Add your CSS animation reversing class
$container.addClass('is-exiting');
// Restart your animation
smoothState.restartCSSAnimations();
}
},
onReady: {
duration: 0,
render: function ($container, $newContent) {
// Remove your CSS animation reversing class
$container.removeClass('is-exiting');
// Inject the new content
$container.html($newContent);
}
}
},
smoothState = $('#main').smoothState(options).data('smoothState');
});