jquery - Button transition using javascript and css, how to temporarily disable the transition -


basically have button hover , slide green (active) button mouse out , slide appear opening grey unactive button comes in left, cancel setting button @ start without transitioning it, hope makes sense?

at moment if transition first button going left:0 left: -210px see transition because .btn-ctn has transition on it, possible temporarily disable buttons jump dont see green middle button?

css

* {     padding: 0;     margin: 0;     border: 0;     outline: 0;     list-style: none; }  body {     padding: 20px; }  .direction {     width: 70px;     overflow: hidden; }  .btn-ctn {     width: 210px;     position: relative;     left: -140px;     -webkit-transition: left .3s ease-in-out; }  .btn-ctn.on {     left: -70px; }  .btn-ctn.off {     left: 0; }  .btn-ctn > li {     float: left;     position: relative; }  .btn {     width: 70px;     height: 70px;     background: #676767;     display: block; }  .btn::after {     content: '';     width: 30px;     height: 30px;     border-right: 2px solid white;     border-top: 2px solid white;     display: block;     position: absolute;     top: 0; right: 15px; bottom: 0; left: 0;     margin: auto;     -webkit-transform:rotate(45deg); }  .active .btn {     background: #5cdf84; }  .btns > li::after {  } 

js

$('.btn').on('mouseenter', function() {      $('.btn-ctn').removeclass('off').addclass('on');  }).on('mouseleave', function() {      $('.btn-ctn').removeclass('on').addclass('off');      //reset start without animating if hover on again same animation happens if first time?  }); 

jsfiddle http://jsfiddle.net/atzx2/2/

edit think figured out you're trying now. need move transition property onto on , off classes i'd suggested earlier:

.btn-ctn {     width: 210px;     position: relative;     left: -140px; }  .btn-ctn.on {     left: -70px;     -webkit-transition: left .3s ease-in-out; }  .btn-ctn.off {     left: 0;     -webkit-transition: left .3s ease-in-out; } 

...but key listen webkittransitionend event in order remove off class after it's finished sliding:

$('.btn-ctn').on('webkittransitionend', function(e)  {       $(e.target).removeclass('off'); }); 

jsfiddle demo here: http://jsfiddle.net/atzx2/6/


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -