如何修改此jQuery插件滑块的滚动和方向? [英] How to modify this jQuery plugin slider for scrolling and orientation?

查看:110
本文介绍了如何修改此jQuery插件滑块的滚动和方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了一个几乎可以满足我需要的jQuery滑块插件.我需要更改选项卡,使其位于右侧(通过添加选项).另外,如果有3个以上的选项卡(也可以选择),我想向选项卡添加滚动.我正在尝试使它看起来像是艺术家的模型:

I found a jQuery slider plugin that does almost what I need. I need to change the tabs so it is on the right side (by adding an option). Also, I would like to add scrolling to the tabs in case there is more than 3 tabs (also by an option). I am trying to make it look like this which is an artist mock up:

http://i.stack.imgur.com/nR8RY.png

这是我尝试使用其下面的代码修改的脚本: http://jqueryglobe.com/labs/feature_list/

This is the script I am trying to modify with the code below it: http://jqueryglobe.com/labs/feature_list/

/*
 * FeatureList - simple and easy creation of an interactive "Featured Items" widget
 * Examples and documentation at: http://jqueryglobe.com/article/feature_list/
 * Version: 1.0.0 (01/09/2009)
 * Copyright (c) 2009 jQueryGlobe
 * Licensed under the MIT License: http://en.wikipedia.org/wiki/MIT_License
 * Requires: jQuery v1.3+
*/
;(function($) {
    $.fn.featureList = function(options) {
        var tabs    = $(this);
        var output  = $(options.output);

        new jQuery.featureList(tabs, output, options);

        return this;    
    };

    $.featureList = function(tabs, output, options) {
        function slide(nr) {
            if (typeof nr == "undefined") {
                nr = visible_item + 1;
                nr = nr >= total_items ? 0 : nr;
            }

            tabs.removeClass('current').filter(":eq(" + nr + ")").addClass('current');

            output.stop(true, true).filter(":visible").fadeOut();
            output.filter(":eq(" + nr + ")").fadeIn(function() {
                visible_item = nr;  
            });
        }

        var options         = options || {}; 
        var total_items     = tabs.length;
        var visible_item    = options.start_item || 0;

        options.pause_on_hover      = options.pause_on_hover        || true;
        options.transition_interval = options.transition_interval   || 5000;

        output.hide().eq( visible_item ).show();
        tabs.eq( visible_item ).addClass('current');

        tabs.click(function() {
            if ($(this).hasClass('current')) {
                return false;   
            }

            slide( tabs.index( this) );
        });

        if (options.transition_interval > 0) {
            var timer = setInterval(function () {
                slide();
            }, options.transition_interval);

            if (options.pause_on_hover) {
                tabs.mouseenter(function() {
                    clearInterval( timer );

                }).mouseleave(function() {
                    clearInterval( timer );
                    timer = setInterval(function () {
                        slide();
                    }, options.transition_interval);
                });
            }
        }
    };
})(jQuery);

这是CSS:

body {
    background: #EEE;   
    font-family: "Trebuchet MS",Verdana,Arial,sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

#content {
    width: 750px;
    margin: 50px auto;
    padding: 20px;
    background: #FFF;   
    border: 1px solid #CCC;
}

h1 {
    margin: 0;
}

hr {
    border: none;
    height: 1px; line-height: 1px;
    background: #CCC;   
    margin-bottom: 20px;
    padding: 0;
}

p {
    margin: 0;  
    padding: 7px 0;
}

.clear {
    clear: both;
    line-height: 1px;
    font-size: 1px;
}

a { 
    outline-color: #888;    
}

任何人都可以帮忙吗?

推荐答案

答案: jsFiddle:功能框滚动和滚动

Answer: jsFiddle: features box that slides and scrolls

功能:

  • 随时间推移滑动
  • 单击下一个和上一个
  • 支持很多幻灯片
  • 平滑滚动
  • 点击时移至项目
  • 悬停时停止运动
  • 易于扩展,因为它使用了循环插件.

在项目上花费的时间: 4小时

Time spent on project: 4hrs

这篇关于如何修改此jQuery插件滑块的滚动和方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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