如何使用相同的js函数显示两个轮播

时间:2018-10-10 22:37:17

标签: javascript html slider carousel

我的网站上有一个旋转木马滑块,我复制了它以在同一页面上有另一个类似的滑块。第一个轮播工作正常,但是在第二个轮播中,上一个和下一个按钮不起作用,并且并非所有幻灯片都在显示。有没有办法在同一页面上重复使用同一功能两次?还是这里还有其他事情?任何事情都会有所帮助。

这是我的两个轮播代码:

<article class="content menu-top dark">
    <section class="featured-slider">
            <div class="ca-container">
                <div class="nav-featured">
                    <div class="prev-featured"></div>
                    <a href="#anchor3"><div class="btn-featured">Button</div></a>
                    <div class="next-featured"></div>
                </div>
                <div class="main-carousel hideme dontHide">
                    <div class="ca-wrapper">
                        <div class="ca-item ca-item-1">
                            <div class="f-single">
                                <a href="#" class="mfp-iframe">
                                    <div class="f-image">
                                        <img src="image1.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Watch Now</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-2">
                            <div class="f-single">
                                <a href="#" class="mfp-iframe">
                                    <div class="f-image">
                                        <img src="image2.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Watch Now</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-3">
                            <div class="f-single">
                                <a href="#" class="mfp-iframe">
                                    <div class="f-image">
                                        <img src="image3.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Watch Now</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-4">
                            <div class="f-single">
                                <a href="#" class="mfp-iframe">
                                    <div class="f-image">
                                        <img src="image4.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Watch Now</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-5">
                            <div class="f-single">
                                <a href="#" class="mfp-iframe">
                                    <div class="f-image">
                                        <img src="image5.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Watch Now</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                         <div class="ca-item ca-item-6">
                            <div class="f-single">
                                <a href="#" class="mfp-iframe">
                                    <div class="f-image">
                                        <img src="image6.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Watch Now</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </article>



    <article class="content menu-top dark">
        <section class="featured-slider">
            <div class="ca-container">
                <div class="nav-featured">
                    <div class="prev-featured"></div>
                    <a href="#anchor5"><div class="btn-featured">Button</div></a>
                    <div class="next-featured"></div>
                </div>
                <div class="main-carousel hideme dontHide">
                    <div class="ca-wrapper">
                        <div class="ca-item ca-item-1">
                            <div class="f-single">
                                <a href="image7.jpg">
                                    <div class="f-image">
                                        <img src="image8.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Text</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-2">
                            <div class="f-single">
                                <a href="image9.jpg">
                                    <div class="f-image">
                                        <img src="image10.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Text</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-3">
                            <div class="f-single">
                                <a href="image11.jpg">
                                    <div class="f-image">
                                        <img src="image12.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Text</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-4">
                            <div class="f-single">
                                <a href="image13.jpg">
                                    <div class="f-image">
                                        <img src="image14.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Text</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-5">
                            <div class="f-single">
                                <a href="image15.jpg">
                                    <div class="f-image">
                                        <img src="image16.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Text</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-6">
                            <div class="f-single">
                                <a href="image17.jpg">
                                    <div class="f-image">
                                        <img src="image18.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Text</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Wales</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-7">
                            <div class="f-single">
                                <a href="image19.jpg">
                                    <div class="f-image">
                                        <img src="image20.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Text</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>
                        <div class="ca-item ca-item-8">
                            <div class="f-single">
                                <a href="image21.jpg">
                                    <div class="f-image">
                                        <img src="image22.jpg" alt='img'>
                                        <div class="image-hover-overlay"></div>
                                        <span class="f-category"></span>
                                        <div class="portfolio-meta">
                                            <div>Text</div>
                                            <div class="clear"></div>
                                            <div>Text</div>
                                        </div>
                                    </div>
                                    <div class="f-info">Text</div>
                                </a>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </section>
    </article>

轮播的JS:

