亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問怎樣才能讓其在任意度數下饒中心旋轉?

請問怎樣才能讓其在任意度數下饒中心旋轉?

喵喔喔 2022-07-07 11:07:03
這是一個讓圖片旋轉的函數,rotate里輸入角度,可是我發現只有90度的時候圖片才圍繞自己的中心旋轉(正方形圖片),如果換成其他度數就不行了,我找半天也沒看出來是繞著那個點旋轉。
查看完整描述

3 回答

?
楊魅力

TA貢獻1811條經驗 獲得超6個贊

    rotate是jQuery旋轉rotate插件,支持Internet Explorer 6.0+ 、Firefox 2.0 、Safari 3 、Opera 9 、Google Chrome,高級瀏覽器下使用Transform,低版本ie使用VML實現。

    rotate(angle)angle參數:[Number] – 默認為 0


根據給定的角度旋轉圖片例如:$(“#img”).rotate(45);或 $(‘#img’).rotate({angle:45})

rotate(parameters)parameters參數:[Object] 包含旋轉參數的對象。

支持的屬性:

1.angle屬性:[Number] – default 0 – 旋轉的角度數,并且立即執行


例如:1$(“#img”).rotate({angle:45});

2.bind屬性:[Object] 對象,包含綁定到一個旋轉對象的事件。事件內部的$(this)指向旋轉對象-這樣可以在內部鏈式調用- $(this).rotate(…)。


例如 (click on arrow):$(“#img”).rotate({bind:{    click: function(){            $(this).rotate({                angle: 0,                animateTo:180            })          }       }});

3.animateTo屬性:[Number] – default 0 – 從當前角度值動畫旋轉到給定的角度值 (或給定的角度參數)

4.duration屬性:[Number] – 指定使用animateTo的動畫執行持續時間


例如 (click on arrow):$(“#img”).rotate({bind:{    click: function(){        $(this).rotate({            duration:6000,            angle: 0,            animateTo:100        })    }   }});

5. step屬性:[Function] – 每個動畫步驟中執行的回調函數,當前角度值作為該函數的第一個參數

6.  easing屬性:[Function] – 默認 (see below) 

默認:function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; }

Where:

t: current time,

b: begInnIng value,

c: change In value,

d: duration,

x: unused

沒有漸變:No easing (linear easing):function(x, t, b, c, d) { return (t/d)*c ; }   


示例1:沒有效果,一直轉 $("#scImg").rotate({                              angle:0,                              animateTo:360,                              callback: rotation,                                easing: function (x,t,b,c,d){                                           return (t/d)*c ;                             }                      });
  

示例2: 默認的效果         $("#scImg").rotate({                              angle:0,                              animateTo:360,                              callback: rotation,                              easing: function (x,t,b,c,d){return -c*((t=t/d-1)*t*t*t-1)+b ;                             }                      });

示例3:$(“#img”).rotate({bind:{    click: function(){        $(this).rotate({            angle: 0,            animateTo:180,            easing: $.easing.easeInOutElastic            })        }    }});

7.callback屬性:[Function] 動畫完成時執行的回調函數

例如


$(“#img”).rotate({bind:{    click: function(){        $(this).rotate({            angle: 0,            animateTo:180,            callback: function(){ alert(1) }            })        }    }});

8. getRotateAngle這個函數只是簡單地返回旋轉對象當前的角度。


例如:$(“#img”).rotate({    angle: 45,    bind: {        click : function(){        alert($(this).getRotateAngle());        }    }});

9.stopRotate這個函數只是簡單地停止正在進行的旋轉動畫。例如:


$(“#img”).rotate({    bind: {        click: function(){            $(“#img”).rotate({                angle: 0,                animateTo: 180,                duration: 6000            });        setTimeout(function(){            $(“#img”).stopRotate();            }, 1000);        }    }});



查看完整回答
反對 回復 2022-07-11
?
青春有我

TA貢獻1784條經驗 獲得超8個贊

你好?。?/p>

不知道你的那個jquery.rotate.js是什么版本了?

新版本的用法也不是很復雜,如下:


$(function(){    $("#rotate-img").click(function(){//click事件,每點擊一次,順時針旋轉45°.        //圖片旋轉,通過$.animate()方法        $(this).animate({            rotate:"+=45deg"  //為rotate屬性賦值,注意:deg為角度單位        },'slow');    });});



查看完整回答
反對 回復 2022-07-11
?
幕布斯6054654

TA貢獻1876條經驗 獲得超7個贊

以中心豎軸線為基準旋轉。
$(obj).rotate(30); //即正上向右偏轉30度

查看完整回答
反對 回復 2022-07-11
  • 3 回答
  • 0 關注
  • 211 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號