function AutoScroll(e) { for (i = 0; i < e.length; i++) { (function(e, i) { scroll(e, i); })(e, i); } } function scroll(e, i) { var $report = $(\"div[widgetname=\" + e[i].toUpperCase() + \"]\"); //获取对应report的div元素 var $scroll; if ($report.find(\".frozen-center\").length != 0) { $scroll = $report.find(\".frozen-center\"); } else if ($report.find(\".scrollDiv\").length != 0) { $scroll = $report.find(\".scrollDiv\"); } else { $scroll = $report.find(\".reportContent\"); } //判断是否冻结以及是否安装自定义滚动条插件 var flag = eval(\"window.flag\" + i); //设置全局flag,控制悬停 if (interval) { clearInterval(interval); } //清除定时器,避免越滚越快 var interval = eval(\"window.interval\" + i); $report.find(\"#frozen-center\").css(\'overflow-x\', \'hidden\'); $report.find(\"#frozen-center\").css(\'overflow-y\', \'hidden\'); $report.find(\"#frozen-north\").css(\'overflow-x\', \'hidden\'); $report.find(\"#frozen-north\").css(\'overflow-y\', \'hidden\'); //冻结情况下隐藏滚动条 $report.find(\".reportContent\").css(\'overflow-y\', \'hidden\'); $report.find(\".reportContent\").css(\'overflow-x\', \'hidden\'); //非冻结情况下隐藏滚动条 flag = true; $scroll.mouseover(function() { flag = false; }) //鼠标悬浮,滚动停止 $scroll.mouseleave(function() { flag = true; }) //鼠标离开,继续滚动 var old = -1; interval = setInterval(function() { if (flag) { currentpos = $scroll[0].scrollTop; //获取距顶部距离 if (currentpos == old) { $scroll[0].scrollTop = 0; //若已到达底部,则重置 } else { old = currentpos; $scroll[0].scrollTop = currentpos + 1.5; //若未到达底部,则向下移动1.5像素 } } }, 100); //以25ms的频率执行 }