<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
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |