Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional anchoring #213

Merged
merged 4 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recyclerlistview",
"version": "1.4.0-beta.9",
"version": "1.4.0-beta.10",
"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",
Expand Down
6 changes: 5 additions & 1 deletion src/core/RecyclerListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,11 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
if (forceFullRender || this.props.layoutProvider !== newProps.layoutProvider || this.props.isHorizontal !== newProps.isHorizontal) {
//TODO:Talha use old layout manager
this._virtualRenderer.setLayoutManager(newProps.layoutProvider.newLayoutManager(this._layout, newProps.isHorizontal));
this._virtualRenderer.refreshWithAnchor();
if (newProps.layoutProvider.shouldRefreshWithAnchoring) {
this._virtualRenderer.refreshWithAnchor();
} else {
this._virtualRenderer.refresh();
}
this._refreshViewability();
} else if (this.props.dataProvider !== newProps.dataProvider) {
const layoutManager = this._virtualRenderer.getLayoutManager();
Expand Down
6 changes: 4 additions & 2 deletions src/core/dependencies/LayoutProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { Layout, WrapGridLayoutManager, LayoutManager } from "../layoutmanager/L
*/

export abstract class BaseLayoutProvider {
//Unset if your new layout provider doesn't require firstVisibleIndex preservation on application
public shouldRefreshWithAnchoring: boolean = true;

//Return your layout manager, you get all required dependencies here. Also, make sure to use cachedLayouts. RLV might cache layouts and give back to
//in cases of conxtext preservation. Make sure you use them if provided.
public abstract newLayoutManager(renderWindowSize: Dimension, isHorizontal?: boolean, cachedLayouts?: Layout[]): LayoutManager;
Expand All @@ -34,8 +37,7 @@ export class LayoutProvider extends BaseLayoutProvider {
private _tempDim: Dimension;
private _lastLayoutManager: WrapGridLayoutManager | undefined;

constructor(getLayoutTypeForIndex: (index: number) => string | number,
setLayoutForType: (type: string | number, dim: Dimension, index: number) => void) {
constructor(getLayoutTypeForIndex: (index: number) => string | number, setLayoutForType: (type: string | number, dim: Dimension, index: number) => void) {
super();
this._getLayoutTypeForIndex = getLayoutTypeForIndex;
this._setLayoutForType = setLayoutForType;
Expand Down