我设法使smoothstate
在WordPress上可以正常工作。但是视觉作曲家元素不起作用,我认为这阻止了ajax调用后视觉作曲家re-initialize
的使用。
如果我加载的第一页具有视觉作曲器元素,则它可以正常工作,但是当我移至另一页具有视觉作曲器元素时,所有元素均处于关闭状态并且无法正常工作。
我希望有人帮我解决了这三天没有运气的尝试。
以下是我的代码:
$(document).ready(function () {
/*
$(function() {
$('#smoothBody').smoothState();
});*/
function addBlacklistClass() {
$('a').each(function () {
if (this.href.indexOf('/wp-admin/') !== -1 ||
this.href.indexOf('/wp-login.php') !== -1) {
$(this).addClass('wp-link');
}
});
}
(function ($) {
'use strict';
addBlacklistClass();
var $page = $('#smoothBody'),
options = {
anchors: 'a',
repeatDelay: 100,
debug: true,
forms: 'form',
scroll: true,
prefetch: true,
cacheLength: 25,
blacklist: ".no-smoothstate, .post-edit-link, a[href*='.jpg'], a[href*='.png'], a[href*='.jpeg'], a[href*='.pdf']",
prefetchOn: 'mouseover touchstart',
onBefore: function (a) {
a.attr("href") == window.location.href && I.pageContainerSmoothState.clear(window.location.href)
},
onStart: {
// How long this animation takes
duration: 1000,
// A function that dictates the animations that take place
render: function (url, $container) {
$(".loading_overlay ").addClass("is_exiting");
}
},
onProgress: {
// How long this animation takes
duration: 0,
// A function that dictates the animations that take place
render: function ($container) {
$(".loading_overlay ").addClass("is_loading");
}
},
onReady: {
duration: 1000,
// `$container` is a `jQuery Object` of the the current smoothState container
// `$newContent` is a `jQuery Object` of the HTML that should replace the existing container's HTML.
render: function ($container, $newContent) {
// Update the HTML on the page
$container.html($newContent);
$(".loading_overlay ").addClass("is_entering");
}
},
onAfter: function ($container, $newContent) {
$(".loading_overlay ").removeClass("is_exiting");
$(".loading_overlay ").removeClass("is_loading");
$(".loading_overlay ").removeClass("is_entering");
/* window.location.reload();*/
}
},
smoothState = $page.smoothState(options).data('smoothState');
})(jQuery);
$(".loading_overlay ").removeClass("is_entering");
setTimeout(function () {
$(".loading_overlay ").addClass("is_entering");
$(".loading_overlay ").removeClass("is_entering");
$(".loading_overlay ").removeClass("is_loading");
$(".loading_overlay ").removeClass("is_exiting");
/* $(function() {
$('#smoothBody').smoothState();
});*/
}, 1050);
setTimeout(function () {
$(".loading_overlay ").addClass("is_entering");
$(".loading_overlay ").removeClass("is_entering");
$(".loading_overlay ").removeClass("is_loading");
$(".loading_overlay ").removeClass("is_exiting");
/* $(function() {
$('#smoothBody').smoothState();
});*/
}, 1100);
});