0

我使用了选项 autoScrollingMode: "always" 但当用户将鼠标移动到左侧或右侧热点或使用鼠标滚轮时,自动滚动仍然停止。与描述相反,热点未被禁用。我怎样才能在不停止的情况下自动滚动。她是我的代码:

<script type="text/javascript">
    $(document).ready(function() {
        $("#makeMeScrollable").smoothDivScroll({ 
            mousewheelScrolling: true,
            manualContinuousScrolling: true,
            visibleHotSpotBackgrounds: "onstart",
            autoScrollingMode: "always",
            hotSpotScrollingStep: "5",
            hotSpotsVisibleTime: "2000"
        });
    });
</script>

感谢您的帮助,Afrikpit

4

3 回答 3

0

使用自动滚动模式:“onStart”

于 2013-08-29T16:05:18.117 回答
0

如果你想自动滚动,这个设置应该足够了:

<script type="text/javascript">
    $(document).ready(function() {
        $("#makeMeScrollable").smoothDivScroll({ 
            autoScrollingMode: "always"
        });
    });
</script>

这意味着滚动条将一直自动滚动,而不会受到用户的干扰。或者您是否在寻找不同的设置?

于 2012-09-28T10:00:05.507 回答
0

好的,我已经通过稍微编辑源以禁用鼠标滚轮滚动来修复它。

在 jquery.smoothDivScroll.js(不是 .min.js)的第 337-355 行,我注释掉了所有的self.stopAutoScrolling();self.move(pixels);行:

if (o.mousewheelScrolling === "vertical" && deltaY !== 0) {
    // Stop any ongoing auto scrolling if it's running
    // self.stopAutoScrolling();
    event.preventDefault();
    // pixels = Math.round((o.mousewheelScrollingStep * deltaY) * -1);
    // self.move(pixels);
} else if (o.mousewheelScrolling === "horizontal" && deltaX !== 0) {
    // Stop any ongoing auto scrolling if it's running
    // self.stopAutoScrolling();
    event.preventDefault();
    // pixels = Math.round((o.mousewheelScrollingStep * deltaX) * -1);
    // self.move(pixels);
} else if (o.mousewheelScrolling === "allDirections") {
    // Stop any ongoing auto scrolling if it's running
    // self.stopAutoScrolling();
    event.preventDefault();
    // pixels = Math.round((o.mousewheelScrollingStep * delta) * -1);
    // self.move(pixels);
}

然后我将第 364 行更改为:

el.data("scrollingHotSpotLeft").add(el.data("scrollingHotSpotRight")).add(el.data("scrollWrapper")).mousewheel(function (event) {

我刚刚添加了.add(el.data("scrollWrapper"))部分以禁用整个区域的鼠标滚轮滚动。

这样做使它滚动得更快一些,所以我不得不调整我的autoScrollingInterval设置,但它似乎无论如何都禁用了鼠标滚轮滚动。顶部的默认设置是禁用热点滚动的良好开端(我在 jquery.smoothDivScroll.js 顶部的选项中默认禁用它并且看不到任何热点)。

然后只需将代码压缩回您的 jquery.smoothDivScroll.min.js 文件,您就应该进行设置。最后我的配置看起来像这样:

$(document).ready(function() {

    $("div#makeMeScrollable").smoothDivScroll({
        manualContinuousScrolling: true,
        autoScrollingMode: "always",
        autoScrollingInterval: 80,
        autoScrollingDirection: "endlessLoopRight",
        autoScrollingStep: 1,
        hotSpotScrolling: false,
        mousewheelScrolling: "",
        touchScrolling: false
    });

});
于 2013-10-26T18:03:29.013 回答