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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
T
Tailwind CSS Blog
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
博客园 - 叶小钗
N
Netflix TechBlog - Medium
罗磊的独立博客
量子位
MyScale Blog
MyScale Blog
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
B
Blog
腾讯CDC
爱范儿
爱范儿
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
F
Fortinet All Blogs
雷峰网
雷峰网
G
Google Developers Blog
Google DeepMind News
Google DeepMind News

博客园 - jueban's space

js - jueban's space - 博客园 确定删除 - jueban's space - 博客园 SQL语句大全 上海 招聘 asp.net jq 的程序员 上海 招聘 asp.net jq 程序员 sql2005 asp.net2.0安全性(1)--用户角色篇(类) 常用编码工具类,支持base64,md5,des,crc32 reg 新城管如何变老城管 进度条 xss tt 可拖动,ModalPopup 新封装的仿kijiji的城市菜单 http://shanghai.myol.cn/ favicon.ico图标在线制作+ico下载 验证码 转贴 lightbox
用ajax.net封装的不间断marquee行为
jueban's space · 2008-03-13 · via 博客园 - jueban's space

/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace(
"DDT");
DDT.Direction 
= function(){};
DDT.Direction.prototype 
= {
        Left:
0,
        Right:
1,
        Up:
2,
        Down:
3
    } 
DDT.Direction.registerEnum(
"DDT.Direction");
DDT.Marqee 
= function(element) {
    DDT.Marqee.initializeBase(
this, [element]);    
    
this.EnumDirection  = DDT.Direction.Left;
    
this.Speed = 30;
    
this.TimeId = null;
}

DDT.Marqee.prototype 

= {
    initialize: 
function() {
        DDT.Marqee.callBaseMethod(
this'initialize');        
        
this.get_element().innerHTML += this.get_element().innerHTML;
        
this.get_element().style.overflow = "hidden";
        
if(this.EnumDirection==DDT.Direction.Left||this.EnumDirection==DDT.Direction.Right)
        {
            
this.get_element().style.whiteSpace="nowrap";            
        }
        
this._onMouseOverHandler = Function.createDelegate(this,this._onMouseOver);
        
this._onMouseOutHandler = Function.createDelegate(this,this._onMouseOut);
        
this._onMarqeeHandler = Function.createDelegate(this,this._onMarqee);
        $addHandler(
this.get_element(), "mouseover",this._onMouseOverHandler);
        $addHandler(
this.get_element(), "mouseout",this._onMouseOutHandler);
        
this.TimeId = setInterval(this._onMarqeeHandler,this.Speed);
        
// Add custom initialization here
    },_onMarqee:function(){
        
switch(this.EnumDirection)
        {
            
case DDT.Direction.Right:
                
if(this.get_element().scrollLeft<=0){                     
                    
this.get_element().scrollLeft = this.get_element().scrollWidth/2;                    
                }else{
                    
this.get_element().scrollLeft --;
                }
            
break;
            
case DDT.Direction.Up:
                
if(this.get_element().scrollTop>=(this.get_element().scrollHeight) /2){            
                    this.get_element().scrollTop = 0;
                }
else{
                    
this.get_element().scrollTop ++;
                }
            
break;
            
case DDT.Direction.Down:
                
if(this.get_element().scrollTop<=0){                               
                    
this.get_element().scrollTop = (this.get_element().scrollHeight) /2;
                }else{
                    
this.get_element().scrollTop --;
                }
            
break;
            
default:
                
if(this.get_element().scrollLeft>=this.get_element().scrollWidth/2){            
                    this.get_element().scrollLeft = 0;
                }
else{
                    
this.get_element().scrollLeft ++;
                }
            
break;
            
        }
        
    },_onMouseOver:
function(){
        clearInterval(
this.TimeId);        
    },_onMouseOut:
function(){
        
this.TimeId = setInterval(this._onMarqeeHandler,this.Speed);
    },
    dispose: 
function() {        
        
//Add custom dispose actions here
        DDT.Marqee.callBaseMethod(this'dispose');
    }
}
DDT.Marqee.registerClass(
'DDT.Marqee', Sys.UI.Behavior);if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

使用方法:

      $create(DDT.Marqee,{Speed:30,EnumDirection:DDT.Direction.Right},null,null,$get("UserScoreScroll"));