0

I have very basic promise based self-calling function that:

  • takes collection of divs with certain class
  • checks whether they have just been moved left or right
  • based on result makes choice to move (transform: translate) them with classList.add() / classList.remove()
  • and on transitionend - calls itself

here is function:

function transitionTest(){
          console.log('called --- transitionTest() ');

          var dummies = document.getElementsByClassName('dummy'),
          count = dummies.length;

          if(window.cache==='right'){
              var transitionCollection=0;
              for(var i = 0; i < dummies.length; i++){
                  dummies[i].classList.remove('right');
                  dummies[i].addEventListener('transitionend', function(){ 
                      transitionCollection++; 
                      if( transitionCollection === dummies.length ){
                          transitionTest();
                      }  
                  });                  

              }              
              window.cache='';
          } else {
              var transitionCollection=0;
              for(var i = 0; i < dummies.length; i++){
                  dummies[i].classList.add('right');
                  dummies[i].addEventListener('transitionend', function(){ 
                      transitionCollection++; 
                      if( transitionCollection === dummies.length ){
                          transitionTest();
                      }  
                  });

              }        
              window.cache='right';

          }

and here is working fiddle

So, what is wrong?

  • Nothing, if you are accessing via modern browser but not latest versions of Chrome on Windows
  • Nothing, if you are accessing via latest versions of Chrome on Windows but refrain from causing any mouse events such as mouseenter/leave, click, even window focus event (e.g. if you stand still)
  • If you do such, infinite left - right movement of dummy div will occasionally break, under unclear circumstances

What gets wrong:

Dummy div, which is moving left-right infinitely, on mouseenter, mouseleave, click, sometimes and sometimes not (exact conditions are unclear) will:

  • go to end CSS value without transition and resumes normal operation after a while
  • stop entirely and resumes normal operation after a while
  • slow down (!? yeah, I wish I was kidding ) and stop/go to end CSS value

These errors are occurring in Chrome 45 (Win 7) and, less intensively Chrome 42 (Win XP) - which are platforms that I was able to test by now. Just to note, upper code does not need to be cross browser, I'm fully aware of implications.

Miloš Đakonović
  • 3,751
  • 5
  • 35
  • 55
  • I think that's the same problem that I have: http://stackoverflow.com/questions/31678578/css-transition-is-sometimes-skipped-in-chrome Looks like a bug in Chrome. – klaussner Sep 05 '15 at 08:44
  • @chrisklaussner I was assuming that this is bug in Chrome, but, you know rule of thumb - browser bug is the last one to blame. Maybe someone know something me and you don't. I saw your example, too bad Purple Tentacles workaround doesn't work to me. – Miloš Đakonović Sep 05 '15 at 09:29

0 Answers0