Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matchmedia support? #1250

Closed
djmtype opened this issue Sep 12, 2022 · 1 comment
Closed

matchmedia support? #1250

djmtype opened this issue Sep 12, 2022 · 1 comment

Comments

@djmtype
Copy link

djmtype commented Sep 12, 2022

Does flickity 3 offer matchmedia support? I saw an old v2 demo using jquery on Codepen. But, what about v3 with vanilla js?

Am I doing something wrong?

const options = {
  cellAlign: 'left',
  contain: true,
  pageDots: false,
  wrapAround: false,
  groupCells: 1
};

const flkty = new Flickity( '.carousel', 
options);

const mediaQueryList = window.matchMedia('(min-width: 600px)');
if(mediaQueryList.matches) {
 options.prevNextButtons = false;
}
@desandro
Copy link
Member

You need to set prevNextButtons before initializing Flickity

const options = {
  cellAlign: 'left',
  contain: true,
  pageDots: false,
  wrapAround: false,
  groupCells: 1
};

const mediaQueryList = window.matchMedia('(min-width: 600px)');
if(mediaQueryList.matches) {
 options.prevNextButtons = false;
}

const flkty = new Flickity( '.carousel', 
options);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants