diff --git a/README.md b/README.md index 4b8af0c..4bbae24 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Flickity responsive v1.1.0 [![](https://data.jsdelivr.com/v1/package/gh/phucbm/flickity-responsive/badge)](https://www.jsdelivr.com/package/gh/phucbm/flickity-responsive) +# Flickity responsive v1.1.1 [![](https://data.jsdelivr.com/v1/package/gh/phucbm/flickity-responsive/badge)](https://www.jsdelivr.com/package/gh/phucbm/flickity-responsive) A jQuery plugin that adds `responsive` option for Flickity. @@ -74,6 +74,10 @@ carousel. ## Changelog +### v1.1.1 - 2021-09-27 + +- Fix bug when `responsive` property is not defined. + ### v1.1.0 - 2021-09-24 - The core responsive handle has been split into `class ResponsiveObject()` so we can use this feature for other diff --git a/flickity-responsive.js b/flickity-responsive.js index 667ceff..105f802 100644 --- a/flickity-responsive.js +++ b/flickity-responsive.js @@ -1,5 +1,5 @@ /*! - * Flickity responsive v1.1.0 + * Flickity responsive v1.1.1 * https://github.com/phucbm/flickity-responsive */ @@ -31,13 +31,13 @@ /*! - * Responsive Object v1.0.0 + * Responsive Object v1.0.1 * https://github.com/phucbm/js-gist/blob/main/responsive-object.js */ class ResponsiveObject{ constructor(config){ this.object = config.object || undefined; - if(!this.object || !this.object.responsive) return false; + if(!this.object) return; // callbacks this.onMatched = config.onMatched || function(){ @@ -45,6 +45,23 @@ class ResponsiveObject{ this.onUpdate = config.onUpdate || function(){ }; + // exit if there is no responsive object + if(!this.object.responsive){ + // update + this.currentObject = { + type: 'no-responsive', + lastBreakpoint: undefined, + breakpoint: -1, + object: this.mergeObject(-1, this.object) + }; + + // callback onMatched + if(typeof this.onMatched === 'function'){ + this.onMatched(this.currentObject); + } + return false; + } + // if the current object don't have this key, search from the closest breakpoint above this.isInherit = typeof config.isInherit === 'undefined' ? true : config.isInherit; diff --git a/test/index.html b/test/index.html index 96cc2c2..888309b 100644 --- a/test/index.html +++ b/test/index.html @@ -3,7 +3,7 @@ - Flickity responsive v1.1.0 + Flickity responsive v1.1.1