(function($) {var   aux     = {
        navigate    : function( dir, $el, $wrapper, opts, cache ) {

            var scroll      = opts.scroll,
                factor      = 1,
                idxClicked  = 0;

            if( cache.expanded ) {
                scroll      = 1; // scroll is always 1 in full mode
                factor      = 3; // the width of the expanded item will be 3 times bigger than 1 collapsed item
                idxClicked  = cache.idxClicked; // the index of the clicked item
            }

            // clone the elements on the right / left and append / prepend them according to dir and scroll
            if( dir === 1 ) {
                $wrapper.find('div.ca-item:lt(' + scroll + ')').each(function(i) {
                    $(this).clone(true).css( 'left', ( cache.totalItems - idxClicked + i ) * cache.itemW * factor + 'px' ).appendTo( $wrapper );
                });
            }
            else {
                var $first  = $wrapper.children().eq(0);

                $wrapper.find('div.ca-item:gt(' + ( cache.totalItems  - 1 - scroll ) + ')').each(function(i) {
                    // insert before $first so they stay in the right order
                    $(this).clone(true).css( 'left', - ( scroll - i + idxClicked ) * cache.itemW * factor + 'px' ).insertBefore( $first );
                });
            }

            // animate the left of each item
            // the calculations are dependent on dir and on the cache.expanded value
            $wrapper.find('div.ca-item').each(function(i) {

                var $item   = $(this);
                $item.stop().animate({
                    left    :  ( dir === 1 ) ? '-=' + ( cache.itemW * factor * scroll ) + 'px' : '+=' + ( cache.itemW * factor * scroll ) + 'px'
                }, opts.sliderSpeed, opts.sliderEasing, function() {
                    if( ( dir === 1 && $item.position().left < - idxClicked * cache.itemW * factor ) || ( dir === -1 && $item.position().left > ( ( cache.totalItems - 1 - idxClicked ) * cache.itemW * factor ) ) ) {
                        // remove the item that was cloned
                        $item.remove();
                    }
                    cache.isAnimating   = false;
                });
            });
        },
        // gets the item's position (1, 2, or 3) on the viewport (the visible items)
        // val is the left of the item
        getWinPos   : function( val, cache ) {
            switch( val ) {
                case 0                  : return 1; break;
                case cache.itemW        : return 2; break;
                case cache.itemW * 2    : return 3; break;
            }
        }
    },
    methods = {
        init        : function( options ) {

            if( this.length ) {

                var settings = {
                    sliderSpeed     : 500,          // speed for the sliding animation
                    sliderEasing    : 'easeInOutCubic',// easing for the sliding animation
                    scroll          : 1             // number of items to scroll at a time
                };

                return this.each(function() {

                    // if options exist, lets merge them with our default settings
                    if ( options ) {
                        $.extend( settings, options );
                    }

                    var $el             = $(this),
                        $wrapper        = $el.find('div.ca-wrapper'),
                        $items          = $wrapper.children('div.ca-item'),
                        cache           = {};

                    // save the with of one item
                    cache.itemW         = $items.width();
                    // save the number of total items
                    cache.totalItems    = $items.length;

                    //centrar
                    $('.ca-wrapper').css('margin-left',-(cache.totalItems*cache.itemW/2))

                    // control the scroll value
                    if( settings.scroll < 1 )
                        settings.scroll = 1;
                    else if( settings.scroll > 3 )
                        settings.scroll = 3;

                    var $navPrev        = $el.find('.prev-featured'),
                        $navNext        = $el.find('.next-featured');

                    // hide the items except the first 3
                    //$wrapper.css( 'overflow', 'hidden' );

                    // the items will have position absolute
                    // calculate the left of each item
                    $items.each(function(i) {
                        $(this).css({
                            position    : 'absolute',
                            left        : i * cache.itemW + 'px'
                        });
                        //if(i==2){$('.f-single',this).addClass('active')}else{$('.f-single',this).removeClass('active')}
                    });

                    // navigate left
                    $navPrev.bind('click.contentcarousel', function( event ) {
                        if( cache.isAnimating ) return false;
                        cache.isAnimating   = true;
                        aux.navigate( -1, $el, $wrapper, settings, cache );
                    });

                    // navigate right
                    $navNext.bind('click.contentcarousel', function( event ) {
                        if( cache.isAnimating ) return false;
                        cache.isAnimating   = true;
                        aux.navigate( 1, $el, $wrapper, settings, cache );
                    });
                });
            }
        }
    };
$.fn.contentcarousel = function(method) {
    if ( methods[method] ) {
        return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
    } else if ( typeof method === 'object' || ! method ) {
        return methods.init.apply( this, arguments );
    } else {
        $.error( 'Method ' +  method + ' does not exist on jQuery.contentcarousel' );
    }
};
})(jQuery);

