Skip to content

Commit

Permalink
🚑 v1.1.1 Fix bug when responsive property is not defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
phucbm committed Sep 27, 2021
1 parent e40f322 commit 0a42634
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
Expand Down
23 changes: 20 additions & 3 deletions flickity-responsive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Flickity responsive v1.1.0
* Flickity responsive v1.1.1
* https://github.com/phucbm/flickity-responsive
*/

Expand Down Expand Up @@ -31,20 +31,37 @@


/*!
* 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(){
};
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;

Expand Down
2 changes: 1 addition & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flickity responsive v1.1.0</title>
<title>Flickity responsive v1.1.1</title>

<!-- CSS -->
<link rel="stylesheet" href="flickity.min.css">
Expand Down

0 comments on commit 0a42634

Please sign in to comment.