移動時間を指定する

書式

motionObj = new YAHOO.util.Motion(element, attributes, duration)

motionObj : モーションオブジェクト
element : ページ上のエレメント
attributes : 座標パラメータ
duration : 処理完了までの時間 (秒)【省略可能】

説明

 移動時間を指定するにはYAHOO.util.Motion()の3番目のパラメータに秒数を指定します。省略した場合は処理時間は1秒となります。

サンプルコード [実行]

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<script type="text/javascript" src="yahoo.js"></script>
<script type="text/javascript" src="event.js"></script>
<script type="text/javascript" src="dom.js"></script>
<script type="text/javascript" src="animation.js"></script>
<script type="text/javascript"><!--
function startMotion(){
var boxObj = new YAHOO.util.Motion("box", {
points:{ from:[10, 80], to:[120,100] } }, 3);
boxObj.animate();
}
// --></script>
</head>
<body>
<h1>移動時間を指定</h1>
<form>
<input type="button" value="開始" onClick="startMotion()">
</form>
<div id="box">
ここの表示位置が変わります。
</div>
</body>
</html>