Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function () {
- $('.slideshow').each(function () {
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- var $container = $(this),
- $slideGroup = $container.find('.slideshow-slides'),
- $slides = $slideGroup.find('.slide'),
- $nav = $container.find('.slideshow-nav'),
- $indicator = $container.find('.slideshow-indicator'),
- slideCount = $slides.length,
- viewCount = $(".view").length;
- currentIndex = 0,
- duration = 500,
- easing = 'easeInOutExpo';
- console.log($(".view").length);
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- $slides.each(function (i) {
- $(this).css({ left: 200 * i + 'px' });
- });*/
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // 用以顯示任意Slide的函數
- function goToSlide (index) {
- $slides.animate({ left: - 480 * index + 'px' }, duration, easing);
- currentIndex = index;
- updateNav();
- }
- function updateNav () {
- var $navPrev = $nav.find('.prev'),
- $navNext = $nav.find('.next');
- if (currentIndex === 0) {
- $navPrev.addClass('disabled');
- } else {
- $navPrev.removeClass('disabled');
- }
- if (currentIndex === 1 ) {
- $navNext.addClass('disabled');
- } else {
- $navNext.removeClass('disabled');
- }
- console.log(currentIndex);
- }
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- $nav.on('click', 'a', function (event) {
- event.preventDefault();
- if ($(this).hasClass('prev')) {
- goToSlide(currentIndex - 1);
- } else {
- goToSlide(currentIndex + 1);
- }
- });
- //-----------------------------------------------------------------
- goToSlide(currentIndex);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment