javascript - jquery mouseleave animation sometimes freeze -
i'm trying create when mouse on over image box, texts slide in left, right , when on mouse leave, texts slide out left, right. here's link actual project im on. below codes exact codes used unto referred site. can see if mouse over, animation triggered once on mouse leave, texts wont animate out (slide out right, left) , no animation triggered or texts wont hide. please check referred link, can see abnormalities there. help, ideas please? have tried
.stop()
but seems not working.
$(window).load(function(){ $('.hover-box-image').mouseover(function(){ var dis = $(this); dis.find('.hover-box-image-text').show(); //animate hover box image text left dis.find('.hover-box-image-text[data-position="left"]') .stop().animate({ 'left' : dis.find('.hover-box-image-text[data-position="center"]').offset().left-dis.closest('.hover-box-image').offset().left-dis.find('.hover-box-image-text[data-position="center"]').width()-5 },200); //animate hover box image text right dis.find('.hover-box-image-text[data-position="right"]') .stop().animate({ 'right' : dis.find('.hover-box-image-text[data-position="center"]').offset().left-dis.closest('.hover-box-image').offset().left-dis.find('.hover-box-image-text[data-position="center"]').width()-5 },200); //animate hover box image text center dis.find('.hover-box-image-text[data-position="center"]').show(); }).mouseleave(function(){ var dis = $(this); //animate hover box image text left dis.find('.hover-box-image-text[data-position="left"]') .animate({ 'left' : 0 },200,function(){ $(this).hide(); }); //animate hover box image text right dis.find('.hover-box-image-text[data-position="right"]') .animate({ 'right' : 0 },200,function(){ $(this).hide(); }); //animate hover box image text center dis.find('.hover-box-image-text[data-position="center"]').fadeout(500); }); });
.hover-box-image{background:red;width:100%;height:200px;} .hover-box-image-text{ color:blue; font-size:30px; position:absolute; z-index:50; display:none; font-weight:500; text-transform: uppercase; font-size:10px; font-family: 'montserrat', sans-serif; letter-spacing: 2px; top:50%; } .hover-box-image-text[data-position="left"]{ transform: translate(0,-50%); left:0px; } .hover-box-image-text[data-position="right"]{ right:0px; transform: translate(0,-50%); } .hover-box-image-text[data-position="center"]{ left:50%; transform: translate(-50%, -50%); } .x-line{ height:2px; width:30px; } .x-line:nth-child(1){ background-color:#41a0a9; -ms-transform: rotate(40deg); /* ie 9 */ -webkit-transform: rotate(40deg); /* chrome, safari, opera */ transform: rotate(40deg); } .x-line:nth-child(2){ background-color:#41a0a9; -ms-transform: rotate(-40deg); /* ie 9 */ -webkit-transform: rotate(-40deg); /* chrome, safari, opera */ transform: rotate(-40deg); }
<!-- latest compiled , minified css --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-bvyiisifek1dgmjrakycuhahrg32omucww7on3rydg4va+pmstsz/k68vbdejh4u" crossorigin="anonymous"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!-- latest compiled , minified javascript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-tc5iqib027qvyjsmfhjomalkfuwvxzxupncja7l2mcwnipg9mgcd8wgnicpd7txa" crossorigin="anonymous"></script> <div class="col-md-6"> <div class="hover-box-image"> <div class="hover-box-image-text" data-position="left">test 1</div> <div class="hover-box-image-text" data-position="center"> <div class="x-line"></div> <div class="x-line"></div> </div> <div class="hover-box-image-text" data-position="right">test 2</div> </div> </div> <div class="col-md-6"> <div class="hover-box-image"> <div class="hover-box-image-text" data-position="left">test awsew 1</div> <div class="hover-box-image-text" data-position="center"> <div class="x-line"></div> <div class="x-line"></div> </div> <div class="hover-box-image-text" data-position="right">testsadx 2</div> </div> </div>
Comments
Post a Comment