帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» 一个利用图层展示上下滑动门帘门窗伸缩卷动特效
一个利用图层展示上下滑动门帘门窗伸缩卷动特效
浏览:559次
-
评论:0次
-
发布时间:2019-08-22
Html
Css
Js
#idGlideView { height:314px; width:325px; margin:0 auto; } #idGlideView div { width:325px; height:314px; }
var $$ = function (id) { return "string" == typeof id ? document.getElementById(id) : id; }; function Event(e){ var oEvent = document.all ? window.event : e; if (document.all) { if(oEvent.type == "mouseout") { oEvent.relatedTarget = oEvent.toElement; }else if(oEvent.type == "mouseover") { oEvent.relatedTarget = oEvent.fromElement; } } return oEvent; } function addEventHandler(oTarget, sEventType, fnHandler) { if (oTarget.addEventListener) { oTarget.addEventListener(sEventType, fnHandler, false); } else if (oTarget.attachEvent) { oTarget.attachEvent("on" + sEventType, fnHandler); } else { oTarget["on" + sEventType] = fnHandler; } }; var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } Object.extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } return destination; } var GlideView = Class.create(); GlideView.prototype = { //容器对象 容器宽度 展示标签 展示宽度 initialize: function(obj, iHeight, sTag, iMaxHeight, options) { var oContainer = $$(obj), oThis=this, len = 0; this.SetOptions(options); this.Step = Math.abs(this.options.Step); this.Time = Math.abs(this.options.Time); this._list = oContainer.getElementsByTagName(sTag); len = this._list.length; this._count = len; this._height = parseInt(iHeight / len); this._height_max = parseInt(iMaxHeight); this._height_min = parseInt((iHeight - this._height_max) / (len - 1)); this._timer = null; this.Each(function(oList, oText, i){ oList._target = this._height * i;//自定义一个属性放目标left oList.style.top = oList._target + "px"; oList.style.position = "absolute"; addEventHandler(oList, "mouseover", function(){ oThis.Set.call(oThis, i); }); }) //容器样式设置 oContainer.style.height = iHeight + "px"; oContainer.style.overflow = "hidden"; oContainer.style.position = "relative"; //移出容器时返回默认状态 addEventHandler(oContainer, "mouseout", function(e){ //变通防止执行oList的mouseout var o = Event(e).relatedTarget; if (oContainer.contains ? !oContainer.contains(o) : oContainer != o && !(oContainer.compareDocumentPosition(o) & 16)) oThis.Set.call(oThis, -1); }) }, //设置默认属性 SetOptions: function(options) { this.options = {//默认值 Step: 20,//滑动变化率 Time: 3,//滑动延时 TextTag: "",//说明容器tag TextHeight: 0//说明容器高度 }; Object.extend(this.options, options || {}); }, //相关设置 Set: function(index) { if (index < 0) { //鼠标移出容器返回默认状态 this.Each(function(oList, oText, i){ oList._target = this._height * i; if(oText){ oText._target = this._height_text; } }) } else { //鼠标移到某个滑动对象上 this.Each(function(oList, oText, i){ oList._target = (i <= index) ? this._height_min * i : this._height_min * (i - 1) + this._height_max; if(oText){ oText._target = (i == index) ? 0 : this._height_text; } }) } this.Move(); }, //移动 Move: function() { clearTimeout(this._timer); var bFinish = true;//是否全部到达目标地址 this.Each(function(oList, oText, i){ var iNow = parseInt(oList.style.top), iStep = this.GetStep(oList._target, iNow); if (iStep != 0) { bFinish = false; oList.style.top = (iNow + iStep) + "px"; } }) //未到达目标继续移动 if (!bFinish) { var oThis = this; this._timer = setTimeout(function(){ oThis.Move(); }, this.Time); } }, //获取步长 GetStep: function(iTarget, iNow) { var iStep = (iTarget - iNow) / this.Step; if (iStep == 0) return 0; if (Math.abs(iStep) < 1) return (iStep > 0 ? 1 : -1); return iStep; }, Each:function(fun) { for (var i = 0; i < this._count; i++) fun.call(this, this._list[i], (this.Showtext ? this._text[i] : null), i); } }; var gv = new GlideView("idGlideView", 314, "div", 280,"");
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
1.11.3
<!doctype html><html><head><meta charset="utf-8"><title>一个利用图层展示上下滑动门帘门窗伸缩卷动特效-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:利用图层展示上下滑动门帘门窗伸缩卷动特效,详细解说文章中相关滑动 门帘 门窗 伸缩 卷动 技术与知识。
让一组列表数字数组随机显示位置
jQuery倒计时按钮常用于验证码倒计时按钮
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
559
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值