CSS:

.main-carousel{
overflow: hidden;
width: 100%;
position: relative;
height:376px;
}
.f-image{
color: #fff;
}
.f-image a{
color: #fff;
text-decoration: none;
}
.f-single .portfolio-meta,.t-element .portfolio-meta {
color: #fff;
position: absolute;
bottom: 0;
left: 0;
z-index: 20;
width: 100%;
text-align: center;
text-transform: uppercase;
zoom: 1;
filter: alpha(opacity=0);
opacity: 0;
font-size: 15px;
font-weight: 400;
letter-spacing: 1px;
font-family: 'Open Sans', sans-serif;

-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.f-single .portfolio-meta,.t-element .portfolio-meta {
color: #fff;
position: absolute;
bottom: 0;
left: 0;
z-index: 20;
width: 100%;
text-align: center;
text-transform: uppercase;
zoom: 1;
filter: alpha(opacity=0);
opacity: 0;
font-size: 15px;
font-weight: 400;
letter-spacing: 1px;
font-family: 'Open Sans', sans-serif;

-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}


.f-single:hover .portfolio-meta,.t-element:hover .portfolio-meta{
bottom: 75px;
zoom: 1;
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.f-single:hover .f-category,.t-element:hover .f-category{
top: 85px;
zoom: 1;
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}

.f-image .f-category{
text-decoration: none;
position: absolute;
top: 20%;
left: 50%;
z-index: 20;
display: block;
margin-left: -22px;
width: 44px;
height: 44px;
text-align: center;
line-height: 44px;
zoom: 1;
filter: alpha(opacity=0);
opacity: 0;
background: url("color/img/color-icons.png") no-repeat;

-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}

.f-single a{text-decoration: none;}
.image-hover-overlay {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
zoom: 1;
filter: alpha(opacity=0);
opacity: 0;
}
.f-image .image-hover-overlay,.t-photo .image-hover-overlay {
z-index: 11;
background-color: #000!important;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.f-single:hover .image-hover-overlay,.t-element:hover .image-hover-overlay 
{
zoom: 1;
filter: alpha(opacity=85);
opacity: .85;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.active .f-info {opacity: 1;}

.ca-container{
position: relative;
width: 100%;
height: auto;
margin-bottom: 20px;
}
.ca-nav span {
width: 25px;
height: 38px;
background: transparent url(../img/f-next.png) no-repeat top left;
position: absolute;
top: 50%;
margin-top: -19px;
left: -40px;
text-indent: -9000px;
opacity: 0.7;
cursor: pointer;
z-index: 100;
}
.ca-nav span.ca-nav-next {
background-position: top right;
left: auto;
right: -40px;
}
.ca-wrapper {
width: 100%;
height: 100%;
position: absolute;
left: 50%;
}
.ca-item{
position: relative;
float: left;
width: auto;
text-align: center;
}

.content{position: relative;}
.dark{background: #282828; padding-bottom: 85px;}

.f-single{
width: 467px;
float: left;
margin: 0 15px;
position: relative;
}
 .f-single:hover .f-image{
opacity: 1;
 }

.f-single:hover .f-info{
cursor: pointer;
opacity: 1;
background: #FF2C2C;
color: #fff;

-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}


.featured-carousel{
width: 100%;
height: auto;
overflow: hidden;
}
.featured-list{overflow: auto;}
.nav-featured{
margin: 80px auto;
height: 57px;
width: 455px;
}
.nav-featured div{float: left; cursor: pointer;}
 .nav-featured .details-button {
margin-left:37%;
}

.prev-featured{
background: url("../img/f-prev.png") no-repeat #e1e1e1;
width: 30px;
height: 57px;
margin-right: 110px;
}
.prev-featured:hover{background-color: #000000;}
.next-featured{
background: url("../img/f-next.png") no-repeat #e1e1e1;
width: 30px;
height: 57px;
margin-left: 110px;
}
.next-featured:hover{background-color: #000000;}

.nav-featured .btn-featured{
color: #fff;
margin-top: 4px;
font-size: 14px;
text-transform: uppercase;
font-weight: 400;
text-align: center;
font-family: 'Open Sans', sans-serif;
background: #FF2C2C;
border-radius: 25px;
padding: 13px 25px 13px;
letter-spacing: 1px;

-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
.nav-featured .btn-featured:hover{background: #000000;}
.btn-featured a{text-decoration: none; color: #fff;}

.title.one{ 
 color: #fff; 
 font-size: 37px; 
 letter-spacing: 5px; 
 padding: 120px 0 30px; 
 text-transform: uppercase;}
.title.two{color: #fff; font-size: 17px; font-family: 'Open Sans', sans- 
serif; width: 680px; margin: 50px auto;}
.f-info{
font-weight: 400;
text-align: center;
font-family: 'Open Sans', sans-serif;
font-size: 17px;
color: #ffffff;
background: #000000;
line-height: 30px;
padding: 40px 20px;
letter-spacing: 1px;
text-transform: uppercase;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.f-image{
cursor: pointer;
position: relative;

-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.light{background: #000; position: relative;}
.dark:after {
content: '';
position: absolute;
width: 0;
height: 0;
border: 30px solid #f7f7f7;
border-bottom: 0px solid transparent !important;
border-right: 30px solid transparent !important;
border-left: 30px solid transparent !important;
left: 50%;
bottom: -28px;
margin-left: -29px;
z-index: 10;
}

1 个答案:

答案 0 :(得分:0)

两个轮播都为我工作,我只需要更改控件的位置(上,下一个使用css),因为它们重叠了。

(function($) {
  var aux = {
      navigate: function(dir, $el, $wrapper, opts, cache) {

        var scroll = opts.scroll,
          factor = 1,
          idxClicked = 0;

        if (cache.expanded) {
          scroll = 1; // scroll is always 1 in full mode
          factor = 3; // the width of the expanded item will be 3 times bigger than 1 collapsed item
          idxClicked = cache.idxClicked; // the index of the clicked item
        }

        // clone the elements on the right / left and append / prepend them according to dir and scroll
        if (dir === 1) {
          $wrapper.find('div.ca-item:lt(' + scroll + ')').each(function(i) {
            $(this).clone(true).css('left', (cache.totalItems - idxClicked + i) * cache.itemW * factor + 'px').appendTo($wrapper);
          });
        } else {
          var $first = $wrapper.children().eq(0);

          $wrapper.find('div.ca-item:gt(' + (cache.totalItems - 1 - scroll) + ')').each(function(i) {
            // insert before $first so they stay in the right order
            $(this).clone(true).css('left', -(scroll - i + idxClicked) * cache.itemW * factor + 'px').insertBefore($first);
          });
        }

        // animate the left of each item
        // the calculations are dependent on dir and on the cache.expanded value
        $wrapper.find('div.ca-item').each(function(i) {

          var $item = $(this);
          $item.stop().animate({
            left: (dir === 1) ? '-=' + (cache.itemW * factor * scroll) + 'px' : '+=' + (cache.itemW * factor * scroll) + 'px'
          }, opts.sliderSpeed, opts.sliderEasing, function() {
            if ((dir === 1 && $item.position().left < -idxClicked * cache.itemW * factor) || (dir === -1 && $item.position().left > ((cache.totalItems - 1 - idxClicked) * cache.itemW * factor))) {
              // remove the item that was cloned
              $item.remove();
            }
            cache.isAnimating = false;
          });
        });
      },
      // gets the item's position (1, 2, or 3) on the viewport (the visible items)
      // val is the left of the item
      getWinPos: function(val, cache) {
        switch (val) {
          case 0:
            return 1;
            break;
          case cache.itemW:
            return 2;
            break;
          case cache.itemW * 2:
            return 3;
            break;
        }
      }
    },
    methods = {
      init: function(options) {

        if (this.length) {

          var settings = {
            sliderSpeed: 500, // speed for the sliding animation
            sliderEasing: 'easeInOutCubic', // easing for the sliding animation
            scroll: 1 // number of items to scroll at a time
          };

          return this.each(function() {

            // if options exist, lets merge them with our default settings
            if (options) {
              $.extend(settings, options);
            }

            var $el = $(this),
              $wrapper = $el.find('div.ca-wrapper'),
              $items = $wrapper.children('div.ca-item'),
              cache = {};

            // save the with of one item
            cache.itemW = $items.width();
            // save the number of total items
            cache.totalItems = $items.length;

            //centrar
            $('.ca-wrapper').css('margin-left', -(cache.totalItems * cache.itemW / 2))

            // control the scroll value
            if (settings.scroll < 1)
              settings.scroll = 1;
            else if (settings.scroll > 3)
              settings.scroll = 3;

            var $navPrev = $el.find('.prev-featured'),
              $navNext = $el.find('.next-featured');

            // hide the items except the first 3
            //$wrapper.css( 'overflow', 'hidden' );

            // the items will have position absolute
            // calculate the left of each item
            $items.each(function(i) {
              $(this).css({
                position: 'absolute',
                left: i * cache.itemW + 'px'
              });
              //if(i==2){$('.f-single',this).addClass('active')}else{$('.f-single',this).removeClass('active')}
            });

            // navigate left
            $navPrev.bind('click.contentcarousel', function(event) {
              if (cache.isAnimating) return false;
              cache.isAnimating = true;
              aux.navigate(-1, $el, $wrapper, settings, cache);
            });

            // navigate right
            $navNext.bind('click.contentcarousel', function(event) {
              if (cache.isAnimating) return false;
              cache.isAnimating = true;
              aux.navigate(1, $el, $wrapper, settings, cache);
            });
          });
        }
      }
    };
  $.fn.contentcarousel = function(method) {
    if (methods[method]) {
      return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
    } else if (typeof method === 'object' || !method) {
      return methods.init.apply(this, arguments);
    } else {
      $.error('Method ' + method + ' does not exist on jQuery.contentcarousel');
    }
  };
})(jQuery);

//use your plugin on both carousels
$(".featured-slider").contentcarousel({
  sliderEasing: "swing"
});
.main-carousel{
overflow: hidden;
width: 100%;
position: relative;
height:376px;
}
.f-image{
color: #fff;
}
.f-image a{
color: #fff;
text-decoration: none;
}
.f-single .portfolio-meta,.t-element .portfolio-meta {
color: #fff;
position: absolute;
bottom: 0;
left: 0;
z-index: 20;
width: 100%;
text-align: center;
text-transform: uppercase;
zoom: 1;
filter: alpha(opacity=0);
opacity: 0;
font-size: 15px;
font-weight: 400;
letter-spacing: 1px;
font-family: 'Open Sans', sans-serif;

-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.f-single .portfolio-meta,.t-element .portfolio-meta {
color: #fff;
position: absolute;
bottom: 0;
left: 0;
z-index: 20;
width: 100%;
text-align: center;
text-transform: uppercase;
zoom: 1;
filter: alpha(opacity=0);
opacity: 0;
font-size: 15px;
font-weight: 400;
letter-spacing: 1px;
font-family: 'Open Sans', sans-serif;

-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}


.f-single:hover .portfolio-meta,.t-element:hover .portfolio-meta{
bottom: 75px;
zoom: 1;
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.f-single:hover .f-category,.t-element:hover .f-category{
top: 85px;
zoom: 1;
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}

.f-image .f-category{
text-decoration: none;
position: absolute;
top: 20%;
left: 50%;
z-index: 20;
display: block;
margin-left: -22px;
width: 44px;
height: 44px;
text-align: center;
line-height: 44px;
zoom: 1;
filter: alpha(opacity=0);
opacity: 0;
background: url("color/img/color-icons.png") no-repeat;

-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}

.f-single a{text-decoration: none;}
.image-hover-overlay {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
zoom: 1;
filter: alpha(opacity=0);
opacity: 0;
}
.f-image .image-hover-overlay,.t-photo .image-hover-overlay {
z-index: 11;
background-color: #000!important;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.f-single:hover .image-hover-overlay,.t-element:hover .image-hover-overlay 
{
zoom: 1;
filter: alpha(opacity=85);
opacity: .85;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.active .f-info {opacity: 1;}

.ca-container{
position: relative;
width: 100%;
height: auto;
margin-bottom: 20px;
}
.ca-nav span {
width: 25px;
height: 38px;
background: transparent url(../img/f-next.png) no-repeat top left;
position: absolute;
top: 50%;
margin-top: -19px;
left: -40px;
text-indent: -9000px;
opacity: 0.7;
cursor: pointer;
z-index: 100;
}
.ca-nav span.ca-nav-next {
background-position: top right;
left: auto;
right: -40px;
}
.ca-wrapper {
width: 100%;
height: 100%;
position: absolute;
left: 50%;
}
.ca-item{
position: relative;
float: left;
width: auto;
text-align: center;
}

.content{position: relative;}
.dark{background: #282828; padding-bottom: 85px;}

.f-single{
width: 467px;
float: left;
margin: 0 15px;
position: relative;
}
 .f-single:hover .f-image{
opacity: 1;
 }

.f-single:hover .f-info{
cursor: pointer;
opacity: 1;
background: #FF2C2C;
color: #fff;

-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}


.featured-carousel{
width: 100%;
height: auto;
overflow: hidden;
}
.featured-list{overflow: auto;}
.nav-featured{
margin: 80px auto;
height: 57px;
width: 455px;
}
.nav-featured div{float: left; cursor: pointer;}
 .nav-featured .details-button {
margin-left:37%;
}

.prev-featured{
background: url("../img/f-prev.png") no-repeat #e1e1e1;
width: 30px;
height: 57px;
margin-right: 110px;
}
.prev-featured:hover{background-color: #000000;}
.next-featured{
background: url("../img/f-next.png") no-repeat #e1e1e1;
width: 30px;
height: 57px;
margin-left: 110px;
}
.next-featured:hover{background-color: #000000;}

.nav-featured .btn-featured{
color: #fff;
margin-top: 4px;
font-size: 14px;
text-transform: uppercase;
font-weight: 400;
text-align: center;
font-family: 'Open Sans', sans-serif;
background: #FF2C2C;
border-radius: 25px;
padding: 13px 25px 13px;
letter-spacing: 1px;

-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
.nav-featured .btn-featured:hover{background: #000000;}
.btn-featured a{text-decoration: none; color: #fff;}

.title.one{ 
 color: #fff; 
 font-size: 37px; 
 letter-spacing: 5px; 
 padding: 120px 0 30px; 
 text-transform: uppercase;}
.title.two{color: #fff; font-size: 17px; font-family: 'Open Sans', sans- 
serif; width: 680px; margin: 50px auto;}
.f-info{
font-weight: 400;
text-align: center;
font-family: 'Open Sans', sans-serif;
font-size: 17px;
color: #ffffff;
background: #000000;
line-height: 30px;
padding: 40px 20px;
letter-spacing: 1px;
text-transform: uppercase;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.f-image{
cursor: pointer;
position: relative;

-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.light{background: #000; position: relative;}
.dark:after {
content: '';
position: absolute;
width: 0;
height: 0;
border: 30px solid #f7f7f7;
border-bottom: 0px solid transparent !important;
border-right: 30px solid transparent !important;
border-left: 30px solid transparent !important;
left: 50%;
bottom: -28px;
margin-left: -29px;
z-index: 10;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

<article class="content menu-top dark">
  <section class="featured-slider">
    <div class="ca-container">
      <div class="nav-featured">
        <div class="prev-featured">first carousel prev</div>
        <a href="#anchor3">
          <div class="btn-featured">Button</div>
        </a>
        <div class="next-featured">first carousel next</div>
      </div>
      <div class="main-carousel hideme dontHide">
        <div class="ca-wrapper">
          <div class="ca-item ca-item-1">
            <div class="f-single">
              <a href="#" class="mfp-iframe">
                <div class="f-image">
                  <img src="https://upload.wikimedia.org/wikipedia/fr/7/71/Quebec_citadelles_200x200.png" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Watch Now</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-2">
            <div class="f-single">
              <a href="#" class="mfp-iframe">
                <div class="f-image">
                  <img src="https://vignette.wikia.nocookie.net/assassinscreed/images/7/7d/200X200.jpg/revision/latest?cb=20120929231337" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Watch Now</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-3">
            <div class="f-single">
              <a href="#" class="mfp-iframe">
                <div class="f-image">
                  <img src="https://vignette.wikia.nocookie.net/cityville/images/5/58/Viral_basketballcomplex_basketball_200x200.png/revision/latest?cb=20130613014636" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Watch Now</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-4">
            <div class="f-single">
              <a href="#" class="mfp-iframe">
                <div class="f-image">
                  <img src="https://vignette.wikia.nocookie.net/lego/images/1/16/Harrypottery5-7-200x200.jpg/revision/latest?cb=20111021110949" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Watch Now</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-5">
            <div class="f-single">
              <a href="#" class="mfp-iframe">
                <div class="f-image">
                  <img src="http://punkerslut.com/graphics-library-of-revolution-and-social-justice/anonymous-and-anonymous-movement/vectorportal---1/vectorportal---1__200x200.jpg" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Watch Now</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-6">
            <div class="f-single">
              <a href="#" class="mfp-iframe">
                <div class="f-image">
                  <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRKDkWdvfhgOAgyuq3TYy-7eUWP_LaQYv4g2kwLqtKmUPuFKkqX" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Watch Now</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</article>



<article class="content menu-top dark">
  <section class="featured-slider">
    <div class="ca-container">
      <div class="nav-featured">
        <div class="prev-featured">second carousel prev</div>
        <a href="#anchor5">
          <div class="btn-featured">Button</div>
        </a>
        <div class="next-featured">second carousel next</div>
      </div>
      <div class="main-carousel hideme dontHide">
        <div class="ca-wrapper">
          <div class="ca-item ca-item-1">
            <div class="f-single">
              <a href="img/image7.jpg">
                <div class="f-image">
                  <img src="http://chan.catiewayne.com/c/src/138578149239.png" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Text</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-2">
            <div class="f-single">
              <a href="img/image9.jpg">
                <div class="f-image">
                  <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSEUHV4ecSVdfsq5zVsQtbCnQOg4HIZNsUghdDdsbu0hSxTDNycrQ" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Text</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-3">
            <div class="f-single">
              <a href="img/image11.jpg">
                <div class="f-image">
                  <img src="http://www.mallvarna.com/files/rte/article33/batux-tux-g2-hd-200x200.png" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Text</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-4">
            <div class="f-single">
              <a href="img/image13.jpg">
                <div class="f-image">
                  <img src="http://s2.dmcdn.net/KXh8h/200x200-CAR.jpg" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Text</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-5">
            <div class="f-single">
              <a href="img/image15.jpg">
                <div class="f-image">
                  <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR5A99ssb425kbuXfGX38qYSSDEgrvCr3IdaSXqZ7ZWOmqbRsSsNA" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Text</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-6">
            <div class="f-single">
              <a href="img/image17.jpg">
                <div class="f-image">
                  <img src="https://serrescircuit.gr/wp-content/uploads/2018/02/male-200x200.jpg" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Text</div>
                  </div>
                </div>
                <div class="f-info">Wales</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-7">
            <div class="f-single">
              <a href="img/image19.jpg">
                <div class="f-image">
                  <img src="https://orig00.deviantart.net/2548/f/2013/224/c/f/world_of_warcraft_200x200_by_dragoanasazi-d6hu54l.png" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Text</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>
          <div class="ca-item ca-item-8">
            <div class="f-single">
              <a href="img/image21.jpg">
                <div class="f-image">
                  <img src="http://www.atelierdecoz.fr/img/cms/thunderbird-logo-200x200.png" alt='img'>
                  <div class="image-hover-overlay"></div>
                  <span class="f-category"></span>
                  <div class="portfolio-meta">
                    <div>Text</div>
                    <div class="clear"></div>
                    <div>Text</div>
                  </div>
                </div>
                <div class="f-info">Text</div>
              </a>
            </div>
          </div>

        </div>
      </div>
    </div>
  </section>
</article>