I'm doing a simple animation if the screen width is > 800px
and don't do nothing (just stay with the default css) if it's < 800, the problems are:
with window width > 800: I refresh the page it doesn't do the animation unless i resize a little to trigger the resize function.
with window < 800: if i had done the animation ( > 800px) and then resize to <800 the animation still goes on instead of just respect the css and nothing more. Any tips?
JS:
$(document).ready(function () {
$(window).resize(function () {
if ($(window).width() > 800) {
$('#upBar, nav').hover(function () {
$('#upBar, nav ul').stop(true).animate({
height: '60px'
}, 200);
});
$('#upBar, nav').mouseleave(function () {
$('#upBar, nav ul').stop(true).animate({
height: '45px'
}, 200);
});
} else {}
})
})
HTML:
<html lang="en" />
<head>
<meta charset="UTF-8">
<title>Intertrafego - Quem Somos</title>
<link rel="stylesheet" href="css/navBar.css">
<link rel="stylesheet" href="css/footer.css">
<link rel="stylesheet" href="css/stylesAboutUs.css">
<meta name="viewport" content="width=width-device, initial-scale=1.0" />
</head>
<body data-stellar-background-ratio="0.2">
<div id="upBar"></div>
<div id="middleBar"></div>
<div id="middleImg"></div>
<div id="missValBar"></div>
<div id="wrapper">
<header>
<nav> <a href="index.html"><img id="logo" src="imgs/logo.png"></a>
<a href="quem_somos.html"><div id="langMobile">EN<br>↓<br>Pt</div></a>
<div id="btnMobile">
<img src="imgs/mobileBtn.jpg">
</div>
<ul>
<li id="lang"><a id="PT" href="quem_somos.html">PT</a> / <a id="EN" href="#">EN</a>
</li> <a href="news.html"><li>News</li></a>
<a href="logistics.html"><li>Logistics</li></a>
<a href="services.html"><li>Services</li></a>
<a href="#"><li>About Us</li></a>
</ul>
</nav>
</header>