Привет, я новичок в использовании библиотеки Raphael Javascript. Я пытаюсь создать простое перетаскивание;чтобы иметь возможность перетаскивать форму клона снаружи холста на холст R, и я хочу иметь возможность удалить выбранный клон, если пользователь щелкнет по нему (пользователь нажимает удалить выбранный клон, и клон удаляется).клон и вставьте его.Вот мой код:
<html>
<head>
<title>Raphael Play</title>
<script type="text/javascript" src="raphael.js"></script>
<script type="text/javascript" src="jquery.contextMenu.r2.js"></script>
<style type="text/css">
#canvas_container {
width: 500px;
border: 1px solid #aaa;
}
</style>
<script>
window.onload = function() {
var nowX, nowY, w = 500, h=400, r=30, R = Raphael("canvas_container", w, h),
c = R.circle(100, 100, r).attr({
fill: "hsb(.8, 1, 1)",
stroke: "none",
opacity: .5,
cursor: "move"
});
var clone=c.clone();
var start = function () {
// storing original coordinates
this.ox = this.attr("cx");
this.oy = this.attr("cy");
this.attr({opacity: 1});
},
move = function (dx, dy) {
// move will be called with dx and dy
// restrict movement of circle to within boundaries
if (this.ox + dx <= w - r &&
this.oy + dy <= h - r &&
this.ox + dx >= 0 + r &&
this.oy + dy >= 0 + r)
{
this.attr({cx: this.ox + dx, cy: this.oy + dy});
} // else nothing
},
up = function () {
// restoring state
this.attr({opacity: .5});
};
clone.drag(move, start, up);
};
// Create Context Menu
</script>
</head>
<body>
<div id="canvas_container"></div>
</body>