var reportarray = ["REPORT0"]; //根据实际情况设置跑马灯报表块的名称,名称大写。 window.fobject = {}; for (i = 0; i < reportarray.length; i++) { fobject["flag" + i] = true; }
for (i = 0; i < reportarray.length; i++) { $("div[widgetname='" + reportarray[i] + "']").ready(function() { //function var index = i; let part; var self = '$("div[widgetname="' + reportarray[i] + ']")'; var name = reportarray[i]; console.log(name) setTimeout(function() { if ($('.scrollDiv').length == 0) //判断是否安装了自定义滚动条插件 {
if ($("div[widgetname=" + name + "]").find(".frozen-center").length == 1) //没安装,报表块有没有设置冻结 { part = $("div[widgetname=" + name + "]").find(".frozen-center"); //设置了冻结时 $("div[widgetname=" + name + "]").find(".frozen-north").css("overflow", "hidden"); $("div[widgetname=" + name + "]").find(".frozen-north").css("overflow-y", "hidden"); } else { part = $("div[widgetname=" + name + "]").find(".reportContent"); //没设置冻结时 } } else {
part = $("div[widgetname=" + name + "]").find(".scrollDiv"); //如果安装了插件,所有元素都是.scrollDiv } part.css("overflow", "hidden"); //去除滚动条 part.css("overflow-x", "hidden"); part.css("overflow-y", "hidden"); //兼容IE的去除滚动条 part.mouseover(function() { fobject["flag" + index] = false; }); //鼠标离开,继续滚动 part.mouseleave(function() { fobject["flag" + index] = true; }); var old = -1; setInterval(function() { if (fobject["flag" + index]) { currentpos = part[0].scrollTop; if (currentpos == old) { part[0].scrollTop = 0; } else { old = currentpos; //以25ms的速度每次滚动1.5PX part[0].scrollTop = currentpos + 1.5; } } }, 25); }, 300) }) } |