【问题标题】:How to remove buttons in AnythingSlider and stop the sliding?如何删除 AnySlider 中的按钮并停止滑动?
【发布时间】:2011-02-21 01:02:23
【问题描述】:

我目前正在使用anythingSlider,效果很好。

但是如果有一个li,我如何让它停止滑动并移除下面显示的按钮?

li 是从数据库中生成的,所以有时只有一个。我希望按钮仅在有多个图像时显示。

如果只有一张图片,所有按钮(后退、前进、暂停)都不应显示。

有没有人知道如果只有一个 li 时阻止它滑动并在只有一个图像时移除按钮的方法。

================================================ ========================================

谢谢。目前我有工作版本,发布在旧代码下方。我试着用你的替换它似乎没有用。还有什么需要补充的吗?

函数格式文本(索引,面板){ 返回索引+“”; } $(函数(){ $('.anythingSlider').anythingSlider({ easing: "easeInOutExpo", // 除了 "linear" 或 "swing" 之外的任何东西都需要 easing 插件 autoPlay: true, // 这会关闭整个 FUNCTIONALY,而不仅仅是它是否开始运行。 delay: 7500, // 自动播放模式下幻灯片转换之间的时间间隔 startStopped: false, // 如果自动播放开启,这可以强制它开始停止 animationTime: 1250, // 幻灯片过渡需要多长时间 hashTags: true, // 链接是否应该更改 URL 中的主题标签? buildNavigation: true, // 如果为 true,则构建和链接到每张幻灯片的锚链接列表 pauseOnHover: true, // 如果为 true,并且启用了自动播放,则节目将在悬停时暂停 startText: "", // 开始文本 stopText: "", // 开始文本 navigationFormatter: formatText // 文件顶部详细说明本次使用(高级使用) }); $("#slide-jump").click(function(){ $('.anythingSlider').anythingSlider(6); }); }); 使用您的代码更新: 函数格式文本(索引,面板){ 返回索引+“”; } $(函数(){ var singleSlide = true, 选项 = { autoPlay: false, // 这会关闭整个 FUNCTIONALY,而不仅仅是它是否开始运行。 buildNavigation: false, // 如果为 true,则构建和链接到每张幻灯片的锚链接列表 easing: "easeInOutExpo", // 除了 "linear" 或 "swing" 之外的任何东西都需要 easing 插件 delay: 3000, // 自动播放模式下幻灯片转换之间的时间间隔 animationTime: 600, // 幻灯片过渡需要多长时间 hashTags: true, // 链接是否应该更改 URL 中的主题标签? pauseOnHover: true, // 如果为 true,并且启用了自动播放,则节目将在悬停时暂停 navigationFormatter: formatText // 文件顶部详细说明本次使用(高级使用) }; // 如果存在多张幻灯片,则添加播放器选项 if ( $('.anythingSlider > div > ul > li').length > 1 ) { $.extend(选项,{ 自动播放:真, startStopped: false, // 如果自动播放开启,这可以强制它开始停止 startText: "", // 开始文本 stopText: "", // 开始文本 构建导航:真 }); 单张幻灯片 = 假; } // 启动anythingSlider $("#slide-jump").click(function(){ $('.anythingSlider').anythingSlider(6); }); // 隐藏任何东西Slider 导航箭头 if (singleSlide) { $('.anythingSlider a.arrow').hide(); } }); HTML 标签

================================================ =========================================== 2010 年 5 月 25 日更新

使用时

$('.anythingSlider').anythingSlider(options);

而不是

$('.anythingSlider').anythingSlider(6);

滑块运行,但我注意到我收到 Javascript 错误:需要对象 还有什么我需要通过的吗? 因为之前anythingSlider 采用6 而不是选项,所以我在哪里通过那个6,因为它正在寻找它。

【问题讨论】:

    标签: jquery


    【解决方案1】:

    试试这个脚本。它应该在加载滑块内容的任何脚本(Ajax?)之后添加。

    $(function () {
     var singleSlide = true,
         options = {
          autoPlay: false,                // This turns off the entire FUNCTIONALY, not just if it starts running or not.
          buildNavigation: false,         // If true, builds and list of anchor links to link to each slide
          easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
          delay: 3000,                    // How long between slide transitions in AutoPlay mode
          animationTime: 600,             // How long the slide transition takes
          hashTags: true,                 // Should links change the hashtag in the URL?
          pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
          navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
        };
    
     // Add player options if more than one slide exists
     if ( $('.anythingSlider > div > ul > li').length > 1 ) {
      $.extend(options, {
       autoPlay: true,
       startStopped: false,     // If autoPlay is on, this can force it to start stopped
       startText: "Go",         // Start text
       stopText: "Stop",        // Stop text
       buildNavigation: true 
      });
      singleSlide = false;
     }
    
     // Initiate anythingSlider
     $('.anythingSlider').anythingSlider(options);
    
     // hide anythingSlider navigation arrows
     if (singleSlide) { $('.anythingSlider a.arrow').hide(); }
    });
    

    我个人认为这应该内置到脚本中...


    更新:

    使用$('.anythingSlider').anythingSlider(6); 格式旨在用于外部链接。我认为您可能会遇到该错误的唯一方法是在设置anythingSlider之前调用该函数。

    我认为不会产生影响的另一种方法是像这样调用滑块更改:$('.anythingSlider').data('AnythingSlider').gotoPage(6);

    【讨论】:

    • 我试图合并它但没有用..还有什么需要添加的吗?谢谢
    • 它只是打破了轮播,即当我插入它时它只是显示一个框架/滚动条而不是轮播。
    • 我为您发布了一个演示 (jsfiddle.net/66s6w)。它设置为显示两项,但如果您注释掉其中一项并再次运行脚本,您应该会看到正在运行的脚本。所以我只能猜测,如果演示适合您,那么您的代码中还有其他内容。
    • 当使用
       $('.anythingSlider').anythingSlider(options); 
      而不是
       $('.anythingSlider').anythingSlider(6); 
      滑块运行,但我注意到我收到一个 Javascript 错误:Object required 还有什么我需要传递的吗?由于在anythingSlider 使用6 而不是选项之前,我应该在哪里传递那个6,因为它可能正在寻找它?
    • 我刚刚对插件进行了修复,因此当只有一页时它不会显示导航或播放器控件,请在此处查看:github.com/Mottie/AnythingSlider
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-10
    • 1970-01-01
    • 2012-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多