Skip to content

Instantly share code, notes, and snippets.

@adrianlzt
Created March 18, 2018 18:55
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 adrianlzt/94e2fd5783a8d0f0e5655ae85e645915 to your computer and use it in GitHub Desktop.
Save adrianlzt/94e2fd5783a8d0f0e5655ae85e645915 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Testing snap</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.5.1/snap.svg-min.js"></script>
<script>
window.onload = function () {
var g = Snap();
g.attr({
viewBox: [0, 0, 800, 600]
});
Snap.load("map2.svg", function (f) {
var pth = f.select("#formamano"),
bola = f.select("#bola"),
mano = f.select("#mano"),
top = g.g();
top.add(bola);
var len = Snap.path.getTotalLength(pth.attr("d"));
Snap.animate(0, len, function (l) {
var dot = pth.getPointAtLength(l);
bola.attr({
transform: "t" + [dot.x, dot.y]
});
}, 3000, null, function () {
top.add(mano);
});
});
};
</script>
</head>
<body>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment