单击导航时,jQuery Scrollable无法停止自动播放 [英] Jquery Scrollable can't stop autoplay when nav is clicked

查看:76
本文介绍了单击导航时,jQuery Scrollable无法停止自动播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用可通过导航滚动的jquery UI工具.我希望它能自动播放,这很好,但是每当我与导航交互时,时间就变得很时髦.

I'm using jquery UI tools scrollable with a nav. I want it so that it autoplays automatically, which is fine, but the timing goes all funky whenever I interact with the nav.

当我单击任何导航链接时,我希望它停止.我似乎无法滚动停止!

I want it to stop when I click on any of the nav links. I can't seem to get scrolling to stop!

下面是启动它的代码:

HTML:

    <div id="flowpanes"> 
        <div class="items">
            <div>
                <h1>Content 1</h1>
            </div>
            <div>
                <h2>Content 2</h2>
            </div>
            <div>
                <h2>Content 3</h2>
            </div>
            <div>
                <h2>Content 4</h2>
            </div>
        </div>
    </div>
    <ul id="flowtabs" class="navi">
        <li><a href="#one" class="current"></a></li>
        <li><a href="#two"></a></li>
        <li><a href="#three"></a></li>
        <li><a href="#four"></a></li>
    </ul>

激活它的jQuery:

Jquery that activates it:

$(document).ready(function() {
    $("#flowpanes").scrollable({ circular: true, mousewheel: true }).autoscroll({autoplay: true,interval: 5000,steps: 1}).navigator({
        navi: ".navi",
        naviItem: 'a',
        activeClass: 'current',
        history: false,
    })
}); 

我尝试了这个,但是没有用:

I tried this, but it didn't work:

$(".navi a").click (function(){
    api.stop()
});

然后我尝试将js添加到实际的按钮中,但我认为我没有正确指定它-像下面的代码一样需要其他东西来指出可滚动区域-滚动内容在一个矛状的div中在ul.navi之上:

Then I tried adding js to the actual buttons, but I don't think I'm specifying it correctly - does something like the below code need something else to pin point the scrollable area - the scrolling content is in a spearate div above ul.navi:

 <ul id="flowtabs" class="navi">
   <li><a href="#one" class="current" onclick="api.stop()"></a></li>
   <li><a href="#two" onclick="api.stop()"></a></li>
   <li><a href="#three" onclick="api.stop()"></a></li>
   <li><a href="#four" onclick="api.stop()"></a></li>
 </ul>

我还尝试在历史记录:false下的导航器部分中添加clickable:false,但这也不起作用.

I also tried adding clickable: false to the navigator section under history: false, but that didn't work either.

任何人都可以帮忙吗?

推荐答案

如果您在 jQuery Scrollable ,他们使用此指令将api对象分配给当前窗口:

If you look the sourcecode of the jquery ui scroller example at jQuery Scrollable they use this instruction for assigning the api object to the current window:

// provide scrollable API for the action buttons
window.api = root.data("scrollable");

您尝试过吗?

这篇关于单击导航时,jQuery Scrollable无法停止自动播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