jquery - not triggering an event when moving the mouse too fast -
is possible not trigger icon when move mouse fast on button? because when move mouse fast on button icon moves down :before , :after elements doesn't trigger. , if move multiple times on button icon triggers late moves , down multiple times.
http://codepen.io/earbot/pen/dvezbw
function easeinoutback(t, b, c, d, s) { if (s == undefined) s = 1.70158; if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b; return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b; } $('#head-btn').on('mouseenter', function() { var bubu = function() { $('#head-io').animate({ top: '50%', }, 500); } settimeout(bubu, 500); }).on('mouseleave', function() { $('#head-io').animate({ top: '-100%', }); }); body { background: #222; } #head-btn { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: transparent; border: 2px solid #fff; color: #fff; text-transform: uppercase; font-size: .8rem; letter-spacing: 4px; height:2rem; text-align: center; overflow: hidden; cursor: pointer; } #head-io { position: absolute; font-size: 2rem; top: -100%; left: 50%; transform: translate(-50%); z-index: 3; color: #222; transform:translate(-50%,-50%); } #head-btn:after { content: ''; position: absolute; left: calc(100% + 2px); height: 100%; width: 100%; top: 0; background: #fff; -webkit-transition: 1000ms cubic-bezier(0.680, 0, 0.265, 1); -webkit-transition: 1000ms cubic-bezier(0.680, -0.550, 0.265, 1.550); -moz-transition: 1000ms cubic-bezier(0.680, -0.550, 0.265, 1.550); -o-transition: 1000ms cubic-bezier(0.680, -0.550, 0.265, 1.550); transition: 1000ms cubic-bezier(0.680, -0.550, 0.265, 1.550); -webkit-transition-timing-function: cubic-bezier(0.680, 0, 0.265, 1); -webkit-transition-timing-function: cubic-bezier(0.680, -0.550, 0.265, 1.550); -moz-transition-timing-function: cubic-bezier(0.680, -0.550, 0.265, 1.550); -o-transition-timing-function: cubic-bezier(0.680, -0.550, 0.265, 1.550); transition-timing-function: cubic-bezier(0.680, -0.550, 0.265, 1.550); } /*\f2eb*/ #head-btn:before { content: ''; font-size: 2rem; text-align: center; position: absolute; height: 100%; width: 100%; background: #fff; top: 0; left: calc(-100% - 2px); -webkit-transition: 1000ms cubic-bezier(0.680, 0, 0.265, 1); -webkit-transition: 1000ms cubic-bezier(0.680, -0.550, 0.265, 1.550); -moz-transition: 1000ms cubic-bezier(0.680, -0.550, 0.265, 1.550); -o-transition: 1000ms cubic-bezier(0.680, -0.550, 0.265, 1.550); transition: 1000ms cubic-bezier(0.680, -0.550, 0.265, 1.550); -webkit-transition-timing-function: cubic-bezier(0.680, 0, 0.265, 1); -webkit-transition-timing-function: cubic-bezier(0.680, -0.550, 0.265, 1.550); -moz-transition-timing-function: cubic-bezier(0.680, -0.550, 0.265, 1.550); -o-transition-timing-function: cubic-bezier(0.680, -0.550, 0.265, 1.550); transition-timing-function: cubic-bezier(0.680, -0.550, 0.265, 1.550); } #head-btn:hover:after { left: calc(50% - 2px); } #head-btn:hover:before { left: calc(-50% + 2px); } <link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button class="btn btn-lg" id="head-btn">i'm interested <i class="ion-ios-email"id="head-io"></i></button>
if using css transitions why don't keep way ?, instead of js styles:
#head-io { ... transition:top .5s linear; } #head-btn:hover #head-io { top:0; transition-delay:.5s; }
Comments
Post a Comment