我对jquery插件的平滑有一些问题。
从本质上讲,我试图让这个插件像这个页面一样运行: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");
});发布于 2012-03-27 14:12:10
我不知道这是不是导致你的问题的原因,但你需要注意括号。将代码更改为:
// 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-27 23:00:39
我发现这些选项是不正确的。尝试这样做(如果您使用的是最新版本,即1.2版):
// Initialize the scroller
$("#makeMeScrollable").smoothDivScroll({
mousewheelScrolling: true,
visibleHotSpotBackgrounds: "always",
autoScrollingMode: "onstart",
autoScrollingDirection: "endlessloopright",
manualContinuousScrolling: true
});在这种配置中,滚动条在加载时会自动滚动到一个无死循环中。一旦用户使用鼠标滚轮或热点,自动滚动将停止,如果不是您的自定义平均处理器,它将不会再次开始自动滚动。但是既然你有了它们,那么只要用户离开可收集区域,它就应该重新启动。
我还将manualContinuousScrolling设置为true,以便在手动滚动时得到相同的无休止循环。
这还没有经过测试,所以你可能需要做一些调整。例如,我不确定autoScrollingMode:"onstart“还是autoScrollingMode:"always”是最好的选择。你只需要试一试。
发布于 2013-03-28 03:14:12
我认为同样重要的是,也许不同的版本会影响行为。这适用于我的:jquery.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");
});
});https://stackoverflow.com/questions/9873255
复制相似问题