Skip to content

Instantly share code, notes, and snippets.

@brainwipe
Created November 27, 2013 10:44
Show Gist options
  • Save brainwipe/7673766 to your computer and use it in GitHub Desktop.
Save brainwipe/7673766 to your computer and use it in GitHub Desktop.
Using snap.svg for creating a draggable square.
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.jsdelivr.net/snap.svg/0.1.0/snap.svg-min.js"></script>
<script>
var s = Snap("#svg");
var block = s.rect(100, 100, 100, 100, 20, 20);
block.attr({
fill: "rgb(236, 240, 241)",
stroke: "#1f2c39",
strokeWidth: 3
});
block.drag();
</script>
</head>
<body>
<svg id="svg" version="1.1" xmlns="http://www.w3.org/2000/svg"></svg>
</body>
</html>
@brainwipe
Copy link
Author

Snap.svg can be found here: http://snapsvg.io/
More info on this Gist on my blog: http://robsneuron.blogspot.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment