First im more of a designer than developper. I have a code to detect if my browser is in mobile and portrait to change some class. I'm pretty sure this can be simplify
Tanks
window.addEventListener("load", function(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && window.matchMedia("(orientation: portrait)").matches) {
console.log("this is mobile and portrait");
}else{
console.log("this is not mobile");
}
});
window.addEventListener("resize", function(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && window.matchMedia("(orientation: portrait)").matches) {
console.log("this is mobile and portrait");
}else{
console.log("this is not mobile");
}
});