You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use Masonry on shopify x storyblok (headless CMS) and the worry I encounter that at the 1st load a certain image positions badly. Always the same place, it is not related to the image. If I resize my screen manually, the Masonry wall is perfectly repositioned.
MY JS :
`module.exports = class GalleryV2 extends Component {
onInit(el) {
this.el = el;
}
onLoad() {
if (window.matchMedia("(min-width: 768px)").matches) {
this.galleryMasonryV2();
}
}
galleryMasonryV2() {
var msnry2 = new Masonry(this.el, {
itemSelector: ".js-grid-item",
columnWidth: ".grid-sizer",
gutter: ".gutter-sizer",
percentPosition: true,
initLayout: false,
});
The text was updated successfully, but these errors were encountered:
anthony-roux
changed the title
Certaines briques (une) de mon masonry se positionne mal au load
Some bricks (one) of my masonry are not well positioned at the load
Nov 23, 2022
Hello,
I use Masonry on shopify x storyblok (headless CMS) and the worry I encounter that at the 1st load a certain image positions badly. Always the same place, it is not related to the image. If I resize my screen manually, the Masonry wall is perfectly repositioned.
MY JS :
`module.exports = class GalleryV2 extends Component {
onInit(el) {
this.el = el;
}
onLoad() {
if (window.matchMedia("(min-width: 768px)").matches) {
this.galleryMasonryV2();
}
}
galleryMasonryV2() {
var msnry2 = new Masonry(this.el, {
itemSelector: ".js-grid-item",
columnWidth: ".grid-sizer",
gutter: ".gutter-sizer",
percentPosition: true,
initLayout: false,
});
}
};
`
MY HTML/LIQUID
`
{% for item in item.images %}
{% capture element %}{% cycle 'odd', 'even' %}{% endcapture %}
{% assign imgSize = item.img_size | default: 'portrait' %}
MY SCSS :
`.c-gallery {
margin-bottom: -10px;
margin-right: -10px;
@include mq($until:tablet){
margin-bottom: 0;
margin-right: 0;
}
@include mq($from:mobile){
height: 0;
overflow: hidden;
opacity: 0;
}
&.masonry-is-complete {
@include mq($from:mobile){
opacity: 1;
}
}
&:after {
content: '';
display: block;
clear: both;
}
.grid-sizer,
.js-grid-item {
width: calc(25% - 10px);
}
.gutter-sizer {
width: 10px;
}
.js-grid-item--width2 {
width: calc(75% - 10px);
}
&__item {
margin-bottom: 10px;
float: left;
}
.c-gallery__item + .c-gallery__item {
@include mq($until:mobile){
margin-top: 20px;
}
}
&__legend {
opacity: 0;
}
}
.c-gallery--v2 {
.grid-sizer,
.js-grid-item {
width: calc(33.33% - 10px);
}
}`
Thanks for your help !
The text was updated successfully, but these errors were encountered: