我正在使用SmoothState.Js在點擊上加載新頁面。由於在這些頁面中的每一個上,徽標都保持在相同的位置/大小,因此我希望徽標不會刷新,也不會在頁面上發生變化。SmoothStateJS:如何防止頁面更新時元素刷新?
我的菜單中的鏈接不刷新,但徽標確實。我沒有看到任何文檔或谷歌解決這個問題..我會如何在這些Ajax頁面變化之間隨時保持一個圖像?
這裏是SmoothState電話:
$(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");
});
的HTML:對於SmoothState
<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>
可用事件調用:
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