$(function(){ $("img.lazy").lazyload({ effect: 'fadeIn', effectspeed: 500 }); $('.slides-wrap').each(function(){ var $container = $(this).find('.slides'), $item = $container.find('span'), $indicator = $(this).find('.indicator'), indicatorHTML = '', slideCount = $item.length, currentIndex = 0, duration = 0, easing = 'linear', interval = 7000, timer = null; $item.each(function (i){ var src = $(this).find('img').attr('src'); indicatorHTML += '
'; }); $indicator.html(indicatorHTML); function mainGoToSlide (idx){ $item.removeClass('show'); $item.stop(true).animate({'opacity':0}, duration); $item.eq(idx).addClass('show'); $('.show').stop(true).animate({'opacity':1}, duration); currentIndex = idx; updateNav(); } function updateNav (){ $indicator.find('div').removeClass('active').eq(currentIndex).addClass('active'); } function mainStartTimer (){ timer = setInterval(function (){ var nextIndex = (currentIndex + 1) %slideCount; mainGoToSlide(nextIndex); }, interval); } $indicator.find('div').on('click touchstart', function (){ if(!$(this).hasClass('active')){ mainGoToSlide($(this).index()); } }); mainGoToSlide(currentIndex); mainStartTimer(); }); $plan = $('.plan'); $('a.pagelink').on('click', function(){ var w = $(window).width(); if(w < 600){ position = $('#plan-idx').offset().top; $('body,html').animate({scrollTop:position}, 1000, 'easeOutExpo'); // return false; var idx = $(this).index('.pagelink'); $plan.removeClass('show'); $plan.eq(idx).addClass('show').css({'opacity': 0}).stop(true).animate({'opacity': 1}, 2000, 'swing'); }else{ var href= $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); if (target.offset()) { var position = target.offset().top; $('body,html').animate({scrollTop:position}, 1000, 'easeOutExpo'); return false; } } }); $plansNav = $('.plans-nav'), $planLi = $plansNav.find('li'); $planLi.on('click', function(){ if( $(window).width() < 800){ position = $('#plan-idx').offset().top; $('body,html').animate({scrollTop:position}, 1000, 'easeOutExpo'); } var idx = $(this).index(); $planLi.removeClass('on'); $(this).addClass('on'); $plan.removeClass('show'); $plan.eq(idx).addClass('show').css({'opacity': 0}).stop(true).animate({'opacity': 1}, 2000, 'swing'); }); $pagetop = $('#pagetop'); $pagetop.on('click', function(){ $('body, html').animate({ scrollTop: 0 }, 1000, 'easeOutExpo'); return false; }); $(window).on('scroll', function(){ if($(window).scrollTop() > 200){ $pagetop.fadeIn(); }else{ $pagetop.fadeOut(); } }); $(window).trigger('scroll'); $(window).on('load', function(){ }); });