アニメーションを停止する

書式

anim.stop();

anim : アニメーションオブジェクト

説明

アニメーションを停止するにはアニメーションオブジェクトのstop()メソッドを呼び出します。

サンプルコード [実行]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="css/yui.css" type="text/css" media="all">
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script type="text/javascript" src="../../../lib/yui/yui.js"></script>
<script type="text/javascript"><!--
var anim;
function startAnime(){
YUI().use('anim', function(Y){
anim = new Y.Anim({
node: '#box',
duration : 5.0,
from : { xy: [10, 20] },
to : { xy: [300, 200] }
});
anim.run();
});
}
// --></script>
</head>
<body class="yui-skin-sam">
<h1>アニメーションを停止する</h1>
<form>
<input type="button" value="アニメーション開始" onClick="startAnime()">
<input type="button" value="アニメーション停止" onClick="anim.stop()">
</form>
<div id="box">
ここが移動します。
</div>
</body>
</html>