-
-
Save amitaibu/421485c593b4fe122a50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<script src="http://snapsvg.io/assets/js/snap.svg-min.js"></script> | |
<style id="jsbin-css"> | |
#svgout { | |
height: 600px; | |
} | |
</style> | |
</head> | |
<body> | |
<svg id="svgout" width="100%" height="100%"></svg> | |
<script id="jsbin-javascript"> | |
var s = Snap("#svgout"); | |
var rect = s.rect(20,20,40,40); | |
var circle = s.circle(60,150,50); | |
var move = function(dx,dy) { | |
this.attr({ | |
transform: this.data('origTransform') + (this.data('origTransform') ? "T" : "t") + [dx, dy] | |
}); | |
}; | |
var start = function() { | |
console.log(this.transform().local); | |
this.data('origTransform', this.transform().local ); | |
}; | |
var stop = function() { | |
console.log('finished dragging'); | |
}; | |
rect.drag(move, start, stop ); | |
circle.drag(move, start, stop ); | |
</script> | |
<script id="jsbin-source-css" type="text/css">#svgout { | |
height: 600px; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var s = Snap("#svgout"); | |
var rect = s.rect(20,20,40,40); | |
var circle = s.circle(60,150,50); | |
var move = function(dx,dy) { | |
this.attr({ | |
transform: this.data('origTransform') + (this.data('origTransform') ? "T" : "t") + [dx, dy] | |
}); | |
}; | |
var start = function() { | |
console.log(this.transform().local); | |
this.data('origTransform', this.transform().local ); | |
}; | |
var stop = function() { | |
console.log('finished dragging'); | |
}; | |
rect.drag(move, start, stop ); | |
circle.drag(move, start, stop ); | |
</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#svgout { | |
height: 600px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var s = Snap("#svgout"); | |
var rect = s.rect(20,20,40,40); | |
var circle = s.circle(60,150,50); | |
var move = function(dx,dy) { | |
this.attr({ | |
transform: this.data('origTransform') + (this.data('origTransform') ? "T" : "t") + [dx, dy] | |
}); | |
}; | |
var start = function() { | |
console.log(this.transform().local); | |
this.data('origTransform', this.transform().local ); | |
}; | |
var stop = function() { | |
console.log('finished dragging'); | |
}; | |
rect.drag(move, start, stop ); | |
circle.drag(move, start, stop ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment