1

Rapahel の円がいくつかあり、それらの上にカーソルを置いたときにテキストを表示する必要があります。これが私のコードです:

var text = R.text(X, Y, "some text");
R.circle(X, Y, 10).attr({"fill-opacity":0.8, fill:color, stroke: "white"})
        .mouseover(function () {
                this.animate({"fill-opacity": 1, 'transform':"s2 2"}, 500);}
            txt.show();
        })
        .mouseout(function () {
            this.animate({"fill-opacity": 0.8, 'transform':"s0.5 0.5"}, 500);}
            txt.hide();
        });

X と Y は、画面上にいくつかの円を描くループで計算されます。問題は、テキスト ショーが常に最後のものであり、位置も固定されていることです。このコードを機能させて、単一のテキストを各円にバインドするにはどうすればよいですか?

4

1 に答える 1

3

これを試して

var circle = R.circle(X, Y, 10).attr({"fill-opacity":0.8, fill:color, stroke: "white"});

circle.txt = R.text(circle.attr('x'), circle.attr('y'), "some text");

circle.mouseover(function () {
                  this.animate({"fill-opacity": 1, 'transform':"s2 2"}, 500);}
              this.txt.show();
          })
          .mouseout(function () {
              this.animate({"fill-opacity": 0.8, 'transform':"s0.5 0.5"}, 500);}
              this.txt.hide();
          });
于 2013-05-03T08:43:40.477 に答える