
Security News
MCP Steering Committee Launches Official MCP Registry in Preview
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
react-native-waterfall-list-view
Advanced tools
基于官方 flatlist 实现的 多列 不定高 瀑布流组件 不依赖任何第三方
const waterfallRef = useRef<IWaterFallList>(null);
<WaterFallList ref={waterfallRef} />;
waterfallRef.current?.flatList?.scrollToOffset;
export type ItemData = {
offsetTop: number; // !! 元素距离容器顶部的距离
itemH: number; // 元素高度
itemData: any; // 元素数据
columnIndex: number; // 当前元素所在的列
index: number; // 原始列表的位置索引
};
export type RowData = {
rowIndex: number; // 第几行
rowData: ItemData[]; // 每行的列数据
rowH: number; // 行高度
rowOffsetTop: number; // !! 每行距离容器顶部的距离
};
export type IRenderItemProps = {
item: ItemData;
index: number;
row: RowData;
};
export interface IWaterFallListProps
extends Omit<
FlatListProps<RowData>,
"renderItem" | "ItemSeparatorComponent"
> {
renderItem: ({
item,
index,
row,
}: IRenderItemProps) => React.ReactElement | null;
ItemSeparatorComponent?: () => JSX.Element;
children?: React.ReactNode; // 添加children类型
rowStyle?: ViewStyle;
}
export interface IWaterFallList {
refreshList: (offset?: number, animated?: boolean) => void;
flatList: FlatList | null;
}
最小高度>=最大高度的30%
不建议动态改变item的高度
会引起布局抖动import {
TouchableNativeFeedback,
TouchableHighlight,
TouchableOpacity,
TouchableWithoutFeedback,
} from "react-native";
// has to be replaced with:
import {
TouchableNativeFeedback,
TouchableHighlight,
TouchableOpacity,
TouchableWithoutFeedback,
} from "react-native-gesture-handler";
例如当前一行是这个形式:
第三个元素应该加在下一行的最短一列:
同理第四个元素也加在最短的一列 第二列
然后计算第二行的行高:
因为 flatlist 的一行是以最长的元素高度为准 所以我们需要计算出最长的元素高度是多少 并且还要减去上一行的高度这个偏移量。
所以高度如下
然后不断循环列表 直到结束。
FAQs
基于官方 flatlist 实现的 多列 不定高 瀑布流组件 不依赖任何第三方
We found that react-native-waterfall-list-view demonstrated a healthy version release cadence and project activity because the last version was released less than 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 MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.