gpt4 book ai didi

javascript - 在按钮悬停时连续滚动 jCarousel

转载 作者:行者123 更新时间:2023-11-30 10:46:17 26 4
gpt4 key购买 nike

我正在使用 jCarousel 插件,但遇到了障碍...

我需要旋转木马在导航按钮悬停时不断滚动。将内置配置变量更改为“鼠标悬停”每次悬停仅滚动一次。

我遇到了 this similar question但我不是 JavaScript 专家,无法得到工作的答案。

这是我的代码:

    function mycarousel_initCallback(carousel)
{

// Pause autoscrolling if the user moves with the cursor over the clip.
carousel.clip.hover(function() {
carousel.stopAuto();
}, function() {
carousel.startAuto();
});
};

jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
auto: 10,
start: 1,
scroll: 1,
animation: 'slow',
wrap: 'circular',
buttonNextEvent: 'mouseover',
buttonPrevEvent: 'mouseover',
initCallback: mycarousel_initCallback
});
});

如有任何帮助,我们将不胜感激。

最佳答案

您可以使用以下脚本使其工作。我已经在 jquery.jcarousel.jsjquery-1.4.1

上测试过了

请注意,我的 jcarousel 设置没有自动滚动。

<script>
jQuery(document).ready(function() {
var _this = null;
$('.jcarousel-next').mouseover(function() {
if (!$(this).hasClass("jcarousel-next-disabled")) {
_this = $(this);
_this.click();
window.setTimeout(CallAgain, 100);
}
});

$('.jcarousel-next').mouseout(function() {
if (!$(this).hasClass("jcarousel-next-disabled")) {
_this = null;
}
});

function CallAgain() {
if (_this != null) {
//alert("Inside Call again");
_this.click();
window.setTimeout(CallAgain, 100);
}
};

$('.jcarousel-prev').mouseover(function() {
if (!jQuery(this).hasClass("jcarousel-prev-disabled")){
_this = $(this);
_this.click();
window.setTimeout(CallAgain, 100);
}
});

$('.jcarousel-prev').mouseout(function() {
if (!$(this).hasClass("jcarousel-next-disabled")) {
_this = null;
}
});
});
</script>

关于javascript - 在按钮悬停时连续滚动 jCarousel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8143599/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com