You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.9 KiB
JavaScript

5 years ago
$(function(){
/*轮播banner*/
var mySwiper_banner = new Swiper('.swiper-container-banner', {
autoplay: true,
loop: true,
pagination: {
el: '.swiper-container-banner .swiper-pagination',
clickable :true,
},
});
/*热门游戏*/
var mySwiper_hotGame = new Swiper('.swiper-container-hotGame', {
slidesPerView: 3.3,
spaceBetween: 10,
freeMode: true,
on: {
imagesReady: function(){
var h = $(this.slides[0]).height();
var i = this.slides.length-1;
this.slides.eq(i).css({height:h+'px'});
},
},
});
/*调整最后一个swiper高度*/
$(window).resize(function(){
var h = $(mySwiper_hotGame.slides[0]).height();
var i = mySwiper_hotGame.slides.length-1;
mySwiper_hotGame.slides.eq(i).css({height:h+'px'});
});
/*游戏头条*/
var mySwiper_news = new Swiper('.swiper-container-news', {
loop: true,
autoHeight: true,
on: {
slideChange: function(){
$('.swiper-container-news .swiper-tab-box li').removeClass('on').eq(this.realIndex).addClass('on');
}
},
});
$('.swiper-container-news .swiper-tab-box li').on('click',function(){
var index = $(this).index();
mySwiper_news.slideToLoop(index, 500, false);
});
/*排行榜*/
var mySwiper_rank = new Swiper('.swiper-container-rank', {
loop: true,
autoHeight: true,
initialSlide :1,
on: {
slideChange: function(){
$('.swiper-container-rank .swiper-tab-box li').removeClass('on').eq(this.realIndex).addClass('on');
}
},
});
$('.swiper-container-rank .swiper-tab-box li').on('click',function(){
var index = $(this).index();
mySwiper_rank.slideToLoop(index, 500, false);
});
});