bigbite / macy.js

http://macyjs.com/
MIT License
1.28k stars 156 forks source link

Initializing two different instances causes one to fail. #102

Open jankeistoer opened 9 months ago

jankeistoer commented 9 months ago

Expected Behavior

I expect both instances to work properly and set correct sizes.

Actual Behavior

One of the instances works perfectly but the height of the second instance is incorrect.

Step-by-step reproduction instructions

  1. Place two different containers on a webpage.
  2. Initialize both
  3. Check the height of each container

I use the following configuration:

const macyInstance = Macy({
            container: `#${wrappedId}`,
            columns: 1,
            margin: {
                x: 32,
                y: 32,
            },
            mobileFirst: true,
            breakAt: {
                576: {
                    columns: 2,
                },
                992: {
                    columns: 3,
        },
    },
});

macyInstance.recalculate();

Screenshots, screen recordings, code snippets

If possible, please upload a screenshot or screen recording which demonstrates the bug.

This is the first instance:

image

This is the second instance:

image

jankeistoer commented 9 months ago

Problem was solved with the recalculateOnImageLoad function.