app-new.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // var thumbsSwiper = new Swiper('#thumbsSwiper', {
  2. // autoplay: false,
  3. // slidesPerView: 6,
  4. // // mousewheel:false,
  5. // watchSlidesVisibility: true,//防止不可点击
  6. // slideToClickedSlide: true,
  7. // watchSlidesProgress : true,
  8. // on:{
  9. // slideChange: function(){
  10. // // 切换回来的index
  11. // console.log(this.realIndex);
  12. // },
  13. // },
  14. // });
  15. var swiper = new Swiper('#swiperContainer', {
  16. direction: 'vertical',
  17. autoHeight: true,
  18. speed: 600,
  19. autoplay: false,
  20. slidesPerView : 5,
  21. slidesPerGroup : 1,
  22. spaceBetween: 0,
  23. centeredSlides: true,
  24. centeredSlidesBounds : true,
  25. breakpoints: {
  26. 1000: { //当屏幕宽度小于等于1280
  27. slidesPerView: 5,
  28. spaceBetween: 0
  29. },
  30. },
  31. loop: true,
  32. // thumbs: {
  33. // swiper: thumbsSwiper,
  34. // },
  35. on:{
  36. slideChange: function(){
  37. // 切换的index = this.realIndex
  38. $('#swiper-nav-div .item-nav').removeClass('item-nav-active');
  39. $('#swiper-nav-div .item-nav').eq(this.realIndex).addClass('item-nav-active')
  40. },
  41. },
  42. });
  43. init();
  44. $('#swiper-nav-div').on('click','.item-nav',function(){
  45. var index = $(this).index();
  46. if($('body').width() >= 769){
  47. swiper.slideToLoop(index, 300, false);
  48. }else{
  49. $('#swiper-nav-div .item-nav').removeClass('item-nav-active');
  50. $('#swiper-nav-div .item-nav').eq(index).addClass('item-nav-active');
  51. $('.swiper-content-div.mobile .img').removeClass('active-img');
  52. $('.swiper-content-div.mobile .img').eq(index).addClass('active-img')
  53. }
  54. });
  55. function init(){
  56. if($('body').width() < 769){
  57. $('#swiper-nav-div .item-nav').removeClass('item-nav-active');
  58. $('#swiper-nav-div .item-nav').eq(0).addClass('item-nav-active');
  59. }
  60. }
  61. $(window).resize(function(){
  62. init();
  63. });