Coda-Slider 上一个和下一个按钮隐藏

发布于 2024-08-09 04:40:41 字数 921 浏览 3 评论 0原文

非常简单的问题,我知道这只是 if / else if 语句的问题,但我无法让它们正确运行。

我正在使用 http://jqueryfordesigners.com/coda-slider-effect/,我可以将它们隐藏起来,等等,但是当涉及到根据情况(当前选择的内容)让它们可用时,我只是无法让它正常工作。

有一个 SerialScroll 插件,但是它似乎不适用于 coda-slider。

jQuery(function( $ ){
var $prev = $('#before'),//prev button
    $next = $('#after');//next button

$('.slider').serialScroll({
    //...
    cycle:false, //you probably don't want this
    onBefore:function( e, elem, $pane, $items, pos ){
        $prev.add($next).show();
        if( pos == 0 )
            $prev.hide();
        else if( pos == $items.length-5 )
            $next.hide();
    }
    //...
});

});

所以,我不确定我是否在serialscroll方面遗漏了一些东西,或者应该只为它编写一个简单的JS情景片段,而我在这方面遇到了麻烦!

我已经使用并设置了cycle: false,如您所见,虽然它会停止滚动并使按钮不执行任何操作,但它们不会消失

提前感谢!

Pretty simple question, I know it's just a matter of if / else if statements but I'm unable to get them to run correctly.

I'm using the basis of http://jqueryfordesigners.com/coda-slider-effect/, I can get them hidden, etc, but when it comes to having them available depending on the situation (what is currently selected) I'm just unable to get it to work correctly.

There's a serialscroll plugin for it, but, it doesn't seem to be working for coda-slider.

jQuery(function( $ ){
var $prev = $('#before'),//prev button
    $next = $('#after');//next button

$('.slider').serialScroll({
    //...
    cycle:false, //you probably don't want this
    onBefore:function( e, elem, $pane, $items, pos ){
        $prev.add($next).show();
        if( pos == 0 )
            $prev.hide();
        else if( pos == $items.length-5 )
            $next.hide();
    }
    //...
});

});

So, I'm not sure if I'm missing something on the serialscroll side, or should just write a simple situational piece of JS for it, which I'm having trouble doing!

I have used and have set cycle: false as you can see, and while it will stop scrolling and make the buttons do nothing, they will not dissapear

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

送君千里 2024-08-16 04:40:42

你的 onBefore 函数被调用了吗

is your onBefore function is being called

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文