0.0.7 • Published 2 years ago

@edde746/svelte-masonry v0.0.7

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

svelte-masonry

A lightweight and dependency-free Masonry component for Svelte, based on the article by Ana Tudor (@anatudor) on CSS Tricks.

Originally coded by janzheng and updated by edde746.

Installation

npm install @edde746/svelte-masonry

Usage

import Masonry from "@edde746/svelte-masonry";
<Masonry update={itemCount} stretchFirst>
  {#each data.slice(0, itemCount) as o}
    <div class="card">
      <header>
        <h3>{o.name}</h3>
      </header>
      <section>
        <p>{o.text}</p>
      </section>
    </div>
  {/each}
</Masonry>

Note: Make sure to update the itemCount variable whenever you want to update the layout.

Props

PropTypeDefaultDescription
stretchFirstboolfalseWhether the first item should stretch across all grid columns.
gridGapstring"0.5em"The gap between grid items.
colWidthstring"minmax(min(20em, 100%), 1fr)"The width of the grid columns.
updateanyA variable to trigger layout updates.
rearrangeboolfalseWhether to rearrange the grid items to best fill vertical space.

Functions

refreshLayout()

Use this function to manually trigger a layout refresh. This might be useful in cases when the content of the grid items changes.

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago