zoukankan      html  css  js  c++  java
  • raphael.js 给元素 hover 添加glow() 外发光

     用raphael.js 给 svg画布里面添加个元素,嗯就圓好了,男人一般都喜欢圆形的东西,比如xx ,  xxx , 还有xxx

    $(document).ready(function() {
        var paper = Raphael(0,0,360,360);
        var myCircle = paper.circle(180,180,30).attr('stroke','#FFF');
        myCircle.hover(function() {
            myCircle.glow().attr('stroke','#FFF');
        }, function() {
            // removing the glow from the circle??
        });
    });
    

      

    raphael.js 官网的文档是在是羞涩难懂,它的文档里面对glow()的用法如下:

     Element.glow([glow])⚓➭
    
    Return set of elements that create glow-like effect around given element. See Paper.set.
    
    Note: Glow is not connected to the element. If you change element attributes it won’t adjust itself.
    
    Parameters
    glowobject
    parameters object with all properties optional:
    {
    widthnumber //size of the glow, default is 10
    fillboolean //will it be filled, default is false
    opacitynumber //opacity, default is 0.5
    offsetxnumber //horizontal offset, default is 0
    offsetynumber //vertical offset, default is 0
    colorstring //glow colour, default is black
    }
    Returns:objectPaper.set of elements that represents glow
    

      

     嗯,我也依然还是不晓得要怎么在mouseout的时候如何把这个glow()的效果给remove掉。

     后偶然发现一个奇葩的解决方案。

    function init(){
    // Creates canvas 320 × 200 at 10, 50
    var paper = Raphael(10, 50, 320, 200);
    
    // Creates circle at x = 50, y = 40, with radius 10
    var circle = paper.circle(50, 40, 10);
    // Sets the fill attribute of the circle to red (#f00)
    circle.attr("fill", "#f00");
    
    // Sets the stroke attribute of the circle to white
    circle.attr("stroke", "#fff");
    
    circle.hover(
    // When the mouse comes over the object //
    // Stock the created "glow" object in myCircle.g
    function() {
    this.g = this.glow({color: "#FFF",  100});
    },
    // When the mouse goes away //
    // this.g was already created. Destroy it!
    function() {
    this.g.remove();
    });
    }
    

      

     -----------------------------------------节操分界线---------------------------------------------------------------

    
    
    mouseover --> this.g = this.glow({color: "#FFF",  100});
    
    mouseout  --> this.g.remove();
    
    
    妹的,太奇葩了有么有!看文档的人谁能想到是这么用的我陪睡啊。

    居然你会发下this.g 的这个g,居然是任意的,只要不是"glow" 把本来的glow给覆盖了就可以,你甚至可以
     
    mouseover --> this.xxoo = this.glow({color: "#FFF",  100});
    
    mouseout  --> this.xxoo.remove();
    

      



    这个,太没节操了!
     


  • 相关阅读:
    Ecshop商品批量上传,内容编码错误 您尝试查看的页面无法显示
    php 数组转化成字符串,并原样还原回数组
    PHP函数 curl_setopt
    <javascript学习笔记> javascript 获得url里参数。
    <yii 框架学习> <转> 关于yii数据库添加新字段之后model类的修改
    <yii 框架学习> 清空数据表
    <javascript学习笔记>javascript 实现隔行变色
    <javascript学习笔记> javascript 检查输入内容的长度。
    <php 代码积累 数组相关>
    <yii 框架学习> yii 框架改为中文提示
  • 原文地址:https://www.cnblogs.com/litao229/p/3165362.html
Copyright © 2011-2022 走看看