jQuery UI API - 反彈特效(Bounce Effect)
所屬類別
用法
描述:反彈特效(Bounce Effect)反彈一個元素。當與隱藏或顯示一起使用時,最後一次或第一次反彈會呈現淡入/淡出效果。
bounce
| 參數 | 類型 | 描述 | 默認值 |
|---|---|---|---|
| distance | Number | 最大的反彈距離,以像素為單位。 | 20 |
| times | Integer | 元素反彈的次數。當隱藏或顯示時,會為淡入/淡出效果添加半個反彈。 | 5 |
實例
使用反彈特效(Bounce Effect)切換一個 div。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>反彈特效(Bounce Effect)演示</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<style>
#toggle {
width: 100px;
height: 100px;
background: #ccc;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>
<p>點擊任意地方進行切換。</p>
<div id="toggle"></div>
<script>
$( document ).click(function() {
$( "#toggle" ).toggle( "bounce", { times: 3 }, "slow" );
});
</script>
</body>
</html>
