Skip to content

Commit

Permalink
Merge pull request #86 from BKWLD/watch-peek-value-changes
Browse files Browse the repository at this point in the history
Watch peek value changes
  • Loading branch information
weotch authored Aug 31, 2022
2 parents c8abcc9 + 62f31be commit b38a12a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
27 changes: 24 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,24 @@ gutter space.
};
}
},
watch: {
// Recapture peeking values if the source props change
peekLeft: function () {
return this.capturePeekingMeasurements();
},
peekRight: function () {
return this.capturePeekingMeasurements();
},
peek: function () {
return this.capturePeekingMeasurements();
},
peekGutter: function () {
return this.capturePeekingMeasurements();
},
responsive: function () {
return this.capturePeekingMeasurements(); // Easier to respond to all
}
},
methods: {
// Capture measurements of peeking values
capturePeekingMeasurements: function () {
Expand Down Expand Up @@ -1894,7 +1912,10 @@ Code related to changing the slides per page at different viewport widths
return this.responsive.map(breakpoint => {
return { ...breakpoint,
mediaQuery: this.makeMediaQuery(breakpoint),
active: this.isBreakpointActive(breakpoint)
active: this.isBreakpointActive(breakpoint),
// Unpack shorthands
peekLeft: breakpoint.peekLeft || breakpoint.peek || (breakpoint.peekGutter ? breakpoint.gutter : void 0),
peekRight: breakpoint.peekRight || breakpoint.peek || (breakpoint.peekGutter ? breakpoint.gutter : void 0)
};
});
},
Expand All @@ -1918,8 +1939,8 @@ Code related to changing the slides per page at different viewport widths
return {
slidesPerPage: this.slidesPerPage,
gutter: this.gutter,
peekLeft: this.peekLeft,
peekRight: this.peekRight,
peekLeft: this.peekLeft || this.peek || (this.peekGutter ? this.gutter : void 0),
peekRight: this.peekRight || this.peek || (this.peekGutter ? this.gutter : void 0),
feather: this.feather
};
}
Expand Down
9 changes: 9 additions & 0 deletions src/concerns/peeking.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ export default
left: @autoUnit @getResponsiveValue 'peekLeft', breakpoint
right: @autoUnit @getResponsiveValue 'peekRight', breakpoint

watch:

# Recapture peeking values if the source props change
peekLeft: -> @capturePeekingMeasurements()
peekRight: -> @capturePeekingMeasurements()
peek: -> @capturePeekingMeasurements()
peekGutter: -> @capturePeekingMeasurements()
responsive: -> @capturePeekingMeasurements() # Easier to respond to all

methods:

# Capture measurements of peeking values
Expand Down
12 changes: 10 additions & 2 deletions src/concerns/responsive.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ export default
...breakpoint
mediaQuery: @makeMediaQuery breakpoint
active: @isBreakpointActive breakpoint

# Unpack shorthands
peekLeft: breakpoint.peekLeft ||
breakpoint.peek ||
(breakpoint.gutter if breakpoint.peekGutter)
peekRight: breakpoint.peekRight ||
breakpoint.peek ||
(breakpoint.gutter if breakpoint.peekGutter)
}

# Get current responsive values
Expand All @@ -41,8 +49,8 @@ export default
else { # Defaults
@slidesPerPage
@gutter
@peekLeft
@peekRight
peekLeft: @peekLeft || @peek || (@gutter if @peekGutter)
peekRight: @peekRight || @peek || (@gutter if @peekGutter)
@feather
}

Expand Down

0 comments on commit b38a12a

Please sign in to comment.