Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<p>press "start" to hide the box, then press "start" again to show the box. See the console for the first few frame's computed styles.</p>
  <button type="button" id="start">start</button>
  <div id="target"></div>
  
  
</body>
</html>
 
#target {
  width: 100px;
  height: 100px;
  background: red;
  transition:
    visibility 1s,
    background-color 1s;
}
#target.started {
  background: blue;
  visibility: hidden;
}
 
var observations = 0;
function logTransition() {
  if (!observations) {
    return;
  }
  observations--;
  
  var style = window.getComputedStyle(target, null);
  var value = style.getPropertyValue('visibility')
  + ' - '
  + style.getPropertyValue('background-color');
  console.log(value);
  requestAnimationFrame(logTransition);
}
var button = document.getElementById('start');
var target = document.getElementById('target');
start.addEventListener('click', function(){
  observations = 4;
  target.classList.toggle('started');
  logTransition();
});
Output 300px

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers