diff --git a/.gitignore b/.gitignore index 54b806f2..105c6216 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,5 @@ yarn.lock package-lock.json #npm release config -.npmrc \ No newline at end of file +.npmrc +scripts/publish-local.sh diff --git a/package.json b/package.json index e77ba184..ee12fa30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "recyclerlistview", - "version": "3.0.4", + "version": "3.0.9", "description": "The listview that you need and deserve. It was built for performance, uses cell recycling to achieve smooth scrolling.", "main": "dist/reactnative/index.js", "types": "dist/reactnative/index.d.ts", diff --git a/scripts/publish-local.sh b/scripts/publish-local.sh index db50797c..a6bb29ad 100644 --- a/scripts/publish-local.sh +++ b/scripts/publish-local.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -TARGET=$"/Users/talha.naqvi/Documents/Work/RLV-Demo/node_modules/recyclerlistview/dist" #target-path +TARGET=$"/Users/manish.patwari/work/FFB-Exp-Apps/node_modules/recyclerlistview/dist" #target-path npm run build diff --git a/src/core/RecyclerListView.tsx b/src/core/RecyclerListView.tsx index f55b9c29..07fc165c 100644 --- a/src/core/RecyclerListView.tsx +++ b/src/core/RecyclerListView.tsx @@ -110,6 +110,7 @@ export interface RecyclerListViewProps { scrollViewProps?: object; applyWindowCorrection?: (offsetX: number, offsetY: number, windowCorrection: WindowCorrection) => void; onItemLayout?: (index: number) => void; + onSizeChange?: (rlvDimension: Dimension, contentDimension: Dimension) => void; } export interface RecyclerListViewState { @@ -402,6 +403,7 @@ export default class RecyclerListView

extends Com private _stickyHeaderRef: StickyHeader | null = null; private _stickyFooterRef: StickyFooter | null = null; private _visibleIndicesAll: number[] = []; + private _isRlvScrollable: boolean = true; private _windowCorrection: WindowCorrection = { startCorrection: 0, endCorrection: 0, windowShift: 0, }; @@ -71,6 +72,7 @@ export default class StickyContainer

extends Com onScroll: this._onScroll, applyWindowCorrection: this._applyWindowCorrection, rowRenderer: this._rlvRowRenderer, + onSizeChange: this.props.alwaysStickyFooter ? this._onSizeChange : undefined, }); return ( @@ -102,7 +104,7 @@ export default class StickyContainer

extends Com overrideRowRenderer={this.props.overrideRowRenderer} renderContainer={this.props.renderStickyContainer} getWindowCorrection={this._getCurrentWindowCorrection} - alwaysStickBottom = {this.props.alwaysStickyFooter} /> + alwaysStickyFooter = {this.props.alwaysStickyFooter} /> ) : null} ); @@ -110,20 +112,30 @@ export default class StickyContainer

extends Com private _rlvRowRenderer = (type: string | number, data: any, index: number, extendedState?: object): JSX.Element | JSX.Element[] | null => { if (this.props.alwaysStickyFooter) { - const rlvDimension: Dimension | undefined = this._getRLVRenderedSize(); - const contentDimension: Dimension | undefined = this._getContentDimension(); - let isScrollable = false; - if (rlvDimension && contentDimension) { - isScrollable = contentDimension.height > rlvDimension.height; - } - if (!isScrollable && this.props.stickyFooterIndices - && index === this.props.stickyFooterIndices[0]) { + if (!this._isRlvScrollable && this.props.stickyFooterIndices + && index === this.props.stickyFooterIndices[this.props.stickyFooterIndices.length - 1]) { return null; } } return this._rowRenderer(type, data, index, extendedState); } + private _onSizeChange = (rlvDimension: Dimension, contentDimension: Dimension) => { + let isScrollable = this._isRlvScrollable; + if (rlvDimension && contentDimension) { + isScrollable = contentDimension.height > rlvDimension.height; + } + // In case of scrollable state change, we have to force render to current Sticky slots rendering. + if (this._recyclerRef && this._isRlvScrollable !== isScrollable) { + this._isRlvScrollable = isScrollable; + if (!isScrollable && this._stickyFooterRef) { + this._stickyFooterRef.onScroll(0); + this.forceUpdate(); + } + this._recyclerRef.forceRerender(); + } + } + private _getRecyclerRef = (recycler: any) => { this._recyclerRef = recycler as (RecyclerListView | undefined); if (this.props.children.ref) {