Raphael jsを使用して、ページの周りに円や四角形以外のオブジェクトをドラッグアンドドロップすることは可能ですか?Raphael jsでパスとイメージをドラッグ可能にする
パスと画像を追加したいのですが、移動することはできますが、その証明は難しいです。 タッチインターフェイスをサポートしているため、これをRaphaelと連携させたいと思います。ここで
私は少し前にこのを試し、そしてそれは、次のアプローチを使用して作業してしまったコード
<script>
window.onload = function() {
var R = Raphael(0, 0, "100%", "100%"),
r = R.circle(100, 100, 50).attr({fill: "hsb(0, 1, 1)", stroke: "none", opacity: .5}),
g = R.circle(210, 100, 50).attr({fill: "hsb(.3, 1, 1)", stroke: "none", opacity: .5}),
b = R.circle(320, 100, 50).attr({fill: "hsb(.6, 1, 1)", stroke: "#fff", "fill-opacity": 0, "stroke-width": 0.8, opacity: .5}),
p = R.path("M 250 250 l 0 -50 l -50 0 l 0 -50 l -50 0 l 0 50 l -50 0 l 0 50 z") .attr({fill: "hsb(.8, 1, 1)", stroke: "none", opacity: .5});
var start = function() {
this.ox = this.attr("cx");
this.oy = this.attr("cy");
this.animate({r: 70, opacity: .25}, 500, ">");
},
move = function (dx, dy) {
this.attr({cx: this.ox + dx, cy: this.oy + dy});
},
up = function() {
this.animate({r: 50, opacity: .5}, 500, ">");
};
R.set(r, g, b, p).drag(move, start, up);
};
</script>
ありがとう。しかし、形状の最終的な(絶対的な)位置を知る方法はありますか? – Yako
ヤコ、getBBox()を使用することができます – Dan
変換は非推奨です変換でこれを行うための私の答えを参照してください –