惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
G
GRAHAM CLULEY
Security Latest
Security Latest
C
Cyber Attacks, Cyber Crime and Cyber Security
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic
S
Secure Thoughts
Simon Willison's Weblog
Simon Willison's Weblog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Help Net Security
Help Net Security
S
Schneier on Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - Franky
H
Heimdal Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The Cloudflare Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
人人都是产品经理
人人都是产品经理
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
雷峰网
雷峰网
Forbes - Security
Forbes - Security
IT之家
IT之家
The Hacker News
The Hacker News
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
N
News | PayPal Newsroom
AI
AI
博客园 - 三生石上(FineUI控件)
PCI Perspectives
PCI Perspectives
H
Hacker News: Front Page
Apple Machine Learning Research
Apple Machine Learning Research
N
News and Events Feed by Topic
WordPress大学
WordPress大学
P
Palo Alto Networks Blog
S
SegmentFault 最新的问题
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes
Cyberwarzone
Cyberwarzone
阮一峰的网络日志
阮一峰的网络日志
K
Kaspersky official blog
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
S
Security @ Cisco Blogs
Know Your Adversary
Know Your Adversary
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页

博客园 - Go_Rush

发一个python写的多线程 代理服务器 抓取,保存,验证程序,希望喜欢python的朋友和我一起完善它 根据生日或者日期 获取 生肖和星座的 JavaScript代码 身份证号码前六位所代表的省,市,区, 以及地区编码下载 15位, 18位的身份证号码的验证函数.以及根据身份证取省份,生日,性别 一个友好的.改善的 Object.prototype.toString的实现 发两个小东西,ASP/PHP 学习工具。 用JavaScript写的 怎样写一个通用的JavaScript效果库!(1/2) 自己写的几个高效,简洁的字符处理函数 无语,javascript居然支持中文(unicode)编程! ie 处理 gif动画 的onload 事件的一个 bug 讲两件事:1.this指针的用法小探. 2.ie的attachEvent和firefox的addEventListener在事件处理上的区别 总结两个Javascript的哈稀对象的一些编程技巧 使用prototype.js 的时候应该特别注意的几个问题. 再论怎么有效利用浏览器缓存之------怎么避免浏览器缓存静态文件. RE:对博客园URL的一些调整建议, 二级域名不利于客户端浏览器缓存 深入聊聊Array的sort方法的使用技巧.详细点评protype.js中的sortBy方法 由 element.appendChild(newNode) ,谈开去, 分享几个并不常见的Dom操作技巧给大家 在项目中玩了把addRule,结果差点被它玩死。附 addRule在firefox下的兼容写法 JavaScript写作技巧,函数A中调用函数B, 怎样在函数B中写代码中断函数A的运行?
怎样写一个通用的JavaScript效果库!(2/2)
Go_Rush · 2007-01-16 · via 博客园 - Go_Rush

续上回:  怎样写一个通用的JavaScript效果库!(1/2)

在上个随笔中贴出了效果库的整体框架,和一个简单的opacity插件. 今天这个随笔主要是扩展其他常用
效果插件,毕竟框架只能是个空壳,内容还是要自己充实。
如果看过了我上篇的实现细节,这里就不多说废话了,来段代码先:

/****************************************************/

// 移动, 这里是move to  就是移动到 x,y 当然,大家也可以再扩展一个move by  移动x个象素
Effect.Init.move=function(effect){   //初始化
    if (effect.options.x!==undefined || effect.options.y!==undefined){        
        
var pos=Position.cumulativeOffset(effect.element);
        effect.setting.left       
=pos[0];
        effect.setting.top          
=pos[1];
        effect.setting.position 
=effect.element.style.position;     
        effect.element.style.position    
="absolute"
        effect.options.x
=(effect.options.x===undefined)?effect.setting.left:effect.options.x;
        effect.options.y
=(effect.options.y===undefined)?effect.setting.top :effect.options.y;                        
    }

}


Effect.Fn.move
=function(effect,pos){     //效果
    if (effect.options.x===undefined && effect.options.y===undefined) return        
    effect.element.style.left
=effect.setting.left + (effect.options.x-effect.setting.left) * pos +"px";
    effect.element.style.top 
=effect.setting.top  + (effect.options.y-effect.setting.top ) * pos +"px";
}

/****************************************************/




/****************************************************/
// zoom   by Go_Rush(阿舜) from http://ashun.cnblogs.com/
Effect.Init.zoom=function(effect){    
    effect.setting.zoom      
=effect.element.style.zoom || 1;
    
// firefox 不支持 css的 zoom 用  改变 width,height的方式代替
    if (effect.options.zoom!==undefined && navigator.userAgent.toLowerCase().indexOf('firefox') != -1){                    
        effect.options.w
=effect.element.offsetWidth  * effect.options.zoom;
        effect.options.h
=effect.element.offsetHeight * effect.options.zoom;    
    }

}

Effect.Fn.zoom
=function(effect,pos){
    
if (effect.options.zoom===undefined) return;
    effect.element.style.zoom
=effect.setting.zoom+(effect.options.zoom-effect.setting.zoom)*pos
}


/****************************************************/


/****************************************************/
// size  同上,是 size to, 改变到指定大小 by Go_Rush(阿舜) from http://ashun.cnblogs.com/
Effect.Init.size=function(effect){
    
if (effect.options.w!==undefined || effect.options.h!==undefined){
        effect.setting.overflow   
=effect.element.style.overflow || 'visible';
        effect.setting.width      
=effect.element.offsetWidth;
        effect.setting.height      
=effect.element.offsetHeight; 
        effect.element.style.overflow 
="hidden"    
        effect.options.w
=(effect.options.w===undefined)?effect.setting.width :effect.options.w;
        effect.options.h
=(effect.options.h===undefined)?effect.setting.height:effect.options.h;            
    }

}


Effect.Fn.size
=function(effect,pos){    
    
if (effect.options.w===undefined && effect.options.h===undefined) return;
    effect.element.style.width 
=effect.setting.width + (effect.options.w-effect.setting.width ) * pos +"px";
    effect.element.style.height
=effect.setting.height+ (effect.options.h-effect.setting.height) * pos +"px";
}

/****************************************************/


/****************************************************/
// 背景色 by Go_Rush(阿舜) from http://ashun.cnblogs.com/
Effect.Init.bgcolor=function(effect){
    
if (effect.options.bgcolor!==undefined && /^\#?[a-f0-9]{6}$/i.test(effect.options.bgcolor)){
        
var color =effect.element.style.backgroundColor || "#ffffff";
        
//FireFox 下,即使css样式设置背景为 #ffffff格式,但程序取到的是 rgb(255,255,255)格式, 这里把他转化为 #ffffff格式
        if (/rgb/i.test(color)){               // "rgb(255, 0, 255)"
            //var arr=color.replace(/[rgb\(\s\)]/gi,"").split(",")
            var arr=eval(color.replace("rgb","new Array"))       
            color
="#"+Number(arr[0]).toColorPart()+Number(arr[1]).toColorPart()+Number(arr[2]).toColorPart()
        }

        effect.setting.bgcolor
=color
    }

}

Effect.Fn.bgcolor
=function(effect,pos){    
    
if (effect.options.bgcolor===undefined) return;
    
var c1=effect.setting.bgcolor,c2=effect.options.bgcolor
    
var arr1=[parseInt(c1.slice(1,3),16),parseInt(c1.slice(3,5),16),parseInt(c1.slice(5),16)]
    
var arr2=[parseInt(c2.slice(1,3),16),parseInt(c2.slice(3,5),16),parseInt(c2.slice(5),16)]
    
var r=Math.round(arr1[0]+(arr2[0]-arr1[0])*pos)
    
var g=Math.round(arr1[1]+(arr2[1]-arr1[1])*pos)
    
var b=Math.round(arr1[2]+(arr2[2]-arr1[2])*pos)
    effect.element.style.backgroundColor
="#"+r.toColorPart()+g.toColorPart()+b.toColorPart()
}

/****************************************************/


/****************************************************/
// 透明度,这个上个贴过了   by Go_Rush(阿舜) from http://ashun.cnblogs.com/
Effect.Init.opacity=function(effect){
    
if (effect.options.opacity===undefined) return;
    effect.setting.opacity
=Opacity(effect.element);    
}


Effect.Fn.opacity
=function(effect,pos){
    
if (effect.options.opacity===undefined) return;
    Opacity(effect.element,effect.setting.opacity
+(effect.options.opacity-effect.setting.opacity)*pos);    
}

/****************************************************/

这里 effect.setting 是非常有用而且非常重要的冬冬,所有的通过options传进来自定义函数都可以
通过effect.setting来获取element最初的设置。 在很多场合,我们需要在 options 中传一个 onComplete
函数进来, 用来在效果执行完毕后,打扫战场,恢复一些设置。
这些效果是可以重叠的,大家可以看看下面我写的例子。

写了十来个例子,应该很详细了。

完整的,可调试代码和例子如下:

全部代码附范例