0

ロゴ付きのリストを含むdivを連続的に上下に移動するjqueryコードがあります。アニメーションは設定された間隔内で繰り返され、Chrome、FireFox、IE 9および8ですべて期待どおりに機能しているようです(コンソールエラーはありません)。

ただし、IE7では「スクリプトエラー」が発生し、ブラウザが完全にフリーズします... setIntervalとclearIntervalが正しく機能していないか、コードが台無しになっていると思います...

ここにあります:

//<!------------------LOGOS ------------------>

// the automatic scroll start immediately
$(document).ready(function () { membersLogos() });

// set the interval after which to restart the animated scroll
$(function () {

  var intervalID;
  var resetTimer = function () {
    if (intervalID) { clearInterval(intervalID) };
    intervalID = setInterval(function () {
        membersLogos();
    }, 190000);
  };

});

// set the interval after which to restart the animated scroll

function membersLogos() {
  var pane = $('#mypane');

  if ($('#mypane').length) {
    pane.jScrollPane({
        animateScroll: true, //added
        animateDuration: 95000, //added - length each way in milliseconds
        stickToTop: true,
        //autoReinitialise: true,
        enableKeyboardNavigation: true
    });

    var api = pane.data('jsp');
    var logosHeight = parseInt($('#mypane .jspPane').height());

    //listen to the x-axis scrolling event
    pane.bind('jsp-scroll-y', function (event, pos_y, at_top, at_bottom) {
        //we're at the bottom now lets scroll back to the top
        if (at_bottom) {
            api.scrollToY(0);
            $(this).unbind(event); //added with edit
            $(this).bind('jsp-scroll-y', function (event, pos_y, at_top, at_bottom) {
                if (at_top) {
                    $(this).unbind(event);
                    api.scrollToY(logosHeight);
                }

            });

        }

    });

    //initial animate scroll to the top
    api.scrollToY(logosHeight);
  }
}

何が悪いのかというアイデアや提案はありますか?前もって感謝します!Vik

4

1 に答える 1

1

間隔を2つのアニメーションの正確な合計(190000 = 95000 * 2)に設定したので、アニメーションが完了する前に間隔関数が再度起動され、何かが他の何かを踏んだとしても驚かないでしょう。 。簡単に確認できます。間隔を300000程度に設定して、問題が解決するかどうかを確認してください。

インターバルがすぐに再起動する可能性を回避するためにsetInterval(ほとんどの場合、それが価値があるよりも厄介です)、jScrollPaneアニメーションが完了したときに完了コールバックを提供するかどうかを確認します。含まれている場合は、その完了コールバックを使用して次のアニメーションをトリガーします。そうでない場合は、おそらく追加することを検討します。

于 2011-12-01T12:13:25.537 に答える