102 lines
3.6 KiB
HTML
102 lines
3.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="copyright" content="Copyright © 2013 Adobe Systems Incorporated. All rights reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the “License”);
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an “AS IS” BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.">
|
|
<title>Snap</title>
|
|
<style media="screen">
|
|
body {
|
|
background: #2c4e6b;
|
|
}
|
|
</style>
|
|
<script src="dist/snap.svg-min.js"></script>
|
|
<script>
|
|
window.onload = function () {
|
|
1;
|
|
var g = Snap("100%", "100%");
|
|
g.attr({
|
|
viewBox: [0, 0, 800, 600]
|
|
});
|
|
|
|
Snap.load("map.svg", function (f) {
|
|
function getShift(dot) {
|
|
pln.attr({
|
|
transform: "t" + (dot.x) + "," + (dot.y) + "r" + (dot.alpha - 90)
|
|
});
|
|
return "t" + (400 - dot.x) + "," + (300 - dot.y);
|
|
}
|
|
var gr = f.select("g"),
|
|
wrd = f.select("#world").attr({fill: "#fff"}),
|
|
syd = f.select("#sydney").attr({fill: "red"}),
|
|
msk = f.select("#moscow").attr({fill: "red"}),
|
|
pth = f.select("#flight"),
|
|
pln = f.select("#plane"),
|
|
top = g.g();
|
|
top.attr({
|
|
mask: g.rect(100, 0, 600, 600).attr({
|
|
fill: "r(.5,.5,.25)#fff-#000"
|
|
})
|
|
});
|
|
var click = top.text(410, 310, "click!").attr({
|
|
font: "20px Source Sans Pro, Arial, sans-serif",
|
|
fill: "#fff"
|
|
});
|
|
pth.attr({
|
|
display: "none"
|
|
});
|
|
pln = gr.g(pln, pln.clone());
|
|
pln.attr({
|
|
display: "none"
|
|
});
|
|
pln[0].attr({
|
|
stroke: "#fff",
|
|
strokeWidth: 2
|
|
});
|
|
top.add(gr.attr({
|
|
transform: getShift({
|
|
x: syd.attr("cx"),
|
|
y: syd.attr("cy")
|
|
})
|
|
}));
|
|
var flight = gr.path().attr({
|
|
fill: "none",
|
|
stroke: "red",
|
|
strokeWidth: 3,
|
|
strokeDasharray: "5 3"
|
|
}).insertBefore(pln);
|
|
window.onclick = function () {
|
|
pln.attr({
|
|
display: ""
|
|
});
|
|
click.attr({
|
|
display: "none"
|
|
});
|
|
Snap.animate(0, pth.getTotalLength(), function (l) {
|
|
var dot = pth.getPointAtLength(l);
|
|
flight.attr({
|
|
d: pth.getSubpath(0, l)
|
|
});
|
|
gr.attr({
|
|
transform: getShift(dot)
|
|
});
|
|
}, 10000);
|
|
};
|
|
});
|
|
};
|
|
</script>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html> |