最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery插件實(shí)現(xiàn)彈性運(yùn)動(dòng)完整示例

 更新時(shí)間:2018年07月07日 16:00:52   作者:菜園子丶  
這篇文章主要介紹了jQuery插件實(shí)現(xiàn)彈性運(yùn)動(dòng),結(jié)合完整實(shí)例形式分析了jQuery插件擴(kuò)展結(jié)合定時(shí)器實(shí)現(xiàn)頁(yè)面元素抖動(dòng)的相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery插件實(shí)現(xiàn)彈性運(yùn)動(dòng)的方法。分享給大家供大家參考,具體如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>www.fzitv.net jQuery彈性運(yùn)動(dòng)</title>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
// JavaScript Document
(function($){
  $.fn.moveTx=function(json)
  {
    var i=0;
    for(i=0;i<this.length;i++)//重要
    {
      startMove(this[i],json);
    }
    function getStyle(obj, attr)
    {
      if(obj.currentStyle)
      {
        return obj.currentStyle[attr];
      }
      else
      {
        return getComputedStyle(obj, false)[attr];
      }
    }
var iSpeed=0;
var iTget=0;
function startMove(obj,json)
{
  clearInterval(obj.timer);
  obj.timer=setInterval(function (){
    for(var attr=0 in json)
    {
      iSpeed+=(json[attr]-parseInt(getStyle(obj, attr)))/5;
      iSpeed*=0.7;
      iTget+=iSpeed;
      if(Math.abs(iSpeed)<1 && Math.abs(iTget-json[attr])<1)
      {
        clearInterval(obj.timer);
        obj.style[attr]=json[attr]+'px';
      }
      else
      {
        obj.style[attr]=iTget+'px';
      }
    }
  }, 30);
}
}})(jQuery)
$(function(){
  var oDiv=$('#zgz')
  oDiv.click(function(){
    $(this).moveTx({left:500})
  })
})
</script>
<style>
#zgz{ width:80px; height:80px; background-color:#f00;position:absolute; left:0px; top:20px; color:#fff; padding:10px;}
#xt{ width:1px; height:500px; background-color:#000; position:absolute; left:500px; top:0px;}
</style>
</head>
<body>
<div id="zgz">彈性運(yùn)動(dòng)</div>
<div id="xt"></div>
</body>
</html>

運(yùn)行效果:

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery切換特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery常見(jiàn)經(jīng)典特效匯總》、《jQuery動(dòng)畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

邵武市| 嵊泗县| 宜阳县| 三明市| 松溪县| 红桥区| 株洲市| 珠海市| 同仁县| 遂溪县| 阜城县| 荣成市| 隆回县| 天水市| 吉林省| 罗山县| 工布江达县| 乌审旗| 金溪县| 交口县| 镇坪县| 鄢陵县| 邓州市| 抚顺县| 神池县| 霸州市| 巴南区| 兴业县| 陆丰市| 五原县| 简阳市| 雅安市| 新密市| 连州市| 南开区| 周口市| 本溪| 山阳县| 界首市| 祥云县| 尚志市|