Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Incorrect SVG transform-origin">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
<svg width="120px" height="120px" viewBox="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="border: 1px dashed">
  
  <rect id="rect1" fill="blue" x="0" y="0" width="50" height="50" style="transform-origin: 50% 50%; transform: scale(0.5); border: 1px solid red; overflow: hidden; position: relative; display: block;"></rect>
  <rect stroke="red" fill="transparent" x="0" y="0" width="50" height="50"></rect>
</svg>
  <pre id="info1"></pre>
  <hr>
Compare against a normal div:
<div class="parent" style="width: 120px; height: 120px; border: 1px dashed; position: relative;">
  <div id="rect2" style="background: green; position: absolute; top: 0; left: 0; width: 50px; height: 50px; transform-origin: 50% 50%; transform: scale(0.5)"></div>
</div>
  <pre id="info2"></pre>
</body>
</html>
 
window.onload = function() {
  var cs1 = getComputedStyle(rect1);
  info1.textContent += 'computed transform: ' + cs1.transform;
  info1.textContent += '\ncomputed origin: ' + cs1.transformOrigin;
  info1.textContent += '\ncomputed box: ' + cs1.transformBox;
  info1.textContent += '\nstyle transform: ' + rect1.style.transform;
  info1.textContent += '\nstyle origin: ' + rect1.style.transformOrigin;
  info1.textContent += '\nbcr: ' + getBcr(rect1);
  var cs2 = getComputedStyle(rect2);
  info2.textContent += 'computed transform: ' + cs2.transform;
  info2.textContent += '\ncomputed origin: ' + cs2.transformOrigin;
  info2.textContent += '\ncomputed box: ' + cs2.transformBox;
  info2.textContent += '\nstyle transform: ' + rect2.style.transform;
  info2.textContent += '\nstyle origin: ' + rect2.style.transformOrigin;
  info2.textContent += '\nbcr: ' + getBcr(rect2);
};
function getBcr(node) {
  var b = node.getBoundingClientRect();
  return b.width + 'x' + b.height;
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
dvoytenkopro
0viewers