Ext 实现无滚动条内容滚动.doc
文本预览下载声明
Ext 实现无滚动条内容滚动
最近项目需要,写个面板,如果内容过长,自动隐藏,下面提示更多,鼠标可以滚动查看内容也可点击查看。
//初始化滚动栏 var InitScrollBar = function (conf) { this.Container = Ext.get(conf.container); this.MaxScroll = conf.height ? 200 : conf.height; this.ScrollBox = Ext.get(conf.txtContainer); this.ScrollContent = Ext.get(conf.txtContent); this.ScrollTrack = conf.scrollBar ? conf.scrollBar : null; var ObjScroll = this; if(this.ScrollTrack) { this.ScrollBox.parent().createChild({ tag: div, id: scrollbar, cls: slidebar, html: div id=\handle\ class=\handle\/div }); this.ScrollTrack = Ext.get(scrollbar); this.ScrollHandle = Ext.get(handle); this.ScrollBox.setStyle(width, this.Container.getWidth() - this.ScrollTrack.getWidth() - 2 + px); } //对象不存在 if (!(this.ScrollBox this.ScrollContent)) { return; } //是否内容超过指定高度 this.ScrollAmount = this.ScrollContent.getHeight() / this.MaxScroll; if (this.ScrollAmount 1) { if(this.ScrollTrack) { this.ScrollHandle.on(mousedown, function(e) { //拖动滚轴 dragScroll(e); }); this.ScrollTrack.setStyle(height, this.MaxScroll + px); //设置滑块的默认位置 this.ScrollHandle.setStyle(margin-top, 0px); //设置滑块的高度 this.ScrollHandle.setStyle(height, Math.floor(this.MaxScroll / this.ScrollAmount) + px); } this.ScrollContent.on(mousewheel, function(e) { //鼠标滚轴事件 wheelScroll(e); });
显示全部