몇 가지 테스트를 수행하는 데 사용하는이 간단한 더미 파일이 있습니다. 의도 한 결과는 경로를 따라 빨간색 원을 드래그하는 것입니다. 것은 두 모양을 연결하는 방법을 알아낼 수 없다는 것입니다.주어진 경로를 따라 셰이프를 끌는 방법
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="raphael-min.js"></script>
</head>
<body>
<script type="text/javascript">
// Creates canvas 320 × 200 at 10, 50
var r = Raphael(10, 50, 320, 200);
var p = r.path("M100,100c0,50 100-50 100,0c0,50 -100-50 -100,0z").attr({stroke: "#ddd"}),
e = r.ellipse(104, 100, 4, 4).attr({stroke: "none", fill: "#f00"}),
/*var c = r.circle(100, 100, 50).attr({
fill: "hsb(.8, 1, 1)",
stroke: "none",
opacity: .5
});*/
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
this.attr({cx: this.ox + dx, cy: this.oy + dy});
},
up = function() {
// restoring state
this.attr({opacity: 1});
};
e.drag(move, start, up);
</script>
</body>
</html>
주요 아이디어는 animateAlong과 유사하지만, 대신에 애니메이션 끌어 뭔가를 얻을 수 있습니다 : 여기
http://jsfiddle.net/fuzic/kKLtH/
는 코드입니다. – Guillermo다음은 사람들이 사용할 jsFiddle입니다. http://jsfiddle.net/8T9NQ/ – Joe
일반적으로 커서 위치를 경로에 투영하여 경로에서 가장 가까운 점을 찾아야합니다. 커서에 가장 가까운 경로에 2 개 (또는 그 이상 또는 무한)의 점이있을 가능성이 매우 높으므로 가장 명확한 점을 선택해야합니다. – Phrogz