pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <bdo id='aRdsZ'></bdo><ul id='aRdsZ'></ul>
<i id='aRdsZ'><tr id='aRdsZ'><dt id='aRdsZ'><q id='aRdsZ'><span id='aRdsZ'><b id='aRdsZ'><form id='aRdsZ'><ins id='aRdsZ'></ins><ul id='aRdsZ'></ul><sub id='aRdsZ'></sub></form><legend id='aRdsZ'></legend><bdo id='aRdsZ'><pre id='aRdsZ'><center id='aRdsZ'></center></pre></bdo></b><th id='aRdsZ'></th></span></q></dt></tr></i><div class="umhz5g0" id='aRdsZ'><tfoot id='aRdsZ'></tfoot><dl id='aRdsZ'><fieldset id='aRdsZ'></fieldset></dl></div>
  • <small id='aRdsZ'></small><noframes id='aRdsZ'>

      <tfoot id='aRdsZ'></tfoot>
        <legend id='aRdsZ'><style id='aRdsZ'><dir id='aRdsZ'><q id='aRdsZ'></q></dir></style></legend>
      1. 帶有 jquery.animate() 的 CSS 旋轉跨瀏覽器

        CSS rotation cross browser with jquery.animate()(帶有 jquery.animate() 的 CSS 旋轉跨瀏覽器)
      2. <legend id='LkldJ'><style id='LkldJ'><dir id='LkldJ'><q id='LkldJ'></q></dir></style></legend>

            • <bdo id='LkldJ'></bdo><ul id='LkldJ'></ul>

              <tfoot id='LkldJ'></tfoot>
              1. <small id='LkldJ'></small><noframes id='LkldJ'>

                  <tbody id='LkldJ'></tbody>

                  <i id='LkldJ'><tr id='LkldJ'><dt id='LkldJ'><q id='LkldJ'><span id='LkldJ'><b id='LkldJ'><form id='LkldJ'><ins id='LkldJ'></ins><ul id='LkldJ'></ul><sub id='LkldJ'></sub></form><legend id='LkldJ'></legend><bdo id='LkldJ'><pre id='LkldJ'><center id='LkldJ'></center></pre></bdo></b><th id='LkldJ'></th></span></q></dt></tr></i><div class="0ffipdf" id='LkldJ'><tfoot id='LkldJ'></tfoot><dl id='LkldJ'><fieldset id='LkldJ'></fieldset></dl></div>
                  本文介紹了帶有 jquery.animate() 的 CSS 旋轉跨瀏覽器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在創建一個跨瀏覽器兼容的旋轉 (ie9+),我在 jsfiddle 中有以下代碼

                  I'm working on creating a cross-browser compatible rotation (ie9+) and I have the following code in a jsfiddle

                  $(document).ready(function () { 
                      DoRotate(30);
                      AnimateRotate(30);
                  });
                  
                  function DoRotate(d) {
                  
                      $("#MyDiv1").css({
                            '-moz-transform':'rotate('+d+'deg)',
                            '-webkit-transform':'rotate('+d+'deg)',
                            '-o-transform':'rotate('+d+'deg)',
                            '-ms-transform':'rotate('+d+'deg)',
                            'transform': 'rotate('+d+'deg)'
                       });  
                  }
                  
                  function AnimateRotate(d) {
                  
                          $("#MyDiv2").animate({
                            '-moz-transform':'rotate('+d+'deg)',
                            '-webkit-transform':'rotate('+d+'deg)',
                            '-o-transform':'rotate('+d+'deg)',
                            '-ms-transform':'rotate('+d+'deg)',
                            'transform':'rotate('+d+'deg)'
                       }, 1000); 
                  }
                  

                  CSS 和 HTML 非常簡單,僅用于演示:

                  The CSS and HTML are really simple and just for demo:

                  .SomeDiv{
                      width:50px;
                      height:50px;       
                      margin:50px 50px;
                      background-color: red;}
                  
                  <div id="MyDiv1" class="SomeDiv">test</div>
                  <div id="MyDiv2" class="SomeDiv">test</div>
                  

                  旋轉在使用 .css() 時有效,但在使用 .animate() 時無效;為什么會這樣?有辦法解決嗎?

                  The rotation works when using .css() but not when using .animate(); why is that and is there a way to fix it?

                  謝謝.

                  推薦答案

                  目前尚無法使用 jQuery 制作 CSS-Transforms 動畫.你可以這樣做:

                  CSS-Transforms are not possible to animate with jQuery, yet. You can do something like this:

                  function AnimateRotate(angle) {
                      // caching the object for performance reasons
                      var $elem = $('#MyDiv2');
                  
                      // we use a pseudo object for the animation
                      // (starts from `0` to `angle`), you can name it as you want
                      $({deg: 0}).animate({deg: angle}, {
                          duration: 2000,
                          step: function(now) {
                              // in the step-callback (that is fired each step of the animation),
                              // you can use the `now` paramter which contains the current
                              // animation-position (`0` up to `angle`)
                              $elem.css({
                                  transform: 'rotate(' + now + 'deg)'
                              });
                          }
                      });
                  }
                  

                  您可以在此處閱讀有關 step-callback 的更多信息:http://api.jquery.com/動畫/#step

                  You can read more about the step-callback here: http://api.jquery.com/animate/#step

                  http://jsfiddle.net/UB2XR/23/

                  而且,順便說一句:您不需要為 jQuery 1.7+ 的 css3 轉換添加前綴

                  And, btw: you don't need to prefix css3 transforms with jQuery 1.7+

                  您可以將其包裝在一個 jQuery 插件中,讓您的生活更輕松:

                  You can wrap this in a jQuery-plugin to make your life a bit easier:

                  $.fn.animateRotate = function(angle, duration, easing, complete) {
                    return this.each(function() {
                      var $elem = $(this);
                  
                      $({deg: 0}).animate({deg: angle}, {
                        duration: duration,
                        easing: easing,
                        step: function(now) {
                          $elem.css({
                             transform: 'rotate(' + now + 'deg)'
                           });
                        },
                        complete: complete || $.noop
                      });
                    });
                  };
                  
                  $('#MyDiv2').animateRotate(90);
                  

                  http://jsbin.com/ofagog/2/edit

                  我對其進行了一些優化,以使 easingdurationcomplete 的順序無關緊要.

                  I optimized it a bit to make the order of easing, duration and complete insignificant.

                  $.fn.animateRotate = function(angle, duration, easing, complete) {
                    var args = $.speed(duration, easing, complete);
                    var step = args.step;
                    return this.each(function(i, e) {
                      args.complete = $.proxy(args.complete, e);
                      args.step = function(now) {
                        $.style(e, 'transform', 'rotate(' + now + 'deg)');
                        if (step) return step.apply(e, arguments);
                      };
                  
                      $({deg: 0}).animate({deg: angle}, args);
                    });
                  };
                  

                  更新 2.1

                  感謝 matteo誰注意到完整-callback 中的this-context 存在問題.如果通過 binding 在每個節點上使用 jQuery.proxy 的回調來修復它.

                  Update 2.1

                  Thanks to matteo who noted an issue with the this-context in the complete-callback. If fixed it by binding the callback with jQuery.proxy on each node.

                  我在 Update 2 之前已將版本添加到代碼中.

                  I've added the edition to the code before from Update 2.

                  如果您想要執行諸如來回切換旋轉之類的操作,這是一個可能的修改.我只是在函數中添加了一個 start 參數并替換了這一行:

                  This is a possible modification if you want to do something like toggle the rotation back and forth. I simply added a start parameter to the function and replaced this line:

                  $({deg: start}).animate({deg: angle}, args);
                  

                  如果有人知道如何使其對所有用例更通用,無論他們是否想設置起始學位,請進行適當的編輯.

                  If anyone knows how to make this more generic for all use cases, whether or not they want to set a start degree, please make the appropriate edit.

                  主要有兩種方法可以達到預期的結果.但首先,讓我們看一下論據:

                  Mainly you've two ways to reach the desired result. But at the first, let's take a look on the arguments:

                  jQuery.fn.animateRotate(角度、持續時間、緩動、完成)

                  除了角度"之外,它們都是可選的并且回退到默認的jQuery.fn.animate-properties:

                  Except of "angle" are all of them optional and fallback to the default jQuery.fn.animate-properties:

                  duration: 400
                  easing: "swing"
                  complete: function () {}
                  

                  第一個

                  這種方式比較短,但是傳入的參數越多看起來就有點不清楚了.

                  1st

                  This way is the short one, but looks a bit unclear the more arguments we pass in.

                  $(node).animateRotate(90);
                  $(node).animateRotate(90, function () {});
                  $(node).animateRotate(90, 1337, 'linear', function () {});
                  

                  第二次

                  如果參數超過三個,我更喜歡使用對象,所以我最喜歡這種語法:

                  2nd

                  I prefer to use objects if there are more than three arguments, so this syntax is my favorit:

                  $(node).animateRotate(90, {
                    duration: 1337,
                    easing: 'linear',
                    complete: function () {},
                    step: function () {}
                  });
                  

                  這篇關于帶有 jquery.animate() 的 CSS 旋轉跨瀏覽器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  What is the difference between XMLHttpRequest, jQuery.ajax, jQuery.post, jQuery.get(XMLHttpRequest、jQuery.ajax、jQuery.post、jQuery.get 有什么區別)
                  Can onprogress functionality be added to jQuery.ajax() by using xhrFields?(可以使用 xhrFields 將 onprogress 功能添加到 jQuery.ajax() 嗎?)
                  Show a progress bar for downloading files using XHR2/AJAX(顯示使用 XHR2/AJAX 下載文件的進度條)
                  How can I open a JSON file in JavaScript without jQuery?(如何在沒有 jQuery 的情況下在 JavaScript 中打開 JSON 文件?)

                  • <legend id='Nr9gG'><style id='Nr9gG'><dir id='Nr9gG'><q id='Nr9gG'></q></dir></style></legend>
                        <tbody id='Nr9gG'></tbody>
                      • <bdo id='Nr9gG'></bdo><ul id='Nr9gG'></ul>

                          <i id='Nr9gG'><tr id='Nr9gG'><dt id='Nr9gG'><q id='Nr9gG'><span id='Nr9gG'><b id='Nr9gG'><form id='Nr9gG'><ins id='Nr9gG'></ins><ul id='Nr9gG'></ul><sub id='Nr9gG'></sub></form><legend id='Nr9gG'></legend><bdo id='Nr9gG'><pre id='Nr9gG'><center id='Nr9gG'></center></pre></bdo></b><th id='Nr9gG'></th></span></q></dt></tr></i><div class="e00awcm" id='Nr9gG'><tfoot id='Nr9gG'></tfoot><dl id='Nr9gG'><fieldset id='Nr9gG'></fieldset></dl></div>

                          <small id='Nr9gG'></small><noframes id='Nr9gG'>

                          <tfoot id='Nr9gG'></tfoot>

                            主站蜘蛛池模板: 长江船运_国内海运_内贸船运_大件海运|运输_船舶运输价格_钢材船运_内河运输_风电甲板船_游艇运输_航运货代电话_上海交航船运 | 无刷电机_直流无刷电机_行星减速机-佛山市藤尺机电设备有限公司 无菌检查集菌仪,微生物限度仪器-苏州长留仪器百科 | 定量包装机,颗粒定量包装机,粉剂定量包装机,背封颗粒包装机,定量灌装机-上海铸衡电子科技有限公司 | 上海三信|ph计|酸度计|电导率仪-艾科仪器 | 合肥白癜风医院_[治疗白癜风]哪家好_合肥北大白癜风医院 | 智能垃圾箱|垃圾房|垃圾分类亭|垃圾分类箱专业生产厂家定做-宿迁市传宇环保设备有限公司 | 耐火浇注料价格-高强高铝-刚玉碳化硅耐磨浇注料厂家【直销】 | 软文发布-新闻发布推广平台-代写文章-网络广告营销-自助发稿公司媒介星 | 氢氧化钙设备_厂家-淄博工贸有限公司| 宝宝药浴-产后药浴-药浴加盟-艾裕-专注母婴调养泡浴 | 外观设计_设备外观设计_外观设计公司_产品外观设计_机械设备外观设计_东莞工业设计公司-意品深蓝 | 刘秘书_你身边专业的工作范文写作小秘书 | 红酒招商加盟-葡萄酒加盟-进口红酒代理-青岛枞木酒业有限公司 | 西宁装修_西宁装修公司-西宁业之峰装饰-青海业之峰墅级装饰设计公司【官网】 | elisa试剂盒-PCR试剂盒「上海谷研实业有限公司」 | 厂厂乐-汇聚海量采购信息的B2B微营销平台-厂厂乐官网 | 溶氧传感器-pH传感器|哈美顿(hamilton)| 深圳天际源广告-形象堆头,企业文化墙,喷绘,门头招牌设计制作专家 | 一氧化氮泄露报警器,二甲苯浓度超标报警器-郑州汇瑞埔电子技术有限公司 | 818手游网_提供当下热门APP手游_最新手机游戏下载 | 钣金加工厂家-钣金加工-佛山钣金厂-月汇好 | 不发火防静电金属骨料_无机磨石_水泥自流平_修补砂浆厂家「圣威特」 | 螺杆真空泵_耐腐蚀螺杆真空泵_水环真空泵_真空机组_烟台真空泵-烟台斯凯威真空 | 热处理温控箱,热处理控制箱厂家-吴江市兴达电热设备厂 | 十字轴_十字轴万向节_十字轴总成-南京万传机械有限公司 | 新疆散热器,新疆暖气片,新疆电锅炉,光耀暖通公司 | 青岛空压机,青岛空压机维修/保养,青岛空压机销售/出租公司,青岛空压机厂家电话 | 上海瑶恒实业有限公司|消防泵泵|离心泵|官网 | KBX-220倾斜开关|KBW-220P/L跑偏开关|拉绳开关|DHJY-I隔爆打滑开关|溜槽堵塞开关|欠速开关|声光报警器-山东卓信有限公司 | PTFE接头|聚四氟乙烯螺丝|阀门|薄膜|消解罐|聚四氟乙烯球-嘉兴市方圆氟塑制品有限公司 | 上海新光明泵业制造有限公司-电动隔膜泵,气动隔膜泵,卧式|立式离心泵厂家 | 滑板场地施工_极限运动场地设计_滑板公园建造_盐城天人极限运动场地建设有限公司 | SDI车窗夹力测试仪-KEMKRAFT方向盘测试仪-上海爱泽工业设备有限公司 | 算命免费_生辰八字_免费在线算命 - 卜算子算命网 | 湖南长沙商标注册专利申请,长沙公司注册代理记账首选美创! | 高速龙门架厂家_监控杆_多功能灯杆_信号灯杆_锂电池太阳能路灯-鑫世源照明 | 灌木树苗-绿化苗木-常绿乔木-价格/批发/基地 - 四川成都途美园林 | 山东PE给水管厂家,山东双壁波纹管,山东钢带增强波纹管,山东PE穿线管,山东PE农田灌溉管,山东MPP电力保护套管-山东德诺塑业有限公司 | 收录网| 东莞市超赞电子科技有限公司 全系列直插/贴片铝电解电容,电解电容,电容器 | 导电银胶_LED封装导电银胶_半导体封装导电胶厂家-上海腾烁 |