K
K
Kostya2016-02-04 14:20:34
JavaScript
Kostya, 2016-02-04 14:20:34

What needs to be added in the script so that its parameters change depending on the screen size?

Faced the following problem using the bxSlider plugin. It is necessary to add a condition in the plugin call code that changes the number of slides in the carousel to 1 for mobile devices.

Right now I have the following plugin setup

$(document).ready(function(){
  $('.slider').bxSlider({
    slideWidth: 400,
    minSlides: 2 
  });
});

The bottom line is that with such a plugin call, I have a 2-slide carousel, which needs to be fixed for mobile devices.
31c66535e3ee4bb9877ec0a19388fc81.jpg

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2016-02-04
@baskserg

Does it fit?

$(document).ready(function(){
  $('.slider').bxSlider({
      slideWidth: 400,
      maxSlides: 2,
      minSlides: 1
    });
});

G
Gregory, 2016-02-04
@TMGLUK

Media queries can be applied directly in js

var mobile = window.matchMedia( "(max-width: 768px)" );
if (mobile.matches) {
 // если маленький экран
 $('.slider').bxSlider({
      ...
  });
} else {
 // иначе
 $('.slider').bxSlider({
    ...
  });
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question