爱易网
IT新闻
IT新闻
爱易资讯
网站搭建
云虚拟主机教程
云服务器教程
Apache教程
IIS教程
Nginx教程
网站策划
站长文章
推广教程
淘宝客教程
网页设计
HTML教程
XHTML教程
CSS教程
HTML5教程
CSS3教程
JavaSript基础
JQuery教程
Node.js教程
前端技术
Ajax教程
Js特效
Xml教程
平面设计
页面UI设计
photoshop教程
程序开发
AI人工智能
Asp教程
Php教程
Asp.Net教程
Net Core教程
C#教程
Java教程
Jsp教程
开发技术
微信小程序教程
Uniapp开发教程
微信公众号开发
Andriod教程
IOS教程
DOS教程
Python教程
Docker教程
Windows Container教程
数据库
MSSQL教程
MySQL教程
Redis教程
Access教程
Oracle教程
数据库教程
操作系统
Linux教程
Windows教程
MAC教程
Cisco教程
交换机教程
防火墙教程
搜索
爱易网页
JS特效
js模拟iphone4手机滑锁功能特效代码
js模拟iphone4手机滑锁功能特效代码
日期:2014-05-18 浏览次数:20278 次
以下是程序代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>iPhone手机解锁效果</title> <style type="text/css"> #iphone{position:relative;width:426px;height:640px;margin:10px auto;background:url(http://js.aiyiweb.com/img/201108/111.jpg) no-repeat;} #lock{position:absolute;left:50%;bottom:33px;width:358px;height:62px;margin-left:-179px;} #lock span{position:absolute;width:93px;height:62px;cursor:pointer;background:url(http://js.aiyiweb.com/img/201108/btn.jpg) no-repeat;} </style> <script type="text/javascript"> window.onload = function () { var iPhone = document.getElementById("iphone"); var oLock = document.getElementById("lock"); var oBtn = oLock.getElementsByTagName("span")[0]; var disX = 0; var maxL = oLock.clientWidth - oBtn.offsetWidth; var oBg = document.createElement("img"); oBg.src = "http://js.aiyiweb.com/img/201108/222.jpg";//预加载下第二张背景,其它没什么大用。 oBtn.onmousedown = function (e) { var e = e || window.event; disX = e.clientX - this.offsetLeft; document.onmousemove = function (e) { var e = e || window.event; var l = e.clientX - disX; l < 0 && (l = 0); l > maxL && (l = maxL); oBtn.style.left = l + "px"; oBtn.offsetLeft == maxL && (iPhone.style.background = "url("+ oBg.src +")", oLock.style.display = "none"); return false; }; document.onmouseup = function () { document.onmousemove = null; document.onmouseup = null; oBtn.releaseCapture && oBtn.releaseCapture(); oBtn.offsetLeft > maxL / 2 ? startMove(maxL, function () { iPhone.style.background = "url("+ oBg.src +")"; oLock.style.display = "none" }) : startMove(0) }; this.setCapture && this.setCapture(); return false }; function startMove (iTarget, onEnd) { clearInterval(oBtn.timer); oBtn.timer = setInterval(function () { doMove(iTarget, onEnd) }, 30) } function doMove (iTarget, onEnd) { var iSpeed = (iTarget - oBtn.offsetLeft) / 5; iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed); iTarget == oBtn.offsetLeft ? (clearInterval(oBtn.timer), onEnd && onEnd()) : oBtn.style.left = iSpeed + oBtn.offsetLeft + "px" } }; </script> </head> <body> <div id="iphone"> <div id="lock"><span></span></div> </div> </body> </html>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
上一篇:狡猾的按钮特效
下一篇:使用JS编写面向对象版的放烟花效果代码
免责声明:
本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
相关资料
更多>
国美在线叫板京东:李俊涛底气在哪?
韩国研制无线充电系统:一次可充40部手机
刘强东:京东上市融资用于开拓三至六线城市
打车软件“明补变暗补”背后的小算盘
百度透露无人驾驶战略 研发三维交通地图
支付宝全面封杀比特币:充值码淘宝店或遭封禁
想玩P2P?几个您必须知道的潜规则
盛大游戏走向衰落的根源:免费游戏模式惹的祸
迅雷向美SEC提交IPO招股书:拟最多筹资1亿美元
推荐阅读
更多>
Line风靡亚洲,在北美却进展缓慢
中移动将推出多项4G资费新政
赴美开店,阿里11Main准备好了吗?
虚拟运营商们更像三大运营商的“二道贩子”
HTC手机为何一败再败?效果出在供应链
京东确定IPO定价区间 最高募资16.9亿美元
9月1日起免征新能源汽车购置税
湘鄂情剥离餐饮业务进军大数据的底气在哪里?
携程艺龙联手死磕同程 价钱烽烟蔓延至机票
2018年阿里云双11活动如何参加?1折优惠大攻略
英特尔涉嫌垄断 欧盟或开出史上最高罚单
喜大普奔:2016年国内乘客有望在飞机上使用手机
北京今日实现用支付宝钱包为公交卡充值
国内云服务商存在尴尬:“远程机房+移动大硬盘”模式
国内首个大数据系列指数今日发布
苹果30亿美元收购Beats
前苹果顾问批判iPhone命名:不应加S
诺基亚因充电器问题暂停销售Lumia 2520平板电脑
全球五大电信设备商业绩:华为净利居首
电信运营商员工涌入虚拟运营商,待遇差距多大?