如何解决预加载器WordPress的最短时间
我需要创建一个预加载器,该预加载器会停留最少的给定时间(6秒)。 我对jQuery一无所知,但这是wordpress插件的代码,我想我需要在这里添加时间:
jQuery(function($){
var width = 100,perfData = window.performance.timing,// The PerformanceTiming interface represents timing-related performance information for the given page.
EstimatedTime = -(perfData.loadEventEnd - perfData.navigationStart),time = parseInt((EstimatedTime/1000)%60)*100;
var preloader = document.querySelector(".preloader-plus");
$('body').prepend(preloader);
var progBar = document.querySelector(".prog-bar"),start = 0,end = 70,duration = time,counter = document.getElementById("preloader-counter");
animateValue(progBar,start,end,duration);
function animateValue(element,duration) {
var range = end - start,current = start,increment = end > start? 1 : -1,stepTime = Math.abs(Math.floor(duration / range)),obj = element;
var timer = setInterval(function() {
if(current < end) {
current += increment;
}
if (obj !== null) {
obj.style["transition-duration"] = "0.001s";
obj.style.width= current + "%";
}
if (counter !== null) {
counter.innerHTML = current + "%";
}
if ( current == end ) {
var endLoading = setInterval( function() {
current += increment;
if (obj !== null) {
obj.style.width= current + "%";
}
if (counter !== null) {
counter.innerHTML = current + "%";
}
if(current == 100) {
setTimeout( function() {
$('body,.preloader-plus').addClass('complete');
},preloader_plus.animation_delay)
clearInterval(endLoading);
}
},1)
clearInterval(timer);
}
},stepTime);
}
});
如果您能帮助我,我将非常高兴,谢谢! (如果您需要更多信息,请告诉我)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。