How to add and remove glow for Raphael element?

前端 未结 5 1424
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-13 20:05

I am trying to set up a hover for a raphael element so that when the mouse is on the element, it has a glow and when the mouse leaves, the glow is removed. I have figured out ho

5条回答
  •  旧巷少年郎
    2021-02-13 20:57

    This is how I add / remove the glow effect using Raphael:

    paper.circle(x, y, r)
         .attr({fill: "lightblue", stroke: "lightblue", "stroke-width": 6})
         .hover(function() {
                    this.glowEffect = this.glow({color:"#1693A5", width: 2});                           
                }, function() {
                    this.glowEffect.remove();                       
                })
         .id = "example";
    

    I just add ".hover" to the Raphael element.

    You could also do something like:

    var c = paper.circle(x, y, r);
    c.hover(function() {
                    this.glowEffect = this.glow({color:"#1693A5", width: 2});                           
                }, function() {
                    this.glowEffect.remove();                       
                });
    

提交回复
热议问题