@react-native-ohos/flash-list
Version:
FlashList is a more performant FlatList replacement
57 lines • 2.79 kB
TypeScript
/**
* MIT License
*
* Copyright (C) 2024 Huawei Device Co., Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import React from "react";
import { BlankAreaEvent } from "../native/auto-layout/AutoLayoutView";
import FlashList from "../FlashList";
export interface BlankAreaTrackerResult {
/**
* Max blank area displayed
*/
maxBlankArea: number;
/**
* Sum of all blank area values across all frames
*/
cumulativeBlankArea: number;
}
export interface BlankAreaTrackerConfig {
/**
* When set to true the hook will also sum all negative blank area values.
* Blank area is negative when list is able to draw faster than the scroll speed.
*/
sumNegativeValues?: boolean;
/**
* By default, the hook ignores blank events for 1s after the list load. This value can be changed using this parameter.
* Please note that this duration kicks in after the list has loaded and not after the first scroll.
*/
startDelayInMs?: number;
}
/**
* Can be used to track visible blank area in production
* @param flashListRef Ref to the FlashList component
* @param onBlankAreaChange This event handler will be called when the blank area changes
* @param config additional configuration for the blank area tracker
* @returns blankAreaTrackerResult - maxBlankArea, cumulativeBlankArea this object is mutated and kept up to date. Also returns a callback that needs to be forwarded to FlashList.
*/
export declare function useBlankAreaTracker(flashListRef: React.RefObject<FlashList<any>>, onBlankAreaChange?: (value: BlankAreaTrackerResult) => void, config?: BlankAreaTrackerConfig): [BlankAreaTrackerResult, (event: BlankAreaEvent) => void];
//# sourceMappingURL=useBlankAreaTracker.d.ts.map