Skip to content

Commit

Permalink
Clearing gutter on last side when disabled with negative margin on track
Browse files Browse the repository at this point in the history
  • Loading branch information
weotch committed Sep 19, 2022
1 parent 16ebc90 commit cb2755e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/concerns/gutters.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ export default
makeBreakpointSlideGutterStyle: (breakpoint) ->
gutter = @getResponsiveValue 'gutter', breakpoint

# If carousel would be disabled for not having enough slides, then remove
# gutter from last slide.
notLastSlide = if @isDisabledAtBreakpoint breakpoint
then ':not(:last-child)' else ''
# If carousel would be disabled for not having enough slides, then
# effectively remove the gutter from the last slide. Using a negative
# margin on the track so that we don't increase the specifity on the
# slide style, like would be the case if adding :not(:last-child) to the
# slide.
clearGutter = """
#{@scopeSelector} .ssr-carousel-track {
margin-right: calc(#{@autoUnit(gutter)} * -1);
}
""" if @isDisabledAtBreakpoint breakpoint

# Render styles
"""
#{@scopeSelector} .ssr-carousel-slide#{notLastSlide} {
#{@scopeSelector} .ssr-carousel-slide {
margin-right: #{@autoUnit(gutter)};
}
"""

0 comments on commit cb2755e

Please sign in to comment.