滚动效果_浏览器特效

模板酷站
  •       3/5
  •       1
  •       2
  •       3
  •       4
  •       5
查看演示效果

      织梦DedeCMS视频教程买空间 租服务器 选网硕互联! 无忧站长工具,百度权重一键全查!

      滚动效果,您可以先修改部分代码再运行.

      <HTML> <HEAD> <TITLE>滚动效果-模板无忧www.mb5u.com</TITLE> </HEAD> <BODY STYLE="overflow: hidden; border: 0" topmargin=0 leftmargin=0> <table> <tr><td style="padding: 5"> <div id="testDiv" style="border: buttonface 2 solid"> <img src="http://p1.mb5u.com/texiao/19/20100523005130145.gif"> </div> <script language="JScript"> function scroll(obj, oWidth, oHeight, direction, drag, zoom, speed) { var scrollDiv = obj var scrollContent = document.createElement("span") scrollContent.style.position = "absolute" scrollDiv.applyElement(scrollContent, "inside") var displayWidth = (oWidth != "auto" && oWidth ) ? oWidth : scrollContent.offsetWidth + parseInt(scrollDiv.currentStyle.borderRightWidth) var displayHeight = (oHeight != "auto" && oHeight) ? oHeight : scrollContent.offsetHeight + parseInt(scrollDiv.currentStyle.borderBottomWidth) var mrcWidth = scrollContent.offsetWidth var mrcHeight = scrollContent.offsetHeight var scrollXItems = Math.ceil(displayWidth / mrcWidth) + 1 var scrollYItems = Math.ceil(displayHeight / mrcHeight) + 1 scrollDiv.style.width = displayWidth scrollDiv.style.height = displayHeight scrollDiv.style.overflow = "hidden" scrollDiv.setAttribute("state", "stop") scrollDiv.setAttribute("drag", drag ? drag : "horizontal") scrollDiv.setAttribute("direction", direction ? direction : "left") scrollDiv.setAttribute("zoom", zoom ? zoom : 1) scrollContent.style.zoom = scrollDiv.zoom var scroll_script = "var scrollDiv = " + scrollDiv.uniqueID +"\n"+ "var scrollObj = " + scrollContent.uniqueID +"\n"+ "var mrcWidth = " + mrcWidth + " * (scrollObj.runtimeStyle.zoom ? scrollObj.runtimeStyle.zoom : 1)" +"\n"+ "var mrcHeight = " + mrcHeight + " * (scrollObj.runtimeStyle.zoom ? scrollObj.runtimeStyle.zoom : 1)" +"\n"+ "var scrollx = scrollObj.runtimeStyle.pixelLeft" +"\n"+ "var scrolly = scrollObj.runtimeStyle.pixelTop" +"\n"+ "switch (scrollDiv.state.toLowerCase())" +"\n"+ "{" +"\n"+ "case ('scroll') :" +"\n"+ "switch (scrollDiv.direction)" +"\n"+ "{" +"\n"+ "case ('left') :" +"\n"+ "scrollx = (--scrollx) % mrcWidth" +"\n"+ "break" +"\n"+ "case ('right') :" +"\n"+ "scrollx = -mrcWidth + (++scrollx) % mrcWidth" +"\n"+ "break" +"\n"+ "case ('up') :" +"\n"+ "scrolly = (--scrolly) % mrcHeight" +"\n"+ "break" +"\n"+ "case ('down') :" +"\n"+ "scrolly = -mrcHeight + (++scrolly) % mrcHeight" +"\n"+ "break" +"\n"+ "case ('left_up') :" +"\n"+ "scrollx = (--scrollx) % mrcWidth" +"\n"+ "scrolly = (--scrolly) % mrcHeight" +"\n"+ "break" +"\n"+ "case ('left_down') :" +"\n"+ "scrollx = (--scrollx) % mrcWidth" +"\n"+ "scrolly = -mrcHeight + (++scrolly) % mrcHeight" +"\n"+ "break" +"\n"+ "case ('right_up') :" +"\n"+ "scrollx = -mrcWidth + (++scrollx) % mrcWidth" +"\n"+ "scrolly = (--scrolly) % mrcHeight" +"\n"+ "break" +"\n"+ "case ('right_down') :" +"\n"+ "scrollx = -mrcWidth + (++scrollx) % mrcWidth" +"\n"+ "scrolly = -mrcHeight + (++scrolly) % mrcHeight" +"\n"+ "break" +"\n"+ "default :" +"\n"+ "return" +"\n"+ "}" +"\n"+ "scrollObj.runtimeStyle.left = scrollx" +"\n"+ "scrollObj.runtimeStyle.top = scrolly" +"\n"+ "break" +"\n"+ "case ('stop') :" +"\n"+ "case ('drag') :" +"\n"+ "default :" +"\n"+ "return" +"\n"+ "}" var mrcNode = document.createElement("span") mrcNode.runtimeStyle.position = "absolute" mrcNode.runtimeStyle.width = mrcWidth scrollContent.applyElement(mrcNode, "inside") for (var i=0; i <= scrollXItems; i++) { for (var j=0; j <= scrollYItems ; j++) { if (i+j == 0) continue var tempNode = mrcNode.cloneNode(true) var mrcLeft, mrcTop scrollContent.insertBefore(tempNode) mrcLeft = mrcWidth * i mrcTop = mrcHeight * j tempNode.runtimeStyle.left = mrcLeft tempNode.runtimeStyle.top = mrcTop } } scrollDiv.onpropertychange = function() { var propertyName = window.event.propertyName var propertyValue = eval("this." + propertyName) switch(propertyName) { case "zoom" : var scrollObj = this.children[0] scrollObj.runtimeStyle.zoom = propertyValue var mrc_width = scrollObj.children[0].offsetWidth * propertyValue var mrc_height = scrollObj.children[0].offsetHeight * propertyValue scrollObj.runtimeStyle.left = -mrc_width + (scrollObj.runtimeStyle.pixelLeft % mrc_width) scrollObj.runtimeStyle.top = -mrc_height + (scrollObj.runtimeStyle.pixelTop % mrc_height) break } } scrollDiv.onlosecapture = function() { this.state = this.tempState ? this.tempState : this.state this.runtimeStyle.cursor = "" this.removeAttribute("tempState") this.removeAttribute("start_x") this.removeAttribute("start_y") this.removeAttribute("default_left") this.removeAttribute("default_top") } scrollDiv.onmousedown = function() { if (this.state != "drag") this.setAttribute("tempState", this.state) this.state = "drag" this.runtimeStyle.cursor = "default" this.setAttribute("start_x", event.clientX) this.setAttribute("start_y", event.clientY) this.setAttribute("default_left", this.children[0].style.pixelLeft) this.setAttribute("default_top", this.children[0].style.pixelTop) this.setCapture() } scrollDiv.onmousemove = function() { if (this.state != "drag") return var scrollx = scrolly = 0 var zoomValue = this.children[0].style.zoom ? this.children[0].style.zoom : 1 var mrc_width = this.children[0].children[0].offsetWidth * zoomValue var mrc_Height = this.children[0].children[0].offsetHeight * zoomValue if (this.drag == "horizontal" || this.drag == "both") { scrollx = this.default_left + event.clientX - this.start_x scrollx = -mrc_width + scrollx % mrc_width this.children[0].runtimeStyle.left = scrollx } if (this.drag == "vertical" || this.drag == "both") { scrolly = this.default_top + event.clientY - this.start_y scrolly = -mrc_Height + scrolly % mrc_Height this.children[0].runtimeStyle.top = scrolly } } scrollDiv.onmouseup = function() { this.releaseCapture() } scrollDiv.state = "scroll" setInterval(scroll_script, speed ? speed : 20) } </script> <script language="JScript"> window.onload = new Function("scroll(document.all['testDiv'], 325)") </script> <br> <button onclick="testDiv.direction='up'; testDiv.state='scroll'"><span style="font-family: Webdings">5</span>向上</button> <button onclick="testDiv.direction='left'; testDiv.state='scroll'"><span style="font-family: Webdings">3</span>向左</button> <button onclick="testDiv.state='stop'"><span style="font-family: Webdings">;</span>停止</button> <button onclick="testDiv.state='scroll'"><span style="font-family: Webdings">8</span>播放</button> <button onclick="testDiv.direction='right'; testDiv.state='scroll'"><span style="font-family: Webdings">4</span>向右</button> <button onclick="testDiv.direction='down'; testDiv.state='scroll'"><span style="font-family: Webdings">6</span>向下</button> <br> 缩放: <select onchange="testDiv.zoom = this.options[selectedIndex].value"> <option value=1>100%</option> <option value=2>200%</option> <option value=3>300%</option> </select>      托动范围: <select onchange="testDiv.drag = this.options[selectedIndex].value"> <option value="both">随意</option> <option value="horizontal" selected>横向</option> <option value="vertical">纵向</option> </select> </td></tr> </table> </BODY> </HTML>