[英]How to call a function to reload another function (on “orientationchange()” e.g.)?
我想在移动方向更改时(在directionchange orientationchange()
)重新加载js函数(在xyz.php内部)。
在“ jquery-custom.js ”中,我已经有了一个用于directionchange orientationchange()
的函数,该函数可以工作:
$(window).on('orientationchange', function(e) {
$(".loader-packery").show().delay(1000).fadeOut(1);
});
这是我要重新加载的“ xyz.php ”中的函数:
function searchWidthMobile() {
if (is_mobile) {
var $mobile_search = $( ".mobile-header-inner .searchform" );
if($mobile_search.length){
$mobile_search.focusin(function() {
$(this).css({
'z-index':'2'
}).stop().animate({
'padding-left':'0px',
'padding-right':'0px'
}, 400);
});
if ($(document).width() > 380) {
$mobile_search.focusout(function() {
$(this).stop().animate({
'padding-left':'435px',
'padding-right':'77px'
},400);
setTimeout(function(){
$mobile_search.css({
'z-index':'0'
});
}, 400);
});
}
else {
$mobile_search.focusout(function() {
$(this).stop().animate({
'padding-left':'235px',
'padding-right':'77px'
},400);
setTimeout(function(){
$mobile_search.css({
'z-index':'0'
});
}, 400);
});
}
}
}
}
searchWidthMobile();
// $(window).resize(searchWidthMobile);
xyz.php中的功能起作用。 但是您可以想象,仅在加载或重新加载网站本身时。
任何帮助,将不胜感激 :)
只需在设备方向更改时调用该函数:
$(window).on('orientationchange', function(e) {
$(".loader-packery").show().delay(1000).fadeOut(1);
searchWidthMobile();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.