Skip to content

Instantly share code, notes, and snippets.

@matthewcrist
Created November 28, 2010 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewcrist/719012 to your computer and use it in GitHub Desktop.
Save matthewcrist/719012 to your computer and use it in GitHub Desktop.
<svg height="300" width="350" version="1.1" xmlns="http://www.w3.org/2000/svg">
<script type="application/ecmascript">//<![CDATA[
function removeAndUpdate(el) {
var cliprect = document.getElementById('cliprect');
// remove the path
//el.setAttribute('clip-path', 'none'); // doesn't help
el.parentNode.removeChild(el);
// update the clipping
cliprect.setAttribute('width', 350);
}
//]]>
</script>
<defs>
<clipPath id="clip">
<rect id="cliprect" fill="none" height="330" width="300" y="0" x="0">
</rect>
</clipPath>
</defs>
<g clip-path="url(#clip)" onclick="removeAndUpdate(this)">
<rect x="10" y="10" width="500" height="100" fill="red" />
</g>
<g clip-path="url(#clip)" onclick="removeAndUpdate(this)">
<circle cx="250" cy="150" r="100" fill="blue" />
</g>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment