0

新しいjQueryであるため、コードを組み合わせてdivを左側から右側にアニメーション化してからスライドダウンするのに問題があります。スライドダウン前の div の高さは約 10px で、スライドダウンすると高さ 351px になります。上記を別々に行うことはできますが、組み合わせることはできません!! 少しご指導いただければ幸いです、よろしくお願いします。これが私の現在のコードです。

$.hideAllExcept = function(tabs,boxes){
function init() {

  // make it bookmarkable/refreshable. but, no history.
  var hash = window.location.hash;
  (!hash) ? hideShow('#' + $(boxes+':first').attr('id')) : hideShow(window.location.hash);

  // add click handler.

  $(tabs).click(function(e) {
    e.preventDefault();
    var href = $(this).attr('href');
    // add back the hash which is prevented by e.preventDefault()
    window.location.hash = href;
    hideShow(href);
  });
}

function hideShow(el) {


    $(boxes).animate({"left": "-650px"}, "slow");
     $(el).fadeIn('slow').animate({"left" : "60%",height:"351" }, 1000);

$(tabs).removeClass('active');
      $('a[href="' + el + '"]').addClass('active');
    }
    init();

};

少し進みました!!一時サーバーで実行しています:

http://www.tridentsolutions.co.nz/test-folder/index.html#construction_home

しかし、ボックスを LHS に戻すことはできません。また、テキストが html にあり、div の画像ではないため、テキストがどのように表示されるかを確認できません。つまり、テキストを非表示にできないということですか? 前もって感謝します

(function($){

$.hideAllExcept = function(tabs,boxes){
    function init() {

      // make it bookmarkable/refreshable. but, no history.
      var hash = window.location.hash;
      (!hash) ? hideShow('#' + $(boxes+':first').attr('id')) : hideShow(window.location.hash);

      // add click handler.

      $(tabs).click(function(e) {
        e.preventDefault();
        var href = $(this).attr('href');
        // add back the hash which is prevented by e.preventDefault()
        window.location.hash = href;
        hideShow(href);
      });
    }

 function hideShow(el) {

     $(el).animate({"left": "-650px"}, "slow").fadeIn('slow');
    $(el).fadeIn('slow').animate({"left" : "60%" }, 1000).animate({"height" : "351" }, 1000);


$(tabs).removeClass('active');
      $('a[href="' + el + '"]').addClass('active');
    }
    init();

};
4

2 に答える 2

0

2 つの効果を一緒に連鎖させてみましたか? それらを 2 つの animate() 関数に分割し、必要な順序でチェーンします。

$(el).fadeIn('slow').animate({"left" : "60%"}, 1000).animate({"height:"351" }, 1000);

各 animate() 関数は順番に実行されるため、任意の数のエフェクトを次々に実行できます。

于 2011-06-21T21:25:58.947 に答える
0

あるアニメーションが終了した後に別のアニメーションを起動する場合は、.animateのコールバックを使用します。

擬似的なコード:

$(selector).animate({ key: val },
                     'slow' /*easing*/,
                      function() {
                          // second animation goes here
                     });
于 2011-06-21T21:26:11.703 に答える