代碼如下:
<script>
$(function(){
$.easing.def="easeInQuad";//設置默認效果
var callback=function (){
alert("ok");
}
$("#t1").animate({
"top":600
},{duration: 3000,
easing:"easeInQuad",//可省略
complete: callback})
})
</script>
使用了easing後,JQ原來的方法有將不可用,用對象代替JQ中時間,該對象如下例
{duration: 3000,easing:"easeInQuad",complete: callback}
原JQ的回調函數由complete代替
如果不使用easing,即時間參數不為上面對象所代替,保留原有功能
即加載EASING後仍可以如下使用
代碼如下:
<script>
var callback=function (){
alert("ok");
}
$("#t1").hide(3000,callback)
</script>
具體參數細節:
duration 選項:
毫秒數
complete 選項:
完成後調用
easing 選項:
jswing
def
easeInQuad
easeOutQuad
easeInOutQuad
easeInCubic
easeOutCubic
easeInOutCubic
easeInQuart
easeOutQuart
easeInOutQuart
easeInQuint
easeOutQuint
easeInOutQuint
easeInSine
easeOutSine
easeInOutSine
easeInExpo
easeOutExpo
easeInOutExpo
easeInCirc
easeOutCirc
easeInOutCirc
easeInElastic
easeOutElastic
easeInOutElastic
easeInBack
easeOutBack
easeInOutBack
easeInBounce
easeOutBounce
easeInOutBounce
官方網站 http://gsgd.co.uk/sandbox/jquery/easing/