Skip to content

Commit

Permalink
VA-548 fix column spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
devland committed Feb 17, 2025
1 parent b90d09e commit 378407a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/scripts/h5p-multi-media-choice-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export default class MultiMediaChoiceContent {
// Use masonry library
this.masonry = new Masonry(this.optionList, {
gutter: columnGap,
itemSelector: '.h5p-multi-media-choice-list-item'
itemSelector: '.h5p-multi-media-choice-list-item',
horizontalOrder: true
});

// Toggle selected
Expand Down Expand Up @@ -387,10 +388,10 @@ export default class MultiMediaChoiceContent {
const columns = Math.ceil(
Math.min(columnSpaceCount, this.maxAlternativesPerRow, this.options.length)
);
const elementWidth = (this.optionList.getBoundingClientRect().width / columns) - (columns > 1 ? columnGap : 0);
const elementWidth = (this.optionList.getBoundingClientRect().width / columns) - columnGap;

for (let x = 0; x < this.options.length; x++) {
this.resizeGridItem(this.options[x].getDOM(), elementWidth);
this.resizeGridItem(this.options[x].getDOM(), elementWidth + ((x + 1) % columns === 0 ? columnGap : 0));
}

// Set layout again after resizing
Expand Down

0 comments on commit 378407a

Please sign in to comment.