2.0.9 • Published 11 months ago

react-justified-layout-ts v2.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

A TypeScript component similar to Flickr's justified layout.

Usage

Add the TSJustifiedLayout component to your code with the following props:

  • layoutItems: number[]; - An array of aspect ratios for the images you are adding to the grid
  • itemSpacing?: number; - The amount of spacing between each image, in pixels. (Default: 10)
  • rowSpacing?: number; - The amount of spacing between each row, in pixels. (Default: 10)
  • targetRowHeight?: number; - The target row height for a row, in pixels. (Default: 320)
  • targetRowHeightTolerance?: number; - The amount the row height could deviate from the target row height, as a percent. (Default: .25)
  • width: number; - The width of the container. I would use something like react-use-measure if you're trying to make it dynamically take up the size of the parent container.
  • children: any[]; - The children elements that makes up the grid.
  • showWidows?: boolean; - If the last row should be shown. (Default: true)

Example Usage

<TSJustifiedLayout width={width}
    layoutItems={imagesOnPage.map(value => ({
       dimensions: value.aspectRatio || 1
    }))}>
        {imagesOnPage.map(value => <img
            src={value.src}
            alt={value.alt}
        />)}
</TSJustifiedLayout>

Install

npm i react-justified-layout-ts

Credits

The display logic for the layout and the math used to calculate the row height for each row is adapted from Flickr's Justified Layout library.

License

Open Source Licensed under the MIT license.

1.1.1

1 year ago

1.1.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.9

11 months ago

2.0.8

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

2.0.1

1 year ago

1.1.14

1 year ago

2.0.0

1 year ago

1.1.13

1 year ago

1.1.17

1 year ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago