A React.js component for using @desandro's Masonry
Installations
npm install react-masonry-component
Score
85.2
Supply Chain
99
Quality
79.2
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Developer
eiriklv
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
14.15.0
NPM Version
6.14.8
Statistics
1,444 Stars
199 Commits
145 Forks
23 Watching
13 Branches
28 Contributors
Updated on 13 Nov 2024
Bundle Size
77.26 kB
Minified
23.00 kB
Minified + Gzipped
Languages
JavaScript (93.76%)
CSS (6.24%)
Total Downloads
Cumulative downloads
Total Downloads
16,196,137
Last day
-20.1%
9,849
Compared to previous day
Last week
-3.8%
56,788
Compared to previous week
Last month
-2.3%
261,501
Compared to previous month
Last year
6.2%
3,813,781
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
React Masonry Component
IE8 support
if you wish to have IE8 support, v2 with React 0.14 is the highest version available.
Table of contents
Introduction:
A React.js Masonry component. (Also available as a mixin if needed)
Live demo:
Usage:
-
The component is bundled with Masonry, so no additional dependencies needed!
-
You can optionally include Masonry as a script tag if there should be any reason for doing so
<script src='//cdnjs.cloudflare.com/ajax/libs/masonry/3.1.5/masonry.pkgd.min.js' />
-
To use the component just require the module.
Basic usage
npm install --save react-masonry-component
1import * as React from 'react'; 2import Masonry from 'react-masonry-component'; 3 4const masonryOptions = { 5 transitionDuration: 0 6}; 7 8const imagesLoadedOptions = { background: '.my-bg-image-el' } 9 10class Gallery extends React.Component { 11 render() { 12 const childElements = this.props.elements.map(function(element){ 13 return ( 14 <li className="image-element-class"> 15 <img src={element.src} /> 16 </li> 17 ); 18 }); 19 20 return ( 21 <Masonry 22 className={'my-gallery-class'} // default '' 23 elementType={'ul'} // default 'div' 24 options={masonryOptions} // default {} 25 disableImagesLoaded={false} // default false 26 updateOnEachImageLoad={false} // default false and works only if disableImagesLoaded is false 27 imagesLoadedOptions={imagesLoadedOptions} // default {} 28 > 29 {childElements} 30 </Masonry> 31 ); 32 } 33} 34 35export default Gallery;
ES6-style modules are also supported, just use:
1import Masonry from 'react-masonry-component';
Custom props
You can also include your own custom props - EG: inline-style and event handlers.
1import * as React from 'react'; 2import Masonry from 'react-masonry-component'; 3 4const masonryOptions = { 5 transitionDuration: 0 6}; 7 8const style = { 9 backgroundColor: 'tomato' 10}; 11 12class Gallery extends React.Component { 13 handleClick() {} 14 render() { 15 return ( 16 <Masonry 17 className={'my-gallery-class'} 18 style={style} 19 onClick={this.handleClick} 20 > 21 {...} 22 </Masonry> 23 ); 24 } 25} 26 27export default Gallery;
Accessing Masonry instance
Should you need to access the instance of Masonry (for example to listen to masonry events)
you can do so by using refs
.
1import * as React from 'react'; 2import Masonry from 'react-masonry-component'; 3 4class Gallery extends React.Component { 5 handleLayoutComplete() { }, 6 7 componentDidMount() { 8 this.masonry.on('layoutComplete', this.handleLayoutComplete); 9 }, 10 11 componentWillUnmount() { 12 this.masonry.off('layoutComplete', this.handleLayoutComplete); 13 }, 14 15 render() { 16 return ( 17 <Masonry 18 ref={function(c) {this.masonry = this.masonry || c.masonry;}.bind(this)} 19 > 20 {...} 21 </Masonry> 22 ); 23 } 24} 25 26export default Gallery;
Images Loaded Options
React Masonry Component uses Desandro's imagesloaded
library to detect when images have loaded. Should you want to pass
options down to it then you need to populate the imagesLoadedOptions
property on React Masonry Component.
This will most commonly be used when the elements in your gallery have CSS background images and you want to capture their load event. More info availabe on the imagesloaded website.
eg:
1import * as React from 'react'; 2import Masonry from 'react-masonry-component'; 3 4class Gallery extends React.Component { 5 render() { 6 const imagesLoadedOptions = { background: '.my-bg-image-el' } 7 8 return ( 9 <Masonry 10 className={'my-gallery-class'} 11 elementType={'ul'} 12 options={masonryOptions} 13 imagesLoadedOptions={imagesLoadedOptions} 14 > 15 <div className="my-bg-image-el"></div> 16 </Masonry> 17 ); 18 } 19} 20 21export default Gallery;
Events
onImagesLoaded
- triggered when all images are loaded or after each image is loaded whenupdateOnEachImageLoad
is set totrue
onLayoutComplete
- triggered after a layout and all positioning transitions have completed.onRemoveComplete
- triggered after an item element has been removed
1class Gallery extends React.Component { 2 componentDidMount() { 3 this.hide(); 4 }, 5 handleImagesLoaded(imagesLoadedInstance) { 6 this.show(); 7 }, 8 render() { 9 return ( 10 <Masonry 11 onImagesLoaded={this.handleImagesLoaded} 12 onLayoutComplete={laidOutItems => this.handleLayoutComplete(laidOutItems)} 13 onRemoveComplete={removedItems => this.handleRemoveComplete(removedItems)} 14 > 15 {...} 16 </Masonry> 17 ) 18 } 19}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 8/19 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 20 are checked with a SAST tool
Reason
89 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-hr2v-3952-633q
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-j4f2-536g-r55m
- Warn: Project is vulnerable to: GHSA-r7qp-cfhv-p84w
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-xf7w-r453-m56c
- Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq
- Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq
- Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm
- Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp
- Warn: Project is vulnerable to: GHSA-6x33-pw7p-hmpq
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-4hpf-3wq7-5rpr
- Warn: Project is vulnerable to: GHSA-f522-ffg8-j8r6
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-282f-qqgm-c34q
- Warn: Project is vulnerable to: GHSA-7x7c-qm48-pq9c
- Warn: Project is vulnerable to: GHSA-rc3x-jf5g-xvc5
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-82v2-mx6x-wq7q
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-hxm2-r34f-qmc5
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-q75g-2496-mxpp
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4
- Warn: Project is vulnerable to: GHSA-mvjj-gqq2-p4hw
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-fxwf-4rqh-v8g3
- Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj
- Warn: Project is vulnerable to: GHSA-xfhh-g9f5-x4m4
- Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq
- Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9
- Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3
- Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7
- Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-g7q5-pjjr-gqvp
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-662x-fhqg-9p8v
- Warn: Project is vulnerable to: GHSA-394c-5j6w-4xmx
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-mgfv-m47x-4wqp
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-5v72-xg48-5rpm
- Warn: Project is vulnerable to: GHSA-72mh-269x-7mh5
- Warn: Project is vulnerable to: GHSA-h4j5-c7cj-74xg
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r
- Warn: Project is vulnerable to: GHSA-g74r-ffvr-5q9f
- Warn: Project is vulnerable to: GHSA-wrvr-8mpx-r7pp
- Warn: Project is vulnerable to: GHSA-x43g-gj9x-838x
- Warn: Project is vulnerable to: GHSA-gqgv-6jq5-jjj9
- Warn: Project is vulnerable to: GHSA-7xfp-9c55-5vqj
- Warn: Project is vulnerable to: GHSA-qhv9-728r-6jqg
- Warn: Project is vulnerable to: GHSA-xc7v-wxcw-j472
Score
2.3
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More