【发布时间】:2020-11-17 13:45:08
【问题描述】:
我正在使用RaphaelJS 绘制路径和圆圈,我想拖放一个路径,使线/路径的两端与圆圈重叠。
当我拖动一条线/路径被拖动时,我如何检测到两端是重叠的圆圈(比方说,不是线的中间)?
圈子:
this.set = paper.set();
this.shape = paper.circle(x, y, 10);
paper.setStart();
this.radius = 10;
this.text = paper.text(x, y - 15, this.name);
this.set[0].hover(
function() {
this.g = this.glow({
color: "#fff",
width: 20,
opacity: .5
});
this.node.style.cursor = 'pointer';
},
function() {
this.g.remove();
}
);
行:
let connector = paper.path(`M ${startX} ${startY} l 0 25 l 25 50 L ${endX} ${endY}`);
let start = function () {
this.odx = 0;
this.ody = 0;
this.animate({"fill-opacity": 0.2}, 500);
},
move = function (dx, dy) {
this.translate(dx - this.odx, dy - this.ody);
this.odx = dx;
this.ody = dy;
},
drop = function () {
this.animate({"fill-opacity": 1}, 500);
};
connector.drag(move, start, drop);
【问题讨论】:
标签: javascript collision-detection raphael