JustifiedGallery break on reboot

I am using justifiedGallery for my webpage. When I first visited the page, the gallery displayed correctly. But when I reload the page, it will break.

enter image description here

I use a meteorite and react.

Example of old code:

$(document).ready(() => {
  $('#gallery').justifiedGallery({
    rowHeight: 400,
    fixedHeight: false,
    lastRow:   'justify',
    margins:   -3,
  });
});

I put it in jQuery setTimeOut () function.

setTimeout(function(){
  $('#gallery').justifiedGallery({
    rowHeight: 400,
    fixedHeight: false,
    lastRow: 'justify',
    margins: -3,
  });
}, 100);

Now it works fine. I just need to know what is the correct way to fix it? This is for future proof.

+4
source share
1 answer

, DOM . , , - . , , , .

Template.onRendered() this.$('.gallery') $('#gallery'). React, - componentDidMount , div .gallery.


: , . , .

0

All Articles