Glide: Using .update() with breakpoints breaks options

Created on 27 Sep 2019  路  2Comments  路  Source: glidejs/glide

Same issue as #244, but I am experiencing this using version 3.4.1.

Settings:

{
  perView: 3,
  breakpoints: {
    900: {
      perView: 2,
    },
  },
},

Calling update whenever intersection observer changes (this.instance refers to glide):

this.instance.update({
  keyboard: entries[0].isIntersecting,
})

When this gets called, perView no longer gets updated when changing screen resolution.

Most helpful comment

The issue is this line https://github.com/glidejs/glide/blob/master/src/components/breakpoints.js#L88

The Breakpoints extension pulls in the settings object reference once and works with that on resize. So the resize listener just overwrites everything with the initial values.

this:
Glide.settings = mergeOptions(settings, Breakpoints.match(points))
has to be changed to:
Glide.settings = mergeOptions(Glide.settings, Breakpoints.match(points))

or pull in the new reference in Events.on('update', () => { ... but better would be to just always access Glide.settings directly.

I'd open a PR, but my last bugfix PR (https://github.com/glidejs/glide/pull/379) is in limbo for 4 months, so I'm not sure about that.

All 2 comments

Side note:
I have also tried calling update with the original settings without luck:

this.instance.update({
  ...this.options,
  keyboard: entries[0].isIntersecting,
})

The issue is this line https://github.com/glidejs/glide/blob/master/src/components/breakpoints.js#L88

The Breakpoints extension pulls in the settings object reference once and works with that on resize. So the resize listener just overwrites everything with the initial values.

this:
Glide.settings = mergeOptions(settings, Breakpoints.match(points))
has to be changed to:
Glide.settings = mergeOptions(Glide.settings, Breakpoints.match(points))

or pull in the new reference in Events.on('update', () => { ... but better would be to just always access Glide.settings directly.

I'd open a PR, but my last bugfix PR (https://github.com/glidejs/glide/pull/379) is in limbo for 4 months, so I'm not sure about that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rhysstubbs picture rhysstubbs  路  5Comments

adambartosiewicz picture adambartosiewicz  路  3Comments

dodozhang21 picture dodozhang21  路  5Comments

rkanson picture rkanson  路  5Comments

sehsarah picture sehsarah  路  5Comments