I am using SmoothState.Js to load new pages on clicks. Since on every one of those pages the logo stays in the same place/size, I would like for the logo to not refresh and not fadeout/in on page changes.
The links in my menu don't refresh but the logo does. I have not seen anything in the docs or on Google addressing this.. How would I go about keeping an image in place at all times in between these ajax page changes?
Here is the SmoothState call:
$(function() {
$('#main').smoothState();
});
$(function() {
"use strict";
var options = {
prefetch: true,
pageCacheSize: 4,
onStart: {
duration: 300, // 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");
});
The HTML:
<header class="header">
<div class="main-logo">
<a class="svg" href="www.site.com">
<object class="willItBlend" data="../svg/main-logo.svg" type="image/svg+xml"></object>
<img class="blender" src="../svg/main-logo.png" />
</a>
</div>
<nav class="main-nav-about">
// links go here
</nav>
</header>
Available event calls for SmoothState:
onBefore - Runs before a page load has been started
onStart - Runs once a page load has been activated
onProgress - Runs if the page request is still pending and the onStart animations have finished
onReady - Run once the requested content is ready to be injected into the page and the previous animations have finished
onAfter - Runs after the new content has been injected into the page and all animations are complete
You need to use the 'blacklist' option as specified in the docs:
Just add this to the options object
blacklist: '.no-smoothState'
Then add the
.no-smoothState
class to any page elements you want to be ignored.