运行代码框 期待大家帮忙寻找新bug并提出宝贵建议,相信下一版本将做的更好,谢谢(QQ:149561420,gTalk: [email protected] )。
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
http://www.w3.org/1999/xhtml ">
* { margen:0; relleno: 0; }
cuerpo { margen:20px 0 400px 20px; fuente: 12px Arial; }
h1 {tamaño de fuente:14px; }
ol,ul { margen:20px; altura de línea: 160%; }
ul li {color:#f00; }
.a1 {ancho:300px; altura: 190 px; borde: 1px sólido #f00; desbordamiento:automático; }
.a2 {ancho:600px; altura: 350 px; margen:100px 0 100px 80px; borde: 1px sólido #369; fondo:#eee url( );
}
.dumascroll_bar {
posición:absoluta;
arriba: 0;
derecha: 0;
índice z: 9;
ancho: 14px;
altura: 100%;
cursor: predeterminado;
-moz-user-select:ninguno;
-khtml-user-select:ninguno;
selección de usuario: ninguna;
repetición de fondo: repetición-y;
posición de fondo: -42px 0;
flotador: izquierda;
}
.dumascroll_arrow_up,.dumascroll_arrow_up_a,.dumascroll_handle,.dumascroll_handle_a,.dumascroll_arrow_down,.dumascroll_arrow_down_a {
posición:absoluta;
izquierda: 0;
}
.dumascroll_arrow_up,.dumascroll_arrow_up_a,.dumascroll_arrow_down,.dumascroll_arrow_down_a {
ancho: 100%;
altura: 14px;
color:#fff;
alineación de texto:centro;
}
.dumascroll_arrow_up,.dumascroll_arrow_up_a { arriba:0; }
.dumascroll_arrow_down,.dumascroll_arrow_down_a {parte inferior:0; }
.dumascroll_handle,.dumascroll_handle_a { ancho:100%; repetición de fondo: repetición-y; }
.dumascroll_arrow_up { posición-fondo:0 0; }
.dumascroll_arrow_up_a { posición-fondo:-14px 0; }
.dumascroll_handle { posición-fondo:-28px 0; }
.dumascroll_handle_a { posición-fondo:-56px 0; }
.dumascroll_arrow_down { posición-fondo:-70px 0; }
.dumascroll_arrow_down_a { posición-fondo:-84px 0; }
var duma = {
$:función(o){ if(document.getElementById(o)) {return document.getElementById(o);} },
getStyle:function(o) { return o.currentStyle||document.defaultView.getComputedStyle(o,null); },
getOffset: función (o) {
var t = o.offsetTop,h = o.offsetHeight;
while(o = o.offsetParent) { t += o.offsetTop; }
return {arriba:t, altura:h};
},
enlazar: función (o, eType, fn) {
if(o.addEventListener) { o.addEventListener(eType,fn,false); }
else if(o.attachEvent) { o.attachEvent("on" + eType,fn); }
else { o["on" + eType] = fn; }
},
detenerEvento:función(e) {
mi = mi || ventana.evento;
e.stopPropagation && (e.preventDefault(),e.stopPropagation()) || (e.cancelBubble = verdadero,e.returnValue = falso);
},
setCookie:función(c_name,valor,días de vencimiento) {
var exdate = nueva fecha();
exdate.setDate(exdate.getDate() + días de caducidad);
document.cookie = c_name + "=" + escape(valor) + ((expiredays == null)? "" : ";expires=" + exdate.toGMTString());
},
obtenerCookie:función(c_name) {
if(documento.cookie.longitud > 0) {
c_start = document.cookie.indexOf(c_name + "=");
si(c_start!= -1) {
c_start = c_start + c_name.length + 1;
c_end = document.cookie.indexOf(";",c_start);
if(c_end == -1) { c_end = documento.cookie.length; }
devolver unescape(document.cookie.substring(c_start,c_end));
}
}
devolver "";
}
};
duma.BeautifyScrollBar = function(obj,arrowUpCss,arrowUpActiveCss,handleCss,handleActiveCss,arrowDownCss,arrowDownActiveCss) {
this.arrowUpInterval;
this.arrowDownInterval;
this.barMouseDownInterval;
esto.rely;
this.id = obj;
this.obj = duma.$(this.id);
this.setObjCss(); //预先设置父容器的css定位才能让接下来的属性设置起作用
this.obj.innerHTML = '
this.area = duma.$(obj + "Área");
this.bar = duma.$(obj + "Barra");
this.barPos;
this.arrowUp = this.bar.getElementsByTagName("div")[0];
this.arrowUpCss = flechaUpCss;
this.arrowUpActiveCss = flechaUpActiveCss;
this.handle = this.bar.getElementsByTagName("div")[1];
this.handleCss = manejarCss;
this.handleActiveCss = handleActiveCss;
this.arrowDown = this.bar.getElementsByTagName("div")[2];
this.arrowDownCss = flechaDownCss;
this.arrowDownActiveCss = flechaDownActiveCss;
this.handleMinHeight = 15;
this.arrowUpHeight = parseInt(duma.getStyle(this.arrowUp).height);
this.arrowDownHeight = parseInt(duma.getStyle(this.arrowDown).height);
this.areaScrollHeight = this.area.scrollHeight;
this.handleHeight = parseInt(this.area.offsetHeight/this.area.scrollHeight * (this.bar.offsetHeight - this.arrowUpHeight - this.arrowDownHeight));
}
duma.BeautifyScrollBar.prototipo = {
setObjCss:función() {
duma.getStyle(this.obj).position == "estático"? this.obj.style.position = "relativo": duma.getStyle(this.obj).backgroundColor == "transparente"? this.obj.style.backgroundColor = "#fff": nulo; //若容器本来就没有设position,则初始化为relative;若容器原来未设置背景色,则初始化为白色;
},
sehandle:function() { //当内容超多时设置拖拽条子的最小高度
this.handle.style.top = this.arrowUpHeight + "px";
if(this.handleHeight > this.handleMinHeight) {
this.handleHeight < this.bar.offsetHeight - this.arrowUpHeight - this.arrowDownHeight ? this.handle.style.height = this.handleHeight + "px" : this.handle.style.display = "none";
}
else { this.handleHeight = this.handleMinHeight; this.handle.style.height = this.handleMinHeight + "px"; }
},
setBarPos:function() { //将当前滚动的距离值存入cookie
this.barPos = this.area.scrollTop + "";
duma.setCookie(this.id + "CookieName",this.barPos,1);
},
getBarPos:función() {
this.barPos = duma.getCookie(this.id + "NombreCookie");
if(this.barPos!=null && this.barPos!="") {
this.area.scrollTop = this.barPos;
this.areaScroll();
}
},
clearArrowUpInterval:function() { clearInterval(this.arrowUpInterval); },
clearArrowDownInterval:function() { clearInterval(this.arrowDownInterval); },
clearBarMouseDownInterval:function() { clearInterval(this.barMouseDownInterval); },
desplazamiento de área: función() {
this.handle.style.display! = "ninguno"? this.handle.style.top = this.area.scrollTop/(this.area.scrollHeight - this.area.offsetHeight) * (this.bar.offsetHeight - this.handleHeight - this.arrowUpHeight - this.arrowDownHeight) + esto. flechaArribaAltura + "px": nulo;
},
areakeydown:function(e) { //支持键盘上下按键
var eso = esto;
documento.onkeydown = función (evento) {
var e = evento || ventana.evento,
ek = e.códigoclave || e.cual;
if(ek == 40) { that.area.scrollTop += 25 }
else if(ek == 38) { that.area.scrollTop -= 25 }
if(esa.area.scrollTop > 0 && esa.area.scrollTop < esa.area.scrollHeight - that.area.offsetHeight){ duma.stopEvent(e); }
eso.setBarPos();
}
},
manejarMovimiento:función(e) {
var mi = mi || ventana.evento;
this.area.scrollTop = (e.clientY - this.relY - this.arrowUpHeight)/(this.bar.offsetHeight - this.handleHeight - this.arrowUpHeight - this.arrowDownHeight)*(this.area.scrollHeight - this.area .offsetHeight);
this.setBarPos();
},
handleMouseDown: función (e) {
var eso = esto,e = e || ventana.evento;
that.relY = e.clientY - that.handle.offsetTop;
that.handle.setCapture? that.handle.setCapture(): nulo;
that.handle.className = that.handleActiveCss;
document.onmousemove = función(evento) { that.handleMove(evento); };
documento.onmouseup = función() {
that.handle.className = that.handleCss;
that.handle.releaseCapture? that.handle.releaseCapture(): nulo;
document.onmousemove = nulo;
};
},
barraDesplazamiento:función(e) {
var mi = mi || ventana.evento,eDir; //设置滚轮事件,e.wheelDelta与e.detail分别兼容IE、W3C,根据返回值的正负来判断滚动方向
if(e.wheelDelta) { eDir = e.wheelDelta/120; }
else if(e.detalle) { eDir = -e.detalle/3; }
eDir > 0 ? esta.area.scrollTop -= 80 : esta.area.scrollTop += 80; //步长设80像素比较接近window滚动条的滚动速度
if(this.area.scrollTop > 0 && this.area.scrollTop < this.area.scrollHeight - this.area.offsetHeight){ duma.stopEvent(e); }
this.setBarPos();
},
barraAbajo:función(e) {
var mi = mi || ventana.evento, eso = esto,
eY = e.clienteY,
mStep = this.bar.offsetHeight,
documentScrollTop = document.documentElement.scrollTop || documento.body.scrollTop,
hOffset = duma.getOffset(este.mango),
bOffset = duma.getOffset(esta.barra);
if(documentScrollTop + eY < hOffset.top) { this.barMouseDownInterval = setInterval(función(e){
esa.area.scrollTop -= esa.area.offsetHeight;
if(that.area.scrollTop <= (eY + documentScrollTop - bOffset.top - that.arrowUpHeight)/(that.bar.offsetHeight - that.arrowUpHeight - that.arrowDownHeight) * that.area.scrollHeight) { that.clearBarMouseDownInterval( ); }
eso.setBarPos();
},80); }
else if(documentScrollTop + eY > hOffset.top + hOffset.height) { this.barMouseDownInterval = setInterval(function(){
esa.area.scrollTop += esa.area.offsetHeight;
if(esa.area.scrollTop >= (eY + documentScrollTop - bOffset.top - that.arrowUpHeight - hOffset.height)/(that.bar.offsetHeight - that.arrowUpHeight - that.arrowDownHeight) * that.area.scrollHeight) { that.clearBarMouseDownInterval(); }
eso.setBarPos();
},80); }
duma.stopEvent(e);
},
flechaArribaRatónAbajo:función(e) {
var eso = esto;
this.arrowUpInterval = setInterval(function(){ that.area.scrollTop -= 25; that.setBarPos(); },10);
this.arrowUp.className = this.arrowUpActiveCss;
duma.stopEvent(e);
},
flechaUpMouseUp:función() { this.clearArrowUpInterval(); this.arrowUp.className = this.arrowUpCss; },
flechaUpMouseOut:función() { this.clearArrowUpInterval(); this.arrowUp.className = this.arrowUpCss; },
flechaAbajoRatónAbajo:función(e) {
var eso = esto;
this.arrowDownInterval = setInterval(function(){ that.area.scrollTop += 25; that.setBarPos(); },10);
this.arrowDown.className = this.arrowDownActiveCss;
duma.stopEvent(e);
},
flechaDownMouseUp:función() { this.clearArrowDownInterval(); this.arrowDown.className = this.arrowDownCss; },
flechaDownMouseOut:función() { this.clearArrowDownInterval(); this.arrowDown.className = this.arrowDownCss; },
ejecutar:función(){
var eso = esto;
this.sethandle();
this.areaScroll();
this.getBarPos();
this.area.onscroll = function(){that.areaScroll()};
this.area.onmouseover = this.bar.onmouseover = function(evento){that.areakeydown(evento)};
this.area.onmouseout = this.bar.onmouseout = function(){document.onkeydown = null};
this.handle.onmousedown = function(evento){that.handleMouseDown(evento)};
this.bar.onmousedown = función(evento){ese.barDown(evento)};
this.bar.onmouseup = function(){that.clearBarMouseDownInterval()};
this.bar.onmouseout = function(){that.clearBarMouseDownInterval()};
this.arrowUp.onmousedown = función(evento){that.arrowUpMouseDown(evento)};
this.arrowUp.onmouseup = function(){that.arrowUpMouseUp()};
this.arrowUp.onmouseout = function(){that.arrowUpMouseOut()};
this.arrowDown.onmousedown = función(evento){that.arrowDownMouseDown(evento)};
this.arrowDown.onmouseup = function(){that.arrowDownMouseUp()};
this.arrowDown.onmouseout = function(){that.arrowDownMouseOut()};
duma.bind(this.obj,"mousewheel",function(event){that.barScroll(event)});
duma.bind(this.obj,"DOMMouseScroll",function(event){that.barScroll(event)});
}
}
duma.BeautifyScrollBar.init = función() {
var o = document.getElementsByTagName("div"),
oLen = o.longitud,
dumascrollClass = /bdumascrollb/,
oArr = [],
oArrLen = oArr.longitud;
for(var i=0; i
oArr.push("dumaScrollAreaId_" + i);
oArrLen = oArr.longitud;
o[i].id = oArr[oArrLen - 1];
}
}
for(var j=0; j
}
}
duma.bind(ventana,"cargar",duma.BeautifyScrollBar.init);
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我是第一个被渲染的,真不幸
我还是普通的,我不希望被渲染,我就不用你的class,拿我怎么样?哈哈哈!
我还是普通的,我不希望被渲染,我就不用你的class,拿我怎么样?哈哈哈!
我还是普通的,我不Clase de 希望被渲染,我就不用你的,拿我怎么样?哈哈哈!
我还是普通的,我不希望被渲染,我就不用你的class,拿我怎么样?哈哈哈!
我还是普通的,我不希望被渲染,我就不用你的class,拿我怎么样?哈哈哈!
我还是普通的,我不希望被渲染,我就不用你的class,拿我怎么样?哈哈哈!
我还是普通的,我不希望被渲染,我就不用你的class,拿我怎么样?哈哈哈!
被渲染,我就不用你的clase,拿我怎么样?哈哈哈!
我还是普通的,我不希望被渲染,我就不用你的class,拿我怎么样?哈哈哈!
我还是普通的,我不Clase de 希望被渲染,我就不用你的,拿我怎么样?哈哈哈!
我还是普通的,我不希望被渲染,我就不用你的clase,拿我怎么样?哈哈哈!
22222
笨哟你,嵌套就嵌套,你不用他class就不会被渲染,你看看我,羡慕吧
笨哟你,嵌套就嵌套,你不用他class就不会被渲染,你看看我,羡慕吧
笨哟你,嵌套就嵌套,你不用他class就不会被渲染,你看看我,羡慕吧
笨哟你,嵌套就嵌套,你不用他class就不会被渲染,你看看我,羡慕吧
笨哟你,嵌套就嵌套,你不用他class就不会被渲染,你看看我,羡慕吧
笨哟你,嵌套就嵌套,你不用他class就不会被渲染,你看看我,羡慕吧
笨哟你,嵌套就嵌套,你不用他class就不会被渲染,你看看我,羡慕吧
笨哟你,嵌套就嵌套,你不用他class就不会被渲染,你看看我,羡慕吧
笨哟你,嵌套就嵌套,你不用他class就不会被渲染,你看看我,羡慕吧
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
fsdfs
11111111
图片自定义滚动条3.0(Duma“自动渲染版”,也许世间万物都会变,但是真挚的爱,却永远留存在心中!)
将来版本可继续扩展的功能有:
图片自定义滚动条3.0(Duma“自动渲染版”,也许世间万物都会变,但是真挚的爱,却永远留存在心中!)
将来版本可继续扩展的功能有: