diff --git a/package.json b/package.json index 45602682..e11df4d6 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "clean": "sh scripts/clean.sh", "release": "sh scripts/publish-latest.sh", "release-beta": "sh scripts/publish-beta.sh", - "release-local": "sh scripts/publish-local.sh" + "release-local": "sh scripts/publish-local.sh", + "prepare": "npm run build" }, "keywords": [ "react-native", @@ -34,6 +35,7 @@ }, "homepage": "https://github.com/Flipkart/recyclerlistview", "dependencies": { + "@types/lodash": "4.14.182", "lodash.debounce": "4.0.8", "prop-types": "15.8.1", "ts-object-utils": "0.0.5" @@ -47,9 +49,12 @@ "@types/prop-types": "15.5.2", "@types/react-native": "0.49.5", "@types/react": "16.4.7", - "@types/resize-observer-browser": "^0.1.7", + "@types/resize-observer-browser": "0.1.7", "file-directives": "1.4.6", "tslint": "5.11.0", "typescript": "3.3.1" + }, + "resolutions": { + "@types/lodash": "4.14.182" } } diff --git a/src/core/RecyclerListView.tsx b/src/core/RecyclerListView.tsx index 95dd87be..e9c23802 100644 --- a/src/core/RecyclerListView.tsx +++ b/src/core/RecyclerListView.tsx @@ -76,6 +76,11 @@ export interface OnRecreateParams { lastOffset?: number; } +export interface ViewabilityConfig { + minimumItemViewPercentage: number; + minimumViewTime: number; +} + export interface RecyclerListViewProps { layoutProvider: BaseLayoutProvider; dataProvider: BaseDataProvider; @@ -110,6 +115,7 @@ export interface RecyclerListViewProps { //For all props that need to be proxied to inner/external scrollview. Put them in an object and they'll be spread //and passed down. For better typescript support. scrollViewProps?: object; + viewabilityConfig?: ViewabilityConfig; applyWindowCorrection?: (offsetX: number, offsetY: number, windowCorrection: WindowCorrection) => void; onItemLayout?: (index: number) => void; windowCorrectionConfig?: { value?: WindowCorrection, applyToInitialOffset?: boolean, applyToItemScroll?: boolean }; @@ -141,6 +147,7 @@ export default class RecyclerListView

{ return this.props.dataProvider.getStableId(index); - }, !props.disableRecycling); + }, !props.disableRecycling, props.viewabilityConfig); if (this.props.windowCorrectionConfig) { let windowCorrection; @@ -228,6 +235,9 @@ export default class RecyclerListView