namespace('com.dfe.iss.jmsg'); var win; var winElm; com.dfe.iss.jmsg.moveWin = Ext.extend(Ext.Window, { border : false, shadow : false, closeAction : 'hide', title : '消息内容', id : 'MsgWin', x : 0, y : 0, // 以下自定义属性,可以在外部定义 moveSpeed : 12, // 移动速度(越大越慢),想改变,可是不行, winStep : 2, // 移动变量(像素),想改变,可是不行, stopTime : 60,//1为一秒 // 以下自定义属性,请不要在外部定义 winYtop : 0, winYbom : 0, winYtmp : 0, stopT : 0, initComponent : function() { var self = this; this.listeners = { 'afterrender' : { fn : function() { win = Ext.getCmp(this.id); winElm = Ext.get(this.id); Ext.TaskMgr.start({ run : function(){ if(self.winYtmp>=self.winYtop){ if(self.hidden == true) self.show(); Ext.TaskMgr.start(self.upTask); }else{ Ext.TaskMgr.start(self.downTask); } }, interval : self.stopT }); }, scope : self } }; if (this.width) { this.x = document.body.clientWidth-this.width; } if (this.height) { this.y = document.body.clientHeight; this.winYtop = document.body.clientHeight - this.height; this.winYbom = document.body.clientHeight; this.winYtmp = document.body.clientHeight; } if(this.stopTime){ this.stopT = this.stopTime*1000; } com.dfe.iss.jmsg.moveWin.superclass.initComponent.call(this); }, upTask : { run: function(){ if(win.winYtmp>=win.winYtop){ winElm.moveTo(win.x,win.winYtmp); win.winYtmp = win.winYtmp - win.winStep; }else{ winElm.moveTo(win.x,win.winYtop); Ext.TaskMgr.stop(this); } }, interval : 12 }, downTask :{ run : function(){ if(win.winYtmp<=win.winYbom){ winElm.moveTo(win.x,win.winYtmp); win.winYtmp = win.winYtmp + win.winStep; }else{ winElm.moveTo(win.x,win.winYbom); Ext.TaskMgr.stop(this); win.hide(); } }, interval : 12 }, winResize : function(){ var yChange = win.winYbom - document.body.clientHeight; win.x = document.body.clientWidth-win.width; win.winYtop = win.winYtop - yChange; win.winYbom = win.winYbom - yChange; win.winYtmp = win.winYtmp - yChange; winElm.moveTo(win.x,win.winYtmp); } }); winResize用于改变页面大小时,window始终保持在右下角。