mouseover
event matches animate
Why is it repeated twice?
I want to perform an animation when I slide, so I add a Boolean switch to determine, but strangely enough, this program is repeated twice when I slide quickly?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
-sharpwrap {
width: 300px;
height: 600px;
cursor: pointer;
margin: 0 auto;
overflow: hidden;
}
-sharpwrap .contenttop {
width: 200px;
height: 300px;
border: 1px solid green;
}
-sharpwrap .footer {
width: 200px;
height: 77px;
border: 1px solid blue;
position: relative;
}
</style>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<div id="wrap">
<div class="contenttop"></div>
<div class="footer"></div>
</div>
<script type="text/javascript">
var $owarp = $("-sharpwrap");
var $contenttop = $owarp.find(".contenttop");
var a = 0;
var falg = true;
$contenttop.on("mouseover", function() {
console.log(1);
if(falg == false) {
return;
}
$(".footer").animate({
top: "-=20px",
}, 1000, function() {
falg = false;
});
})
</script>
</body>
</html>
what result do you expect? What is the error message actually seen?
I expect to execute the animation event only once, and slide again not to execute the animation.