0

jquery プラグインの Smoothdivscroll にいくつか問題があります。

基本的に、プラグインを次のページとして実行しようとしています: http://www.smoothdivscroll.com/demo.html

ただし、自動的にスクロールする必要があるため、javascriptを変更しましたが、ホットスポットも機能するようにしますが、ホットスポットを離れたマウスでは自動スクロールに戻ります。

以下のコードは機能しますが、トリガーを右側に置いた後、最初の div に「リセット」されます。

設定した位置からスクロールを再開するように設定する方法はありますか?

コード:

    // Initialize the plugin with no custom options
    $(document).ready(function () {
        // I just set some of the options
        $("div#makeMeScrollable").smoothDivScroll({
        mousewheelScrolling: true,
        visibleHotSpotBackgrounds: "always",
        autoScrollingMode: "endlessright"
        });


    });
    //This is just to make the scroller pause...
    $("#makeMeScrollable").bind("mouseover", function() {
    $(this).smoothDivScroll("stopAutoScrolling");
    }).bind("mouseout", function() {
    $(this).smoothDivScroll("startAutoScrolling");
});
4

3 に答える 3

2

これが問題の原因かどうかはわかりませんが、括弧に注意する必要があります。コードを次のように変更します。

// jQuery document ready
$(document).ready(function () {
  // Initialize the scroller
  $("#makeMeScrollable").smoothDivScroll({
    mousewheelScrolling: true,
    visibleHotSpotBackgrounds: "always",
    autoScrollingMode: "endlessright"
  });

  //This is just to make the scroller pause...
  $("#makeMeScrollable").bind("mouseover", function() {
    $(this).smoothDivScroll("stopAutoScrolling");
    }).bind("mouseout", function() {
    $(this).smoothDivScroll("startAutoScrolling");
  });
}); // End query document ready

私はこのコードをテストしていませんが、タイプミスをしない限り、正しい方法です。

幸運を!

于 2012-03-27T06:12:10.037 に答える
0

オプションが正しくないことがわかりました。これを試してください(最新バージョンであるバージョン1.2を使用している場合):

  // Initialize the scroller
  $("#makeMeScrollable").smoothDivScroll({
    mousewheelScrolling: true,
    visibleHotSpotBackgrounds: "always",
    autoScrollingMode: "onstart",
    autoScrollingDirection: "endlessloopright",
    manualContinuousScrolling: true
  });

この構成では、スクローラーはロード時にenslessループで自動スクロールします。ユーザーがマウスホイールまたはホットスポットを使用するとすぐに自動スクロールが停止し、カスタムイベントハンドラーがない場合は自動スクロールが再開されません。しかし、あなたはそれらを持っているので、ユーザーがscollableエリアを離れるとすぐに再開する必要があります。

また、manualContinuousScrollingをtrueに設定したので、手動でスクロールしたときに同じ無限のループが発生します。

これはテストされていないため、調整が必要になる場合があります。たとえば、autoScrollingMode:"onstart"またはautoScrollingMode:"always"が最良の選択であるかどうかはわかりません。あなたはただ試してみる必要があります。

于 2012-03-27T15:00:39.247 に答える
0

おそらく異なるバージョンが動作に影響を与える可能性があることも重要だと思います。これは私の:jquery.smoothDivScroll-1.1-min.jsバージョンで機能しました。

関数名の違いに注意してください: stopAutoScroll と stopAutoScrolling など。

$(window).load(function() {
    $("#makeMeScrollable").smoothDivScroll({ 
        autoScroll: "always", 
        autoScrollDirection: "backandforth", 
        autoScrollStep: 1, 
        autoScrollInterval: 25, 
        startAtElementId: "startAtMe"
    });

    //This is just to make the scroller pause...
    $("#makeMeScrollable").bind("mouseover", function() {
        $(this).smoothDivScroll("stopAutoScroll");
        }).bind("mouseout", function() {
        $(this).smoothDivScroll("startAutoScroll");
    });
});
于 2013-03-27T19:14:12.077 に答える