Foros del Web » Programando para Internet » Jquery »

Modificar Carousel

Estas en el tema de Modificar Carousel en el foro de Jquery en Foros del Web. Hola a todos, estoy usando este carousel: http://tympanus.net/Development/Circ...ntentCarousel/ y me funciona a la perfeccion, pero necesito hacerle dos modificaciones y no tengo mucha idea, lo ...
  #1 (permalink)  
Antiguo 03/06/2015, 13:48
 
Fecha de Ingreso: enero-2010
Mensajes: 400
Antigüedad: 14 años, 2 meses
Puntos: 6
Modificar Carousel

Hola a todos, estoy usando este carousel:
http://tympanus.net/Development/Circ...ntentCarousel/
y me funciona a la perfeccion, pero necesito hacerle dos modificaciones y no tengo mucha idea, lo unico que hice fue descargarlo e integrarloa mi index.php cambiando las medidas.
Necesito hacer que se mueva solo, sin apretar las flechas, por ej cada 5 segundos que cambie la imagen.
Y otra cosa no se si sera muy complicado agregarle el indice abajo para elegir la noticia
asi como lo utiliza esta web: http://www.bocajuniors.com.ar/
espero su respuesta y ojala puedan ayudarme. gracias

El codigo .js es:
Código PHP:
Ver original
  1. (function($) {
  2.     var aux     = {
  3.             // navigates left / right
  4.             navigate    : function( dir, $el, $wrapper, opts, cache ) {
  5.                
  6.                 var scroll      = opts.scroll,
  7.                     factor      = 1,
  8.                     idxClicked  = 0;
  9.                    
  10.                 if( cache.expanded ) {
  11.                     scroll      = 1; // scroll is always 1 in full mode
  12.                     factor      = 3; // the width of the expanded item will be 3 times bigger than 1 collapsed item
  13.                     idxClicked  = cache.idxClicked; // the index of the clicked item
  14.                 }
  15.                
  16.                 // clone the elements on the right / left and append / prepend them according to dir and scroll
  17.                 if( dir === 1 ) {
  18.                     $wrapper.find('div.ca-item:lt(' + scroll + ')').each(function(i) {
  19.                         $(this).clone(true).css( 'left', ( cache.totalItems - idxClicked + i ) * cache.itemW * factor + 'px' ).appendTo( $wrapper );
  20.                     });
  21.                 }
  22.                 else {
  23.                     var $first  = $wrapper.children().eq(0);
  24.                    
  25.                     $wrapper.find('div.ca-item:gt(' + ( cache.totalItems  - 1 - scroll ) + ')').each(function(i) {
  26.                         // insert before $first so they stay in the right order
  27.                         $(this).clone(true).css( 'left', - ( scroll - i + idxClicked ) * cache.itemW * factor + 'px' ).insertBefore( $first );
  28.                     });
  29.                 }
  30.                
  31.                 // animate the left of each item
  32.                 // the calculations are dependent on dir and on the cache.expanded value
  33.                 $wrapper.find('div.ca-item').each(function(i) {
  34.                     var $item   = $(this);
  35.                     $item.stop().animate({
  36.                         left    :  ( dir === 1 ) ? '-=' + ( cache.itemW * factor * scroll ) + 'px' : '+=' + ( cache.itemW * factor * scroll ) + 'px'
  37.                     }, opts.sliderSpeed, opts.sliderEasing, function() {
  38.                         if( ( dir === 1 && $item.position().left < - idxClicked * cache.itemW * factor ) || ( dir === -1 && $item.position().left > ( ( cache.totalItems - 1 - idxClicked ) * cache.itemW * factor ) ) ) {
  39.                             // remove the item that was cloned
  40.                             $item.remove();
  41.                         }                      
  42.                         cache.isAnimating   = false;
  43.                     });
  44.                 });
  45.                
  46.             },
  47.             // opens an item (animation) -> opens all the others
  48.             openItem    : function( $wrapper, $item, opts, cache ) {
  49.                 cache.idxClicked    = $item.index();
  50.                 // the item's position (1, 2, or 3) on the viewport (the visible items)
  51.                 cache.winpos        = aux.getWinPos( $item.position().left, cache );
  52.                 $wrapper.find('div.ca-item').not( $item ).hide();
  53.                 $item.find('div.ca-content-wrapper').css( 'left', cache.itemW + 'px' ).stop().animate({
  54.                     width   : cache.itemW * 2 + 'px',
  55.                     left    : cache.itemW + 'px'
  56.                 }, opts.itemSpeed, opts.itemEasing)
  57.                 .end()
  58.                 .stop()
  59.                 .animate({
  60.                     left    : '0px'
  61.                 }, opts.itemSpeed, opts.itemEasing, function() {
  62.                     cache.isAnimating   = false;
  63.                     cache.expanded      = true;
  64.                    
  65.                     aux.openItems( $wrapper, $item, opts, cache );
  66.                 });
  67.                        
  68.             },
  69.             // opens all the items
  70.             openItems   : function( $wrapper, $openedItem, opts, cache ) {
  71.                 var openedIdx   = $openedItem.index();
  72.                
  73.                 $wrapper.find('div.ca-item').each(function(i) {
  74.                     var $item   = $(this),
  75.                         idx     = $item.index();
  76.                    
  77.                     if( idx !== openedIdx ) {
  78.                         $item.css( 'left', - ( openedIdx - idx ) * ( cache.itemW * 3 ) + 'px' ).show().find('div.ca-content-wrapper').css({
  79.                             left    : cache.itemW + 'px',
  80.                             width   : cache.itemW * 2 + 'px'
  81.                         });
  82.                        
  83.                         // hide more link
  84.                         aux.toggleMore( $item, false );
  85.                     }
  86.                 });
  87.             },
  88.             // show / hide the item's more button
  89.             toggleMore  : function( $item, show ) {
  90.                 ( show ) ? $item.find('a.ca-more').show() : $item.find('a.ca-more').hide();
  91.             },
  92.             // close all the items
  93.             // the current one is animated
  94.             closeItems  : function( $wrapper, $openedItem, opts, cache ) {
  95.                 var openedIdx   = $openedItem.index();
  96.                
  97.                 $openedItem.find('div.ca-content-wrapper').stop().animate({
  98.                     width   : '0px'
  99.                 }, opts.itemSpeed, opts.itemEasing)
  100.                 .end()
  101.                 .stop()
  102.                 .animate({
  103.                     left    : cache.itemW * ( cache.winpos - 1 ) + 'px'
  104.                 }, opts.itemSpeed, opts.itemEasing, function() {
  105.                     cache.isAnimating   = false;
  106.                     cache.expanded      = false;
  107.                 });
  108.                
  109.                 // show more link
  110.                 aux.toggleMore( $openedItem, true );
  111.                
  112.                 $wrapper.find('div.ca-item').each(function(i) {
  113.                     var $item   = $(this),
  114.                         idx     = $item.index();
  115.                    
  116.                     if( idx !== openedIdx ) {
  117.                         $item.find('div.ca-content-wrapper').css({
  118.                             width   : '0px'
  119.                         })
  120.                         .end()
  121.                         .css( 'left', ( ( cache.winpos - 1 ) - ( openedIdx - idx ) ) * cache.itemW + 'px' )
  122.                         .show();
  123.                        
  124.                         // show more link
  125.                         aux.toggleMore( $item, true );
  126.                     }
  127.                 });
  128.             },
  129.             // gets the item's position (1, 2, or 3) on the viewport (the visible items)
  130.             // val is the left of the item
  131.             getWinPos   : function( val, cache ) {
  132.                 switch( val ) {
  133.                     case 0                  : return 1; break;
  134.                     case cache.itemW        : return 2; break;
  135.                     case cache.itemW * 2    : return 3; break;
  136.                 }
  137.             }
  138.         },
  139.         methods = {
  140.             init        : function( options ) {
  141.                
  142.                 if( this.length ) {
  143.                    
  144.                     var settings = {
  145.                         sliderSpeed     : 500,          // speed for the sliding animation
  146.                         sliderEasing    : 'easeOutExpo',// easing for the sliding animation
  147.                         itemSpeed       : 500,          // speed for the item animation (open / close)
  148.                         itemEasing      : 'easeOutExpo',// easing for the item animation (open / close)
  149.                         scroll          : 1             // number of items to scroll at a time
  150.                     };
  151.                    
  152.                     return this.each(function() {
  153.                        
  154.                         // if options exist, lets merge them with our default settings
  155.                         if ( options ) {
  156.                             $.extend( settings, options );
  157.                         }
  158.                        
  159.                         var $el             = $(this),
  160.                             $wrapper        = $el.find('div.ca-wrapper'),
  161.                             $items          = $wrapper.children('div.ca-item'),
  162.                             cache           = {};
  163.                        
  164.                         // save the with of one item   
  165.                         cache.itemW         = $items.width();
  166.                         // save the number of total items
  167.                         cache.totalItems    = $items.length;
  168.                        
  169.                         // add navigation buttons
  170.                         if( cache.totalItems > 3 ) 
  171.                             $el.prepend('<div class="ca-nav"><span class="ca-nav-prev">Previous</span><span class="ca-nav-next">Next</span></div>')
  172.                        
  173.                         // control the scroll value
  174.                         if( settings.scroll < 1 )
  175.                             settings.scroll = 1;
  176.                         else if( settings.scroll > 3 )
  177.                             settings.scroll = 3;   
  178.                        
  179.                         var $navPrev        = $el.find('span.ca-nav-prev'),
  180.                             $navNext        = $el.find('span.ca-nav-next');
  181.                        
  182.                         // hide the items except the first 3
  183.                         $wrapper.css( 'overflow', 'hidden' );
  184.                        
  185.                         // the items will have position absolute
  186.                         // calculate the left of each item
  187.                         $items.each(function(i) {
  188.                             $(this).css({
  189.                                 position    : 'absolute',
  190.                                 left        : i * cache.itemW + 'px'
  191.                             });
  192.                         });
  193.                        
  194.                         // click to open the item(s)
  195.                         $el.find('a.ca-more').live('click.contentcarousel', function( event ) {
  196.                             if( cache.isAnimating ) return false;
  197.                             cache.isAnimating   = true;
  198.                             $(this).hide();
  199.                             var $item   = $(this).closest('div.ca-item');
  200.                             aux.openItem( $wrapper, $item, settings, cache );
  201.                             return false;
  202.                         });
  203.                        
  204.                         // click to close the item(s)
  205.                         $el.find('a.ca-close').live('click.contentcarousel', function( event ) {
  206.                             if( cache.isAnimating ) return false;
  207.                             cache.isAnimating   = true;
  208.                             var $item   = $(this).closest('div.ca-item');
  209.                             aux.closeItems( $wrapper, $item, settings, cache );
  210.                             return false;
  211.                         });
  212.                        
  213.                         // navigate left
  214.                         $navPrev.bind('click.contentcarousel', function( event ) {
  215.                             if( cache.isAnimating ) return false;
  216.                             cache.isAnimating   = true;
  217.                             aux.navigate( -1, $el, $wrapper, settings, cache );
  218.                         });
  219.                        
  220.                         // navigate right
  221.                         $navNext.bind('click.contentcarousel', function( event ) {
  222.                             if( cache.isAnimating ) return false;
  223.                             cache.isAnimating   = true;
  224.                             aux.navigate( 1, $el, $wrapper, settings, cache );
  225.                         });
  226.                        
  227.                         // adds events to the mouse
  228.                         $el.bind('mousewheel.contentcarousel', function(e, delta) {
  229.                             if(delta > 0) {
  230.                                 if( cache.isAnimating ) return false;
  231.                                 cache.isAnimating   = true;
  232.                                 aux.navigate( -1, $el, $wrapper, settings, cache );
  233.                             }  
  234.                             else {
  235.                                 if( cache.isAnimating ) return false;
  236.                                 cache.isAnimating   = true;
  237.                                 aux.navigate( 1, $el, $wrapper, settings, cache );
  238.                             }  
  239.                             return false;
  240.                         });
  241.                        
  242.                     });
  243.                 }
  244.             }
  245.         };
  246.    
  247.     $.fn.contentcarousel = function(method) {
  248.         if ( methods[method] ) {
  249.             return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
  250.         } else if ( typeof method === 'object' || ! method ) {
  251.             return methods.init.apply( this, arguments );
  252.         } else {
  253.             $.error( 'Method ' +  method + ' does not exist on jQuery.contentcarousel' );
  254.         }
  255.     };
  256.    
  257. })(jQuery);

Última edición por bbrian; 03/06/2015 a las 14:11

Etiquetas: modificar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:30.