JQuery動畫animate的stop方法使用詳解
更新時間:2014年05月09日 09:03:51 作者:
這篇文章主要介紹了JQuery動畫animate的stop方法使用,需要的朋友可以參考下
animate語法:
$(selector).animate(styles,speed,easing,callback)
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Testing</title>
<link rel="stylesheet" href="css/reset.css">
<script src="js/jquery.js"></script>
<style>
.wrap {
position: relative;
height: 300px;
width: 300px;
border:5px solid #FCF;
}
.wrap div {
position: absolute;
left: 0;top: 0;
height: 50px;
width: 50px;
background: #FA0;
}
</style>
</head>
<body>
<input type="button" id="btn1" value="停止當(dāng)前動畫">
<input type="button" id="btn2" value="停止所有動畫">
<input type="button" id="btn3" value="停止所有動畫,到達(dá)終點(diǎn)">
<div class="wrap">
<div></div>
</div>
<script>
function moveX(){
$('.wrap div').animate({'left':'250px'},1000).animate({'left':'0px'},1000);
} moveX();
$('#btn1').click(function(){
$('.wrap div').stop(); // 停止當(dāng)前動畫,沿路返回起點(diǎn),若是返回過程中再點(diǎn)擊,會暫停在路中
clearInterval();
})
$('#btn2').click(function(){
$('.wrap div').stop(true); // 停止所有動畫 去的路程中點(diǎn)擊停止會直接到達(dá)終點(diǎn),若是返回過程中再點(diǎn)擊,會暫停在路中
})
$('#btn3').click(function(){
$('.wrap div').stop(true,true); // 停止所有動畫 ,去的路程中點(diǎn)擊停止會直接到達(dá)終點(diǎn),若是返回過程中再點(diǎn)擊,會停止到在起點(diǎn)
})
// .stop() // 停止當(dāng)前動畫
// .stop(true) // 停止所有動畫
// .stop(true,true) // 停止所有動畫,到達(dá)動畫終點(diǎn)
</script>
</body>
</html>
.stop(); // 停止當(dāng)前動畫,沿路返回起點(diǎn),若是返回過程中再點(diǎn)擊,會暫停在路中
.stop(true); // 停止所有動畫 去的路程中點(diǎn)擊停止會直接到達(dá)終點(diǎn),若是返回過程中再點(diǎn)擊,會暫停在路中
.stop(true,true); // 停止所有動畫 ,去的路程中點(diǎn)擊停止會直接到達(dá)終點(diǎn),若是返回過程中再點(diǎn)擊,會停止到在起點(diǎn)
復(fù)制代碼 代碼如下:
$(selector).animate(styles,speed,easing,callback)
復(fù)制代碼 代碼如下:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Testing</title>
<link rel="stylesheet" href="css/reset.css">
<script src="js/jquery.js"></script>
<style>
.wrap {
position: relative;
height: 300px;
width: 300px;
border:5px solid #FCF;
}
.wrap div {
position: absolute;
left: 0;top: 0;
height: 50px;
width: 50px;
background: #FA0;
}
</style>
</head>
<body>
<input type="button" id="btn1" value="停止當(dāng)前動畫">
<input type="button" id="btn2" value="停止所有動畫">
<input type="button" id="btn3" value="停止所有動畫,到達(dá)終點(diǎn)">
<div class="wrap">
<div></div>
</div>
<script>
function moveX(){
$('.wrap div').animate({'left':'250px'},1000).animate({'left':'0px'},1000);
} moveX();
$('#btn1').click(function(){
$('.wrap div').stop(); // 停止當(dāng)前動畫,沿路返回起點(diǎn),若是返回過程中再點(diǎn)擊,會暫停在路中
clearInterval();
})
$('#btn2').click(function(){
$('.wrap div').stop(true); // 停止所有動畫 去的路程中點(diǎn)擊停止會直接到達(dá)終點(diǎn),若是返回過程中再點(diǎn)擊,會暫停在路中
})
$('#btn3').click(function(){
$('.wrap div').stop(true,true); // 停止所有動畫 ,去的路程中點(diǎn)擊停止會直接到達(dá)終點(diǎn),若是返回過程中再點(diǎn)擊,會停止到在起點(diǎn)
})
// .stop() // 停止當(dāng)前動畫
// .stop(true) // 停止所有動畫
// .stop(true,true) // 停止所有動畫,到達(dá)動畫終點(diǎn)
</script>
</body>
</html>
.stop(); // 停止當(dāng)前動畫,沿路返回起點(diǎn),若是返回過程中再點(diǎn)擊,會暫停在路中
.stop(true); // 停止所有動畫 去的路程中點(diǎn)擊停止會直接到達(dá)終點(diǎn),若是返回過程中再點(diǎn)擊,會暫停在路中
.stop(true,true); // 停止所有動畫 ,去的路程中點(diǎn)擊停止會直接到達(dá)終點(diǎn),若是返回過程中再點(diǎn)擊,會停止到在起點(diǎn)
您可能感興趣的文章:
- 詳解jQuery停止動畫——stop()方法的使用
- JQuery動畫和停止動畫實(shí)例代碼
- jQuery動畫animate方法使用介紹
- jQuery動畫效果animate和scrollTop結(jié)合使用實(shí)例
- jquery animate 動畫效果使用說明
- jQuery實(shí)現(xiàn)切換頁面過渡動畫效果
- Jquery中使用show()與hide()方法動畫顯示和隱藏圖片
- jQuery動畫與特效詳解
- 利用jquery制作滾動到指定位置觸發(fā)動畫
- jQuery動畫出現(xiàn)連續(xù)觸發(fā)、滯后反復(fù)執(zhí)行的解決方法
- jQuery 動畫與停止動畫效果實(shí)例詳解
相關(guān)文章
jquery拖拽效果完整實(shí)例(附demo源碼下載)
這篇文章主要介紹了jquery拖拽效果實(shí)現(xiàn)方法,詳細(xì)介紹了jQuery實(shí)現(xiàn)拖拽功能的具體步驟與相關(guān)技巧,并附代碼了demo源碼供讀者下載參考,需要的朋友可以參考下2016-01-01基于jQuery實(shí)現(xiàn)動態(tài)搜索顯示功能
這篇文章主要介紹了基于jQuery實(shí)現(xiàn)動態(tài)搜索顯示功能的相關(guān)資料,輸入數(shù)值自動匹配相關(guān)信息,感興趣的小伙伴們可以參考一下2016-05-05jQuery實(shí)現(xiàn)的頁面彈幕效果【測試可用】
這篇文章主要介紹了jQuery實(shí)現(xiàn)的頁面彈幕效果,涉及jQuery事件響應(yīng)與頁面元素屬性動態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-08-08使用jquery+CSS實(shí)現(xiàn)控制打印樣式
這篇文章主要介紹了使用jquery+CSS實(shí)現(xiàn)控制打印樣式,需要的朋友可以參考下2014-12-12基于jQuery實(shí)現(xiàn)的圖片切換焦點(diǎn)圖整理
這篇文章主要介紹了基于jQuery實(shí)現(xiàn)的圖片切換焦點(diǎn)圖整理,需要的朋友可以參考下2014-12-12