I'm using Susy's gallery tool to display elements in a grid format. Angular is hiding or showing those grid elements on the fly, depending on user selections. When Angular hides an element in the grid, it attaches a class of ng-hide to it. This in turn sets its CSS to display:none !important.
The issue is that Susy is calculating the position of each element and not taking into account the items set to display:none - it is leaving gaps in the grid when those elements are hidden.
Is it possible to get Susy to ignore the hidden elements when laying them out?
I've tried using :not() CSS selector, without success - there's still gaps in the layout:
.results__result:not(.ng-hide) {
@include gallery(3 of 12);
}
Sass doesn't know anything about the DOM, so Susy doesn't either. To create the gallery layout, susy has to rely on
nth-childselectors — which don't work well for the use-case you are talking about. Start simple:If you are using
split,inside, orinside-staticgutters — that should just work. Otherwise you need some way to target thelastelement in each row of the grid. CSS doesn't have a way to target nth-visible, so this would require added logic in your markup/js. Given alastclass every 4th visible result, you can add: