注意:文章中$$符号只有一个,因程序问题提交后变成了两个。

iPhone手机解锁效果

iPhone手机解锁效果,用JavaScript模拟的效果,两张图片,默认的解锁界面和解锁后的界面,用JavaScript控制图片拖动,拖动结束加载解锁后的界面,
这是基本原理,但是具体是如何实现,请参阅代码吧。

<!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(/jscss/demoimg/201212/1.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(/jscss/demoimg/201212/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://fgm.cc/iphone/2.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>
good 79

发表评论

文明评论,重在参与

暂无评论!
用著作权法来保护软件是否真的有 07-28
杀毒软件:只在搞娱乐,从未杀过 07-28
小谈高通反垄断 07-28
印度将推出百元智能机 山寨厂商 07-28
高通垄断之痛:不是国产手机大而 07-28
一张图读懂阿里巴巴眼花缭乱资本 07-28
滴滴打车副总裁张晶离职 高层换 07-28
小米官网明日首发小米4 预约即 07-28
如何勾引马云马化腾花钱买你公司 07-28
云智慧成为2014 Web性能 07-28
顺丰试水微信扫码支付:发快递无 07-28
从Facebook看百度的移动 07-28
返回JS代码-返回首页
首页 社区 工具 关于 网址
切换:1.0/2.0-电脑-//
2009-2025 版权所有 wap123.cn