
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
yh-react-waterfall
Advanced tools
轻松实现瀑布流布局
import React from "react";
import Waterfall from "./components";
//模拟数据
const imglist = [
"http://dummyimage.com/200x100",
"http://dummyimage.com/200x200",
"http://dummyimage.com/200x100",
"http://dummyimage.com/200x500",
"http://dummyimage.com/200x800",
];
let arr: Array<string> = [];
for (let i = 0; i < 100; i++) {
arr = arr.concat(imglist);
}
///////////////////////
function App() {
return (
<Waterfall
style={{
border: "1px solid black",
}}
column={3}
//220是200宽,左右padding 10
itemWidth={220} //瀑布流需要每个宽度相等,高度可以不相等 单位px 如果rem自行换算
>
{arr.map((v, i) => {
const height = parseFloat(v.slice(v.length - 3, v.length));
return (
<div
key={i}
style={{
padding: "10px",
boxSizing: "content-box",
}}
//这个是图片高度+上下padding 20 必传项!!!!
data-height={height + 20} //高度必须固定,因为图片异步加载,会导致div塌缩,从而高度计算错误
>
<img src={v} alt=""></img>
</div>
);
})}
</Waterfall>
);
}
export default App;
interface WaterfallProps {
//外层容器样式 ,需要自己定外层容器宽高,默认宽高800px
style?: CSSProperties;
//外层容器类名
classnames?: string;
//列数 必传
column: number;
//每个子元素宽度,需要定宽 必传
itemWidth: number;
//容器虚拟渲染高度,需要大于容器高度,用于在用户没滚到最底层时加载
forceHeight?: number;
//监听滚动函数,参数是强制刷新,使得可以继续对滚动进行判断
scrollCallback?: (v: React.Dispatch<React.SetStateAction<number>>) => void;
//拿到外层容器的ref
wrapperRefCallback?: (v: RefObject<HTMLDivElement>) => void;
}
必须为数组的 react 元素才可以工作!目前暂时非数组无法工作。也就是一般使用 map 或者用 Array 包一下。
不满意外层容器宽高,通过 style 进行设置。
column * itemWidth 需要 < 外层容器宽
FAQs
waterfall layout ; 瀑布流布局
We found that yh-react-waterfall demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.