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

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

博客园 - zhuibobo

SQL将多行连接显示 SQL逻辑查询处理中的各个阶段 基于Web用户控件的Portal flex-流程设计器 WebHL(模仿QQ写的Ajax程序)^_^ JavaScript笔记(可以被钉住的层) 新手的入门-设计模式二[一块开工厂把~] 新手的入门-设计模式一[玩玩策略吗?] 读取sql2000,sql2005中的表结构[转贴] 代码生成器(Asp.net(C#)) 十五天的假期-11 十五天的假期-9 十五天的假期-10 十五天的假期-8 十五天的假期-7 十五天的假期-5 十五天的假期-6 十五天的假期-4 十五天的假期-3
JavaScript笔记(带动画效果弹出的层)
zhuibobo · 2008-01-06 · via 博客园 - zhuibobo

    好久没写过js的东西了..从前一段时间痴迷过后,最近有见识到了ext的强大,不过嘛,写一些简单的,基础的实现还是自己来好了..不过ext确实很强大,没看过的人试试把~呵呵~
    这是一个带动画效果的弹出的层,然后关闭也加入了动画的效果,然后使层具有被拖动的功能.动画效果其实就是用了4个偏移量left,top,x,y和定时器实现的.拖动嘛,是注册带document的mousemove的事件实现的.
   先看看拖动的代码..
   canBeDrag.prototype={
        initialize:function(sender)
        {
            sender.onmousedown=function()
            {
                var backDiv=this.backDiv;
                var offsetX=event.clientX-sender.offsetLeft;
                var offsetY=event.clientY-sender.offsetTop;
                document.body.onmousemove=function()
                {
                    sender.style.left=event.x-offsetX;
                    sender.style.top=event.y-offsetY;
                }
            }
            sender.onmouseup=function()
            {
                document.body.onmousemove=null;
                document.body.onmouseup=function()
                {
                    document.body.onmousemove=null;
                }
            }
        }
        }
然后要让这个层可以拖动注册
var sender1=$("dragDiv1");
var sender2=$("dragDiv2");
var sender3=$("dragDiv3");
var drag1=new canBeDrag(sender1);
var drag2=new canBeDrag(sender2);
var drag3=new canBeDrag(sender3);就可以了

恩,因为用了prototype来定义的类,所以就不全帖出来了..有兴趣的直接下载下去看看把~呵呵.
例子下载

posted on 2008-01-06 18:33  zhuibobo  阅读(1333)  评论()    收藏  举报