欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

js實(shí)現(xiàn)類(lèi)似iphone的網(wǎng)頁(yè)滑屏解鎖功能示例【附源碼下載】-創(chuàng)新互聯(lián)

本文實(shí)例講述了js實(shí)現(xiàn)類(lèi)似iphone的網(wǎng)頁(yè)滑屏解鎖功能。分享給大家供大家參考,具體如下:

創(chuàng)新互聯(lián)公司專(zhuān)注為客戶(hù)提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于做網(wǎng)站、網(wǎng)站設(shè)計(jì)、睢寧縣網(wǎng)絡(luò)推廣、成都微信小程序、睢寧縣網(wǎng)絡(luò)營(yíng)銷(xiāo)、睢寧縣企業(yè)策劃、睢寧縣品牌公關(guān)、搜索引擎seo、人物專(zhuān)訪(fǎng)、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們大的嘉獎(jiǎng);創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供睢寧縣建站搭建服務(wù),24小時(shí)服務(wù)熱線(xiàn):13518219792,官方網(wǎng)址:chinadenli.net

iphone 的出現(xiàn),打破了人們的用戶(hù)體驗(yàn),這一用戶(hù)體驗(yàn)也延伸到了網(wǎng)頁(yè)設(shè)計(jì)上。最近看到很多blog的評(píng)論都用類(lèi)似iphone滑動(dòng)解鎖的方式實(shí)現(xiàn)。只有滑動(dòng)解鎖之后才能評(píng)論,或者做其他的事情。這個(gè)功能的實(shí)現(xiàn),其實(shí)并不麻煩,關(guān)鍵是要有好的美工,做出好的滑動(dòng)圖片,然后javascript配合CSS就可以完成,我在這里也簡(jiǎn)單實(shí)現(xiàn)了一個(gè),基本功能如下

1. 打開(kāi)頁(yè)面時(shí)隱藏評(píng)論框,你可以做成disable形式,下載源碼后可以修改。
2. 滑動(dòng)解鎖圖片,顯示評(píng)論框,你可以做成讓textarea字段enable方式。
3. 采用原生javascript實(shí)現(xiàn),兼容ie,firefox,chrome,safari.

效果圖基本如下:

js實(shí)現(xiàn)類(lèi)似iphone的網(wǎng)頁(yè)滑屏解鎖功能示例【附源碼下載】

js實(shí)現(xiàn)類(lèi)似iphone的網(wǎng)頁(yè)滑屏解鎖功能示例【附源碼下載】

你可以改動(dòng)部分源代碼測(cè)試,加入你自己想要的邏輯。

源代碼貼在下面,你也可以在文章的最后下載:

<!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>yihaomen.com js滑屏解鎖</title>
<style type="text/css"> 
#slider_comment{position:relative;width:426px;height:640px;margin:10px auto;}
#lock{width:200px;height:30px;border:1px dashed #ccc;line-height:30px;}
#lock span{position:absolute;width:45px;height:30px;cursor:pointer;background:url(img/arrow.png) no-repeat;}
</style>
<script type="text/javascript"> 
window.onload = function ()
{
  var slider_comment = document.getElementById("slider_comment");
  var oLock = document.getElementById("lock");
  var oBtn = oLock.getElementsByTagName("span")[0];
  var comment=document.getElementById('comment');
  var disX = 0;
  var maxL = oLock.clientWidth - oBtn.offsetWidth;  
  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 && (comment.style.display="block",oLock.innerHTML = "請(qǐng)輸入評(píng)論內(nèi)容");
      return false;
    };
    document.onmouseup = function ()
    {
      document.onmousemove = null;
      document.onmouseup = null;
      oBtn.releaseCapture && oBtn.releaseCapture();
      oBtn.offsetLeft > maxL / 2 ?
        startMove(maxL, function ()
        {
          comment.style.display="block";
          oLock.innerHTML = "請(qǐng)輸入評(píng)論內(nèi)容";
          oLock.style.display = "block";
        }) :
        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="slider_comment">
<div id="lock"><span></span></div>
<div id="comment" >
  <textarea id="comment_text" rows=5 ></textarea>
</div>
</div>
</body>
</html>

本文名稱(chēng):js實(shí)現(xiàn)類(lèi)似iphone的網(wǎng)頁(yè)滑屏解鎖功能示例【附源碼下載】-創(chuàng)新互聯(lián)
標(biāo)題URL:http://chinadenli.net/article12/degpdc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、定制網(wǎng)站、做網(wǎng)站響應(yīng)式網(wǎng)站、App設(shè)計(jì)、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

營(yíng)銷(xiāo)型網(wǎng)站建設(shè)