PHP & JavaScript Room :: 設置サンプル

実行結果

エフェクト操作:カスタム:animate(params, options)の使用例 | jQuery

【アニメーション1】ボタンをクリックすると、キューになっていないアニメーションがどのように動くかが分かります。 フォントサイズを大きくしている間にdiv要素の幅を90%に拡張し、フォントサイズの変更が完了すると、枠線のアニメーションが始まります。

【アニメーション2】ボタンをクリックすると、従来の連続したアニメーションを開始します。 各アニメーションは、要素上で、前のアニメーションが完了した時に、次のアニメーションが実行されます。

div#sample1

div#sample2

設置サンプルのソース

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Language" content="ja" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta http-equiv="imagetoolbar" content="no" />
      <title>エフェクト操作:カスタム:animate(params, options)の使用例 | jQuery</title>
      <link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      <script type="text/javascript">
         $(function(){
            /* 【アニメーション1】ボタンをクリックした時にアニメーション実行 */
            $("#btn_sample1").click(function(){
               $("#sample1").animate( { width:"500px" }, { queue:false, duration:3000 } )
                  .animate( { fontSize:"4em" }, 1500 )
                  .animate( { borderRightWidth:"15px" }, 1500);
            });
            /* 【アニメーション2】ボタンをクリックした時にアニメーション実行 */
            $("#btn_sample2").click(function(){
               $("#sample2").animate( { width:"500px"}, 1000 )
                  .animate( { fontSize:"4em" } , 1000 )
                  .animate( { borderLeftWidth:"15px" }, 1000);
            });
            /* 【アニメーション 1+2】ボタンをクリックした時に、【アニメーション2】ボタンをクリックし、両アニメーションを実行 */
            $("#btn_both").click(function(){
               $("#btn_sample1").add("#btn_sample2").click();
            });
            /* 【リセット】ボタンをクリックした時に、要素をアニメーション前の状態に戻す */
            $("#btn_reset").click(function(){
               $("#sample1").css({width:"", fontSize:"", borderWidth:""});
               $("#sample2").css({width:"", fontSize:"", borderWidth:""});
            });
         });
      </script>
      <style type="text/css">
         #sample1, #sample2 { background-color:pink; width:200px; text-align:center; border:2px solid hotpink; margin:10px 0; padding:10px; font-size:2em; }
      </style>
   <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
   <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP &amp; JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
      <div id="wrap">
         <h1>エフェクト操作:カスタム:animate(params, options)の使用例 | jQuery</h1>
         <p>
            【アニメーション1】ボタンをクリックすると、キューになっていないアニメーションがどのように動くかが分かります。
            フォントサイズを大きくしている間にdiv要素の幅を90%に拡張し、フォントサイズの変更が完了すると、枠線のアニメーションが始まります。
         </p>
         <p>
            【アニメーション2】ボタンをクリックすると、従来の連続したアニメーションを開始します。
            各アニメーションは、要素上で、前のアニメーションが完了した時に、次のアニメーションが実行されます。
         </p>
<!-- CODE -->
         <button id="btn_sample1">アニメーション 1</button>
         <button id="btn_sample2">アニメーション 2</button>
         <button id="btn_both">アニメーション 1+2</button>
         <button id="btn_reset">リセット</button>
         <p id="sample1">div#sample1</p>
         <p id="sample2">div#sample2</p>
<!-- / CODE -->
      </div>
   </body>
</html>