GithubHelp home page GithubHelp logo

bariyard / react-masonry Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bogdanpetru/react-masonry

0.0 2.0 0.0 4.2 MB

React layout library inspired by Masonry.

Home Page: https://bogdanpetru.github.io/react-masonry/

HTML 5.77% CSS 2.61% JavaScript 91.62%

react-masonry's Introduction

react masonry

ReactJs layout library inspired by Masonry.

It places elements in optimal positions by stacking them from left to right and from top to bottom.

See Demo.

This component is in development, any help is welcome :).

Usage

Place any elements inside the Masonry component. They will be cloned, measured and positioned.

Elements rendered inside Masonry must be DOM elements.

import Mansonry, { Brick } from 'react-masonry'

return <Masonry>
  <img src="helloWolrd.jpg" />
  <div className="box">some text</div>
  <img src="foo.png" />
</Masonry>

Install

Clone project.

run yarn install or npm install

run yarn start or npm start - will open in browser the demo (localhost:3000).

Api:

  • gutter: number|{top, left, right, bottom} - default: 0

Space around stones. Specify a number for all 4 directions or specify for desired directions with an object.

  • transition: fade|fadeMove|false - fade - if different than false, each item will appear one after another with an interval of transitionStep in between.

Whether place stones one after another using an animation.

  • transitionStep: number - 50 - in ms, time in between each stone placement, this is relevant if transition prop is not false.

  • transitionDuration: number - 300

Transition duration in ms.

Speed with which stones are placed when enterOneAfterAnother=true

  • updateOnWindowResize: bool - true

Whether to calculate again positions when Windows changes size.

  • Customize specific stones in different way

These props can be also added on div element like so:

data-masonry-settings={{ gutter: 20, offset: { bottom: 20 } }}

TODO

  • simplify and remove img logic
  • add tests for covered cases validate stones
  • fix edge case where an item is bigger than the container
  • add prettier
  • update stone positions on props change that influence positioning

react-masonry's People

Contributors

bogdanpetru avatar bpintican8x8 avatar ovidiuch avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.