javascript - How to fade svg path in/out one after the other? -


i doing following fading in/out path @ once , not 1 after other

  var periodclass = jquery(this).parent().attr("class");   jquery("svg path").each(function(i) {     var elem = jquery(this);     if (elem.hasclass(periodclass)) {         elem.addclass('active').css('transition-delay', i/5000 + 's');     } else {         elem.removeclass('active').css('transition-delay', i/5000 + 's');     }   }); 

css

path {     opacity: 0;     transition-property: opacity;     transition-duration: 0.7s; }  path.active {     opacity: 1;     transition-property: opacity;     transition-duration: 0.7s; } 

also tried still, @ once

  var periodclass = jquery(this).parent().attr("class");   jquery("svg path").each(function(i) {     var elem = jquery(this);     if (elem.hasclass(periodclass)) {       elem.addclass('active');       elem.each(function(index) {           $(this).delay(400*index).fadein(300);       });     } else {       elem.removeclass('active');       elem.each(function(index) {           $(this).delay(400*index).fadeout(300);       });     }   }); 

you need use settimeout();

here's example

$(document).ready(function(){    $('div').each(function(i){      var thisit = $(this);      settimeout(function(){        thisit.addclass('active');      } , * 1000);          });  });
div{    margin: 20px;    padding: 10px;    font-size: 30px;    text-align: center;    background : #eee;    display: none;  }    .active{    display: block;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div>1</div>  <div>2</div>  <div>3</div>  <div>4</div>


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -