繁体   English   中英

在Raphael.js中查看鼠标悬停的文本

[英]Viewing text on mouse over in Raphael.js

我有一些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在循环中计算,在屏幕上形成几个圆圈。 问题是文本节目总是最后一个,位置也是固定的。 如何让这段代码工作并将单个文本绑定到每个圆圈?

尝试这个

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();
          });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM