I tried to embed the smoothState.js into my project, but for any reason the reverse/toogle/exiting animation won’t work. I really have no more ideas and i couldn’t find a solution on stackoverflow or something else.
My codes:
HTML:
<div id="main" class="m-scene">
<!-- Classes that define elment animations -->
<a href="index.html">Home</a>
<a href="about.html">About</a>
<div class="scene_element scene_element--fadeinright">
<p>Home to the boy</p>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/jquery.smoothState.js"></script>
<script src="js/functions.js"></script>
CSS:(linked to the css files, included in the package of smoothstate)
JS:
$(function(){
'use strict';
var $page = $('#main'),
options = {
debug: true,
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 = $page.smoothState(options).data('smoothState');
});
I really hope someone can help me to get this thing working :)
Thank you in advance.
Try removing
$container.removeClass('is-exiting');
from the onReady Render function and instead append this to your options:onAfter: function($container) { $container.removeClass('is-exiting'); }
The onAfter function is called once everything is loaded into the page and seems to help when coordinating animations.