图片从右至左滚动JS
前几天工作时遇到的一问题,不会写JS,请大猪来帮我写的,谢谢大猪了。
图片从右至左滚动JS代码:
1、直线滚动
var x =800
var y=300
var yp=35
var yn=0
var yin=true
var xin = true
var step = 1
var delay = 30
var obj=document.getElementById("ad")
function floatAD() {
var L=-obj.offsetWidth;
var R= document.body.clientWidth-obj.offsetWidth
obj.style.left = x + document.body.scrollLeft
x = x + step*(xin?1:-1)
if (x R){ xin = false; x = R}
var T=0
var B = document.body.clientHeight-obj.offsetHeight
obj.style.top =y+ yn+ document.body.scrollTop
if (yin){ yn=yn+1/Math.sin(1);}
else{yn=yn-1/Math.sin(1);}
if (yn >yp) { yin = false }
if (yn
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
2、波浪滚动
[X]
var x = 800
var y=300
var yp=35
var yn=0
var yin=true
var xin = true
var step = 1
var delay =20
var obj=document.getElementById("ad")
var itl
function CloseAD(){
clearInterval(itl);
obj.style.display="none";
}
function floatAD() {
var L=-obj.offsetWidth;
var R= document.body.clientWidth-obj.offsetWidth
obj.style.left = x + document.body.scrollLeft
x = x + step*(xin?1:-1)
if (x R){ xin = false; x = R}
var T=0
obj.style.top =y+ yn+ document.body.scrollTop
if (x%2==0){
if (yin){ yn=yn+1/Math.sin(1);}
else{yn=yn-1/Math.sin(1);}
if (yn >yp) { yin = false }
if (yn
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]