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

responsive settings ignored #24

Closed
vinkodlak opened this issue Jun 3, 2020 · 1 comment
Closed

responsive settings ignored #24

vinkodlak opened this issue Jun 3, 2020 · 1 comment

Comments

@vinkodlak
Copy link
Contributor

I have this codesandbox
with a simple configuration:

<Glider
  slidesToShow={1.3}
  responsive={[
    {
      breakpoint: 700,
      settings: {
        slidesToShow: 3
      }
    },
    {
      breakpoint: 950,
      settings: {
        slidesToShow: 5
      }
    }
  ]}
>
...
</Glider>

It should show 1.3 slides below 700px, then 3 slides up until 950, and after 5.
It works strange. When you load page at > 950 px, shows 1.3 slides on that breakpoint. Others are ok.
When you load at > 700 that one is broken, bigger is ok.
<500 all are ok. Seems like if it loads non-mobile, responsive breakpoint first it copies default opts to it...

This is what object looks like after init on > 950:
image

I looked a bit through your code and glider-js docs, I think the problem is in

    // When the props update, update the glider
    React.useEffect(() => {
      if (!gliderRef.current) {
        return;
      }

      gliderRef.current.setOption(makeGliderOptions());
      gliderRef.current.refresh(true);
    }, [props]);

setOption(), and that it needs to take 2nd argument as true, to make options global.
Can you check it?

@hipstersmoothie
Copy link
Collaborator

Yup seems like that should be a true. Can you make a PR?

vinkodlak added a commit to vinkodlak/react-glider that referenced this issue Jun 4, 2020
hipstersmoothie added a commit that referenced this issue Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants