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", width: 100});
},
// When the mouse goes away //
// this.g was already created. Destroy it!
function() {
this.g.remove();
});
}
-----------------------------------------节操分界线---------------------------------------------------------------
mouseover --> this.g = this.glow({color: "#FFF", width: 100});
mouseout --> this.g.remove();
妹的,太奇葩了有么有!看文档的人谁能想到是这么用的我陪睡啊。 居然你会发下this.g 的这个g,居然是任意的,只要不是"glow" 把本来的glow给覆盖了就可以,你甚至可以
mouseover --> this.xxoo = this.glow({color: "#FFF", width: 100});
mouseout --> this.xxoo.remove();
这个,太没节操了!
raphael.js 给元素 hover 添加glow() 外发光的更多相关文章
- Raphael.js改变元素层叠顺序
Raphael.js 元素(Element)改变层叠顺序,Raphael.js是一个矢量绘图库兼容svg和vml.初学时感觉css的z-index能搞定,结果是不支持,不过矢量绘图符合dom标准.可以 ...
- JS给元素循环添加事件的问题
<ul> <li>男</li> <li>女</li> <li>老</li> <li>少</li&g ...
- js数组元素的添加和删除
简单测试例子: var arr = new Array(); arr[0] = "aaa"; arr[1] = "bbb"; arr[2] = "cc ...
- JS数组方法汇总 array数组元素的添加和删除
js数组元素的添加和删除一直比较迷惑,今天终于找到详细说明的资料了,先给个我测试的代码^-^ var arr = new Array(); arr[0] = "aaa"; arr[ ...
- js在页面中添加一个元素 —— 添加弹幕
参考地址 [往下拉 —— 使用HTML DOM appendChild() 方法实现元素的添加 ] 一.创建 HTML <div class="right_liuyan"&g ...
- Raphael Js矢量库API简介:
Raphael Js矢量库API简介:Raphael Javascript 是一个 Javascript的矢量库. 2010年6月15日,著名的JavaScript库ExtJS与触摸屏代码库项目jQT ...
- 学习RaphaelJS矢量图形包--Learning Raphael JS Vector Graphics中文翻译(一)
(原文地址:http://www.cnblogs.com/idealer3d/p/LearningRaphaelJSVectorGraphics.html) 前面3篇博文里面,我们讲解了一本叫做< ...
- 当一个HTML元素需要添加mouseon、mouseout与click事件,或者mouserenter、mouseleave和click事件时,click事件无法触发
当一个HTML元素需要添加mouseon.mouseout与click事件,或者mouserenter.mouseleave和click事件时,click事件无法触发 针对上述问题,我遇到的有两种情况 ...
- 【2017-03-31】JS-DOM操作:操作属性、彩虹导航栏、定时器、操作内容、创建元素并添加、操作相关元素
一.操作属性 1.什么是属性: <div class="div" id="div1" style="" ></div> ...
随机推荐
- LAYOUT 注意点
1:CLK时钟GND全包,可以适当调整布局使包地完整. 2:WIFI天线下层均净空GND 3:过孔尽量不打在焊盘上或距离焊盘太近容易漏锡
- 接口自动化学习--testNG
一个月一更的节奏~ testNg是一个开源的自动化测试框架..具体那些什么特点的就不想打了- -,贴张图(虽然也看不懂): 学习网站:https://www.yiibai.com/testng 一样是 ...
- 【MOOC EXP】Linux内核分析实验一报告
程涵 原创博客 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 [反汇编一个简单的C程序] 实验 ...
- Spherical Hashing,球哈希
1. Introduction 在传统的LSH.SSH.PCA-ITQ等哈希算法中,本质都是利用超平面对数据点进行划分,但是在D维空间中,至少需要D+1个超平面才能形成一个封闭.紧凑的区域.而球哈希方 ...
- VSTS写单元测试
用VSTS写单元测试 许多应用程序都会用到“用户”类型,今天我要用的是ConsoleApplicatio ...
- Arduino下读取DHT22温湿度(不使用第三方库)
代码如下: #include <inttypes.h> /* * LED */ unsigned ; /* * DHT22配置程序 */ unsigned ; #define DHT_OK ...
- DHCP中续代理
什么是DHCP中继代理? 答:DCHP中继代理(即DHCP Relay Agent )用于转发来自于另一个没有DHCP服务器子网段中的客户端的DHCP请求,即当一台DCHP客户机发起请求后,此时DH ...
- 关于打包ipa文件以及苹果证书的若干问题
占位 包括windows下生成p12证书,以及apicloud云编译报错等内容.有空更新 http://www.applicationloader.net/blog/zh/2050.html?tdso ...
- php排序学习之-冒泡排序
原理:对一组数据,比较相邻数据的大小,将值小数据在前面,值大的数据放在后面. (以下都是升序排列,即从小到大排列) 举例说明: $arr = array(6, 3, 8, 2, 9, 1); $a ...
- 用prop还是attr
jquery中attr和prop的区别 在高版本的jquery引入prop方法后,什么时候该用prop?什么时候用attr?它们两个之间有什么区别?这些问题就出现了. 关于它们两个的区别,网上的答 ...