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

実行結果

設置サンプル

【参照】hoverFlow

例1:基本


例2:hover()を使用せずにbind()を使用する例


例3:連鎖


例4:live()を使用して動的に追加した要素にもイベントを適用

+アイテム追加


設置サンプルのソース

<!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>設置サンプル</title>
      <link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
      <!-- JS -->
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      <script type="text/javascript" src="/content/lib/jquery/jquery.hoverflow.js"></script>
      <script type="text/javascript">
         $(function(){
            /************* example1 */
            $('#demo1_1 a').hover(function(e) {
               $(this).hoverFlow(e.type, { left:20 }, 'fast');
            }, function(e) {
               $(this).hoverFlow(e.type, { left:0 }, 'fast');
            });
            /* e.typeを使用せずに別名(mouseenter)を使う場合 */
            $('#demo1_2 .anim_queue_example a').hover(function() {
               $(this).hoverFlow('mouseenter', { left:20 }, 'fast');
            }, function() {
               $(this).hoverFlow('mouseleave', { left:0 }, 'fast');
            });
            /************* example2 */
            /* hover()を使用せずにbind()を使う場合 */
            $('#demo2 a')
               .bind('mouseover', function(e) {
                  $(this).hoverFlow(e.type, { left:20 }, 'fast');
               })
               .bind('mouseout', function(e) {
                  $(this).hoverFlow(e.type, { left:0 }, 'fast');
            });
            /************* example3 */
            /* 連鎖 */
            $('#demo3 a').hover(function(e) {
               $(this).hoverFlow(e.type, { left:20 }, 'fast').css('backgroundColor', '#99CCFF');
            }, function(e) {
               $(this).hoverFlow(e.type, { left:0 }, 'fast').css('backgroundColor', '#000');
            });
            /************* example4 */
            /* live()を使用して動的に追加した要素にもイベントを適用させる */
            $('#demo4 a').live('mouseover', function(e) {
               $(this).hoverFlow(e.type, { left:20 }, 'fast');
            }).live('mouseout', function(e) {
               $(this).hoverFlow(e.type, { left:0 }, 'fast');
            });
            // リスト要素にアイテム追加
            $('#addMenuItem').bind('click', function() {
               $('#demo4 ul').append('<li><a href="#">New Menu Item</a></li>');
               return false;
            });
         });
      </script>
      <!-- CSS -->
      <style type="text/css">
         body { background:#fff; }
         /* navigation */
         ul.anim_queue_example {
            list-style:none;
            margin:0 20px 0 0; padding:0 0 20px 20px;
            width:125px;
            float:left;
         }
         ul.anim_queue_example li {
            list-style:none;
            margin:0; padding:0;
            background:#000;
         }
         ul.anim_queue_example li a {
            padding:6px 0px;
            background:#000;
            color:#fff;
            text-align:center;
            text-decoration:none;
            position:relative;
            display:block;
         }
      </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>設置サンプル</h1>
         <p>【参照】<a href='http://www.2meter3.de/code/hoverFlow/'>hoverFlow</a></p>
<!-- CODE -->
         <h2>例1:基本</h2>
         <div id="demo1_1">
            <ul class="anim_queue_example">
               <li><a href="#">Menu Item One</a></li> 
               <li><a href="#">Menu Item Two</a></li> 
               <li><a href="#">Menu Item Three</a></li> 
               <li><a href="#">Menu Item Four</a></li> 
               <li><a href="#">Menu Item Five</a></li> 
            </ul>
         </div>
         <div id="demo1_2">
            <ul class="anim_queue_example">
               <li><a href="#">Menu Item One</a></li> 
               <li><a href="#">Menu Item Two</a></li> 
               <li><a href="#">Menu Item Three</a></li> 
               <li><a href="#">Menu Item Four</a></li> 
               <li><a href="#">Menu Item Five</a></li> 
            </ul>
         </div>
         <br clear="all" />

         <h2>例2:hover()を使用せずにbind()を使用する例</h2>
         <div id="demo2">
            <ul class="anim_queue_example">
               <li><a href="#">Menu Item One</a></li> 
               <li><a href="#">Menu Item Two</a></li> 
               <li><a href="#">Menu Item Three</a></li> 
               <li><a href="#">Menu Item Four</a></li> 
               <li><a href="#">Menu Item Five</a></li> 
            </ul>
         </div>
         <br clear="all" />

         <h2>例3:連鎖</h2>
         <div id="demo3">
            <ul class="anim_queue_example">
               <li><a href="#">Menu Item One</a></li> 
               <li><a href="#">Menu Item Two</a></li> 
               <li><a href="#">Menu Item Three</a></li> 
               <li><a href="#">Menu Item Four</a></li> 
               <li><a href="#">Menu Item Five</a></li> 
            </ul>
         </div>
         <br clear="all" />

         <h2>例4:live()を使用して動的に追加した要素にもイベントを適用</h2>
         <p><a href="#" id="addMenuItem">+アイテム追加</a></p>
         <div id="demo4">
            <ul class="anim_queue_example">
               <li><a href="#">Menu Item One</a></li> 
               <li><a href="#">Menu Item Two</a></li> 
               <li><a href="#">Menu Item Three</a></li> 
               <li><a href="#">Menu Item Four</a></li> 
               <li><a href="#">Menu Item Five</a></li> 
            </ul>
         </div>
         <br clear="all" />
<!-- / CODE -->
      </div>
   </body>
</html>