700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 常见JS效果之图片减速度滚动实现代码_图象特效

常见JS效果之图片减速度滚动实现代码_图象特效

时间:2022-07-31 04:22:15

相关推荐

常见JS效果之图片减速度滚动实现代码_图象特效

web前端|js教程

图片,减速度,滚动

web前端-js教程

感恩论坛源码下载,vscode va,ubuntu禁用ipv6,tomcat dtu,sqlite sum用法,云服务器怎么远程桌面,网页中的视频插件下载视频无法播放,前端主流框架介绍,ajax网页爬虫,如何运行php代码,蓝帽seo,卡盟网站模板,手机版网页源代码,中药材网站模板,手机页面搜索框,美发会员管理系统源码,直播程序php开发lzw

图片减速度滚动(by rentj1@;)

ul{ margin:0; padding:0}

ul{ list-style:none;}

body{font:12px/1.2 "宋体"; }

.scroll_box{ position:relative; height:164px; width:766px; border:1px solid #efefef; overflow:hidden;}

.scroll_box .list{ overflow:hidden; zoom:1; position:absolute;}

.scroll_box .list li{ width:235px; height:164px; padding:0 10px; text-align:center; float:left;}

.scroll_box .list .info{ line-height:1.5}

兵尼兔 环保大包围专车专用脚垫 米色(专车专用,仅支持在线支付)版型精准 大包围

会员价:¥288.00

商标查询源码,vscode画图教程,ubuntu火车,ssh启动 tomcat,c sqlite程序集,foxpay插件,前端框架的原理与作用,python爬虫爬网易标题,php汉字截取,铜陵seo推广排名,电商网站商品栏,滚动通知网页,emlog响应模板lzw

站长类源码,Ubuntu只显示老虎,爬虫抓取犯法吗,php正则 -,seo改动时间lzw

兵尼兔 环保大包围专车专用脚垫 米色(专车专用,仅支持在线支付)版型精准 大包围 会员价:¥288.00

兵尼兔 环保大包围专车专用脚垫 米色(专车专用,仅支持在线支付)版型精准 大包围 会员价:¥288.00

兵尼兔 环保大包围专车专用脚垫 米色(专车专用,仅支持在线支付)版型精准 大包围 会员价:¥288.00

兵尼兔 环保大包围专车专用脚垫 米色(专车专用,仅支持在线支付)版型精准 大包围 会员价:¥288.00

兵尼兔 环保大包围专车专用脚垫 米色(专车专用,仅支持在线支付)版型精准 大包围 会员价:¥288.00

untils = {

getComputedStyle: function(elem,syle){

var computedStyle = document.defaultView

&& document.defaultView.getComputedStyle

&& document.defaultView.getComputedStyle(elem,null);

if(!computedStyle){

computedStyle = elem.currentStyle

}

return computedStyle[syle]

},

setStyle: function(elem, name,val){

elem.style[name] = val;

},

get: function(id){

document.getElementById(id)

}

}

function ScrollSlider(container, content){

var clone = content.cloneNode(true);

var initcss= “left:0; top:0”;

var contentHeight = content.offsetHeight;

var containerHeight = container.clientHeight;

clone.id = “content-clone”;

container.appendChild(clone);

clone.setAttribute(“cssText”, initcss);

content.setAttribute(“cssText”, initcss);

clone.style.marginTop = contentHeight+”px”;

this.content = content;

this.clone = clone;

this.container = container;

this.containerHeight = containerHeight;

this.contentHeight = contentHeight;

}

ScrollSlider.prototype = {

start: function(delay){

var _this = this;

clearInterval(_this.timer);

_this.timer = setInterval(function(){

_this.scroll();

},delay);

},

scroll: function(){

var marginTop = parseInt(untils.getComputedStyle(this.content, “marginTop”));

var offsetTop = this.contentHeight;

if(isNaN(marginTop))return;

if( -marginTop >= this.contentHeight){

marginTop = this.contentHeight;

}

if(marginTop > 0){

offsetTop = -offsetTop;

}

this.move(marginTop, offsetTop);

},

move: function(marginTop, offsetTop){

var s = this.containerHeight, s1 = 0, _this = this, m = 0;

var timer = setInterval(function(){

var speed = (s-s1)/8;

speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);

s1 += speed;

m = marginTop – s1;

untils.setStyle(_this.content, “marginTop”, m + “px”);

untils.setStyle(_this.clone, “marginTop”, (m + offsetTop)+”px”);

if(s-s1 <= 0){

clearInterval(timer);

}

},30);

}

};

var container = document.getElementById(“container”)

var content = document.getElementById(“content”)

var xx = new ScrollSlider(container, content);

xx.start(1000*3);

/*

//s=1/2 * at^2

//s (att)/2

//0<s<164

0,-164,-328,164,0

328,164,0,-164,-328,164,0

*/

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。