I want to reload a js function (inside xyz.php ) as the mobile orientation changes (on orientationchange()
).
In a " jquery-custom.js " I already have a function for orientationchange()
that works:
$(window).on('orientationchange', function(e) {
$(".loader-packery").show().delay(1000).fadeOut(1);
});
This is the function inside " xyz.php " i want to reload:
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);
The function in xyz.php works. But as you can imagine, only on loading or reloading the site itself.
Any help would be appreciated :)
Just call the function when the device orientation changes:
$(window).on('orientationchange', function(e) {
$(".loader-packery").show().delay(1000).fadeOut(1);
searchWidthMobile();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.