Guest User

Untitled

a guest
Apr 28th, 2016
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function () {
  2.    
  3.     $('.slideshow').each(function () {
  4.        
  5.     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6.        
  7.         var $container = $(this),  
  8.             $slideGroup = $container.find('.slideshow-slides'),
  9.             $slides = $slideGroup.find('.slide'),  
  10.             $nav = $container.find('.slideshow-nav'),          
  11.             $indicator = $container.find('.slideshow-indicator'),
  12.             slideCount = $slides.length,
  13.        
  14.             viewCount = $(".view").length;         
  15.                
  16.             currentIndex = 0,            
  17.             duration = 500,              
  18.             easing = 'easeInOutExpo';
  19.  
  20.      console.log($(".view").length);   
  21.      
  22.     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  23.  
  24.      
  25.         $slides.each(function (i) {
  26.             $(this).css({ left: 200 * i + 'px' });          
  27.         });*/
  28.  
  29.     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  30.  
  31.         // 用以顯示任意Slide的函數
  32.         function goToSlide (index) {                   
  33.             $slides.animate({ left: - 480 * index + 'px' }, duration, easing);          
  34.             currentIndex = index;          
  35.             updateNav();           
  36.         }
  37.        
  38.         function updateNav () {
  39.             var $navPrev = $nav.find('.prev'),
  40.                 $navNext = $nav.find('.next');            
  41.             if (currentIndex === 0) {
  42.                 $navPrev.addClass('disabled');
  43.             } else {
  44.                 $navPrev.removeClass('disabled');
  45.             }
  46.            
  47.             if (currentIndex === 1    ) {
  48.                 $navNext.addClass('disabled');
  49.             } else {
  50.                 $navNext.removeClass('disabled');
  51.             }
  52.     console.log(currentIndex);
  53.         }  
  54.  
  55.     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  56.  
  57.         $nav.on('click', 'a', function (event) {
  58.             event.preventDefault();
  59.             if ($(this).hasClass('prev')) {
  60.                 goToSlide(currentIndex - 1);
  61.             } else {
  62.                 goToSlide(currentIndex + 1);
  63.             }
  64.         });
  65.  
  66.     //-----------------------------------------------------------------
  67.         goToSlide(currentIndex);
  68.  
  69.    
  70.     });
  71.  
  72.  
  73. });
Advertisement
Add Comment
Please, Sign In to add comment