The component you are using is miscalculating the dimensions of the image areas because they have not yet been loaded. In short, the component works asynchronously with image loading.
To resolve this, call component options only when images are loaded, using $(window).on("load"...
, in this way:
var $grid = $(".grid").isotope(); // declara a variável atribuída ao componente
$(window).on("load", function(){
if(document.getElementById("menu") || document.getElementById("gallery")){
$grid.isotope({
itemSelector: ".all",
percentPosition: true,
masonry: {
columnWidth: ".all"
}
})
};
});
You declare the variable $grid
before the $(window).on("load"...
so that it has scope outside the function, as you will need it in another part of the code, as in this click event:
$('.filters li').click(function(){
$('.filters li').removeClass('active');
$(this).addClass('active');
var data = $(this).attr('data-filter');
$grid.isotope({
filter: data
})
});
Another thing I noticed is that you have a $(document).ready(function()
{
and others within, in addition to $( function() {
. That is
code redundancy, just the $(document).ready(function() {
leading.
Cara also includes the CSS and JS of his gallery, and if possible pass the link ai of the project so we can inspect. And what is the version of Bootstrap?
– hugocsl
No, they move responsibly, this error only presents if I do not update the page, if update they go to the appropriate space
– André Macedo
https://github.com/amrodr/galeria_projector. here is the repository to check the project
– André Macedo
I located the line but did not find the error in this code, it only error when it is on the server
– André Macedo
I did that but did not allow me to use the tag menu
– André Macedo
So the code looks like this ? var $grid; $(window). on("load", Function(){ if(Document.getElementById("menu") || Document.getElementById("gallery")){ $grid = $(". grid"). Isotope({
– André Macedo
Keeps crashing the menu and I don’t know why
– André Macedo
I changed the Main.js code lines, locally all this ok, when I put on the server continues with the same error of one image overwriting the other, I will add the image in the question !
– André Macedo
By putting this Script in HTML it stops reading my KKKK file and the error in the menu again
– André Macedo
Now it worked thanks to you, the result came out as expected, I did cache and historical cleaning in the browser I stopped the site, the images appear on top of each other and after fully loading they are relocated each in its proper place, you are to congratulations, I am very grateful
– André Macedo