Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Items stack on top of each other on the initial load until I resize #50

Open
motdde opened this issue Mar 25, 2021 · 3 comments
Open

Items stack on top of each other on the initial load until I resize #50

motdde opened this issue Mar 25, 2021 · 3 comments
Labels
bug Something isn't working question Further information is requested

Comments

@motdde
Copy link

motdde commented Mar 25, 2021

Items stack on top of each other on the initial load until I resize

Screenshot 2021-03-25 at 12 01 53

@e-oj
Copy link
Owner

e-oj commented Jan 11, 2022

You need to set place the image in a div whose height is equal to the height of the image. That way, the grid item will always be the correct height even if the image loads slowly.

@e-oj e-oj added the question Further information is requested label Jan 11, 2022
@guillermohs9
Copy link

Sorry for necrobumping, I'm using the library for a dynamic number of images, but I'm facing the same issue as OP, even after setting the height of the div the same as the image it contains.

<div id="container-imagenes">
    {% for i in inmueble.imagenes_inmueble %}
        <div style="height:{{ i.thumb_height() }}px;">
            <a href="{{ url_for('static', filename='uploads/' + i.filename) }}"><img src="{{ url_for('static', filename='uploads/' + i.thumbnail) }}"></a>
        </div>
    {% endfor %}
</div>

thumb_height() is a method that returns the image height in px from the backend

I'm initializing the grid like this:

let magicGrid = new MagicGrid({
    container: "#container-imagenes", // Required. Can be a class, id, or an HTMLElement.
    items: {{ inmueble.imagenes_inmueble | length }},
    animate: true // Optional.
});
    
magicGrid.listen();

but images appear stacked until I resize the window and the grid starts working. Am I missing something?
Thx

@e-oj
Copy link
Owner

e-oj commented Jun 7, 2024

This needs more investigation

@e-oj e-oj added the bug Something isn't working label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants