Skip to content

Allow to pass width / height size data of each item, use (trust) them as calculating the layout. #180

@softmarshmallow

Description

@softmarshmallow

I am building pinterest-like app just like others (https://grida.co/library), for my case, all the image are indexed with width/height, width/height data is available at the render time, which the masonry component don't have to rely on observer (unless window resize), the calculation / layout shift can be optimized based on this.

do you have plans for <items={}/> with width / height property? (and use that?)

e.g.
[{id: 1, width: 100, height: 200}] internally, the component will calculate width per item, then calculate item's height by

const aspect_ratio = input.width / input.height;
const height = width / aspect_ratio;

and pass the height value as well, and intenally use this to calculate (abs pos) the item.
also great for virtualization, without causing any layout shifting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions