Advertisement
Igor150195

card slider

Feb 8th, 2024
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var vslider = tns({
  2.     container: '.card-slider__items-slider',
  3.     slideBy: 1,
  4.     mode: 'gallery',
  5.     axis: 'horizontal',
  6.     autoplay: false,
  7.     mouseDrag: true,
  8.     center: true,
  9.     autoWidth: false,
  10.     loop: false,
  11.     rewind: true,
  12.     preventActionWhenRunning: false,
  13.     nav: true,
  14.     lazyload: true,
  15.     swipeAngle: 50,
  16.     navPosition: 'bottom',
  17.     controlsContainer: '.card-slider-nav',
  18.     controlsText: shop2_gr.settings.sliderControls,
  19.     responsive: {
  20.         320: {
  21.             controls: false,
  22.             nav: true
  23.         },
  24.         768: {
  25.             controls: true,
  26.             nav: true,
  27.         }
  28.     }
  29. });
  30.  
  31. var small_slider = tns({
  32.     container: '.card-slider__thumbs-slider',
  33.     loop: false,
  34.     gutter: 10,
  35.     center:false,
  36.     mouseDrag: true,
  37.     nav: false,
  38.     disable: false,
  39.     controls: false,
  40.     navPosition: 'bottom',
  41.     preventActionWhenRunning: false,
  42.     axis: 'horizontal',
  43.     responsive: {
  44.         320: {
  45.             items: 3
  46.         },
  47.         640: {
  48.             items: 3
  49.         },
  50.         768: {
  51.             items: 3,
  52.             disable: stickyFlag
  53.         },
  54.         1024: {
  55.             items: 4
  56.         },
  57.         1261: {
  58.             items: 4
  59.         },
  60.         1340: {
  61.             items: 4
  62.         }
  63.     }
  64. });
  65.  
  66. var navIndex = $('.card-slider__items .tns-nav-active').index();
  67.     $('.card-slider__thumbs-slider .card-slider__thumb').removeClass('tns-nav-active');
  68.     $('.card-slider__thumbs-slider .card-slider__thumb').eq(navIndex).addClass('tns-nav-active');
  69.  
  70. vslider.events.on('indexChanged', function(){
  71.     var navIndex = $('.card-slider__items .tns-nav-active').index();
  72.     $('.card-slider__thumbs-slider .card-slider__thumb').removeClass('tns-nav-active');
  73.     $('.card-slider__thumbs-slider .card-slider__thumb').eq(navIndex).addClass('tns-nav-active');
  74.  
  75.     /*if (vslider.getInfo().index>vslider.getInfo().indexCached) {
  76.         //console.log('right')
  77.     } else {
  78.         //console.log('left')
  79.     }*/
  80. });
  81.  
  82. vslider.events.on('indexChanged', function(){
  83.     small_slider.goTo(vslider.getInfo().index);
  84. });
  85.  
  86. $(document).on('click', '.card-slider__thumbs-slider .card-slider__thumb', function(){
  87.     var thisIndex = $(this).index();
  88.     $('.card-slider__items .tns-nav button').eq(thisIndex).click();
  89. });
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement