简体   繁体   English

如何在Raphael JS中使圆圈和文本成为一个对象进行悬停?

[英]How to make circle and text inside the circle one object for hover in Raphael JS?

I have a circle (circle3) with a text inside (text3). 我有一个圆圈(circle3),里面有一个文本(text3)。 I want to animate the hover state which I can do nice with the circle, but the problem starts when I hover over the text inside the circle. 我想为悬浮状态设置动画,可以很好地处理圆圈,但是当我将鼠标悬停在圆圈内的文本上时,问题就开始了。 The javacscript thinks I am avay from circle and start the second part of the hover function. javacscript认为我没空,开始了悬停功能的第二部分。 But I need that it thinks that text area is part of the circle so it will stay in hover state even I hover over the text. 但是我需要它认为文本区域是圆的一部分,因此即使我将鼠标悬停在文本上,它也将保持悬停状态。 how to accomplish such thing? 如何完成这样的事情?

EDIT: I have figured out ho wto merge multiple object, however, know the fill atribute aplies also on the text not only the background (so the text is after hover not visible, because it has the same color as the background), so I need to somehow figured it out. 编辑:我已经想出了如何合并多个对象,但是,知道填充属性不仅取决于背景,而且也取决于文本(因此,悬停后该文本不可见,因为它具有与背景相同的颜色),所以我需要以某种方式弄清楚。 Any advice? 有什么建议吗?

My code that I need to modify: 我需要修改的代码:

st.push(
                                circle3,
                                text3
                            );

                            // st.animate(fillerHover, 500);
                            st.hover(function () {
                                st.animate(fillerHover, 500);
                              },
                              function () {
                                st.animate(filler, 500);
                              }
                            );

Ok

Ok, solved by myself. 好,由我自己解决。 This is the final working code: 这是最终的工作代码:

st.push(
                                    circle3,
                                    text3
                                );

                                st.attr({"cursor": "pointer"});


                                st.hover(function () {
                                    st.animate(fillerHover, 500);
                                    text3.animate(fillerTextHover, 500);
                                  },
                                  function () {

                                    st.animate(filler, 500);
                                    text3.animate(fillerText, 500);
                                  }
                                );

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

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