问题描述
此脚本在您第一次访问该页面时起作用。我有一个多语言站点,当我选择一种语言时,页面重新启动而不清除缓存并且页面冻结。我试图删除此加载,一切正常。 我需要帮助,我将不胜感激提示如何修复它。
这是脚本-
const $ = require('jquery');
let wh = $(window).height();
let ww = $(window).width();
let bp = 767;
// IE
let ua = navigator.userAgent.toLowerCase();
let isMSIE = (ua.indexOf('msie') > -1) && (ua.indexOf('opera') == -1);
let isIE11 = (ua.indexOf('trident/7') > -1);
let isIEedge = (ua.indexOf('edge') > -1);
let isIE = isMSIE || isIE11;
$( document ).ready(function() {
// preload
setTimeout(function () {
$("body").addClass("loaded");
},10);
if (ww > bp) {
// PC
if (ww > 1440) {
if (ww / wh > 1.8) {
$("#load").addClass("preloader__wide");
} else {
$("#load").addClass("preloader__tall");
}
} else if (wh > 800) {
$("#load").addClass("preloader__tall");
}
}
else {
// SP
if (ww > 375) {
if (ww / wh > 0.561) {
$("#load").addClass("preloader__wide");
} else {
$("#load").addClass("preloader__tall");
}
} else if (wh > 668) {
$("#load").addClass("preloader__tall");
}
}
$(window).on("load",function () {
$("#load").addClass("on");
setTimeout(function () {
$("#load").addClass("on2");
},200);
setTimeout(function () {
$("#load").addClass("on3");
},400);
setTimeout(function () {
$("#load").addClass("on4");
},3000);
setTimeout(function () {
$("#load .preloader__block").fadeOut(500);
},3400);
if (isIE || isIEedge) {
setTimeout(function () {
},5600);
setTimeout(function () {
$("#load").fadeOut(1500);
},5800);
}
else {
setTimeout(function () {
expandCell();
},5300);
setTimeout(function () {
},6600);
setTimeout(function () {
$("#load").fadeOut(800);
},6800);
}
setTimeout(function () {
animateVisible(".animate",0);
},7000);
});
$('.count').each(function () {
$(this).prop('Counter',0).animate({
Counter: $(this).text()
},{
duration: 6500,easing: 'swing',step: function (Now) {
$(this).text(Math.ceil(Now));
}
});
});
});
function expandCell() {
// change the default path.
$(".preload_path").each(function (i,o) {
$(o).attr("d","M1441,801V1H1V801ZM1,407V1H1441V801H1Z");
});
// End the loading animation.
loading_cells = document.getElementsByClassName("cell_loading");
for (var i = 0; i < loading_cells.length; i++) {
loading_cells[i].endElement();
}
// Begin the loaded animation.
loaded_cells = document.getElementsByClassName("cell_loaded");
for (var i = 0; i < loaded_cells.length; i++) {
loaded_cells[i].beginElement();
}
}
function animateVisible (e,i) {
let n = $(document).scrollTop();
let s = wh;
$(e).each(function (e,o) {
let r,a = parseInt($(o).offset().top),l = parseInt($(o).height());
r = $(o).data('shift') > 0 ? parseInt($(o).data('shift')) : i,n + s - r > a && n < a + l + r && $(o).addClass('animated');
if ($(o).data('counts') && $(o).hasClass('animated')) {
let countEl = $(o).children('.counts');
countEl.prop('Counter',0).animate({
Counter: countEl.text()
},{
duration: 10000,step: function (Now) {
countEl.text(Math.ceil(Now));
}
});
}
})
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)