Eadweard,
<!DOCTYPE HTML>
<html>
<head>
<title>Перемещение круга</title>
<style>
.svgcircle
{
position: absolute;
}
.circle
{ -webkit-transition:all 3s cubic-bezier(0, 0, 1, 1);
-moz-transition:all 3s cubic-bezier(0, 0, 1, 1);
-o-transition:all 3s cubic-bezier(0, 0, 1, 1);
transition:all 3s cubic-bezier(0, 0, 1, 1);
}
.rect
{
-webkit-transition: all 3s cubic-bezier(0, 0, 1, 1);
-moz-transition:all 3s cubic-bezier(0, 0, 1, 1);
-o-transition:all 3s cubic-bezier(0, 0, 1, 1);
transition:all 3s cubic-bezier(0, 0, 1, 1);
}
.ellipse
{
-webkit-transition: all 3s cubic-bezier(0, 0, 1, 1), opacity 10s linear;
-moz-transition:all 3s cubic-bezier(0, 0, 1, 1), opacity 10s linear;
-o-transition:all 3s cubic-bezier(0, 0, 1, 1), opacity 10s linear;
transition:all 3s cubic-bezier(0, 0, 1, 1), opacity 10s linear;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</head>
<body>
<script>
function randomRGBComponent() {
return Math.round(Math.random() * 255);
}
function randomRGBColor() {
return 'rgba(' + randomRGBComponent() + ', ' + randomRGBComponent() + ', ' + randomRGBComponent() + ',1)';
}
$("html").on("click", ".circle", function () {
this.setAttribute("cx", Math.random() * 500);
this.setAttribute("cy", Math.random() * 500);
this.setAttribute('fill',"rgba(255,255,255,0)")
$('rect').attr("fill", randomRGBColor());
});
$("html").on("click", ".rect", function () {
this.setAttribute("x", Math.random() * 500);
this.setAttribute("y", Math.random() * 500);
this.setAttribute('fill', "rgba(255,255,255,0)")
$('ellipse').attr("fill", randomRGBColor());
});
$("html").on("click", ".ellipse", function () {
this.setAttribute("cx", Math.random() * 500);
this.setAttribute("cy", Math.random() * 500);
this.setAttribute('fill', "rgba(255,255,255,0)")
$("circle").attr("fill", randomRGBColor());
});
</script>
<svg width ="600" height ="600" class="svgcircle">
<circle class="circle" cx="35" cy="25" r="35" fill="red"/>
<rect class="rect" x="200" y="400" width="35" height="35" fill="rgba(0,0,0,0)"/>
<ellipse class="ellipse" cx="400" cy="200" rx="50" ry="25" fill="rgba(0,0,0,0)"/>
</svg>
</body>
</html>
|