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

Layout type check for computed layouts #237

Merged
merged 7 commits into from
Aug 24, 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.14",
"version": "1.4.0-beta.15",
"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
10 changes: 6 additions & 4 deletions src/core/layoutmanager/LayoutManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ export class WrapGridLayoutManager extends LayoutManager {
}

const oldItemCount = this._layouts.length;

const itemDim = { height: 0, width: 0 };
let itemRect = null;

let oldLayout = null;

for (let i = startIndex; i < itemCount; i++) {
oldLayout = this._layouts[i];
if (oldLayout && oldLayout.isOverridden) {
const layoutType = this._layoutProvider.getLayoutTypeForIndex(i);
if (oldLayout && oldLayout.isOverridden && oldLayout.type === layoutType) {
itemDim.height = oldLayout.height;
itemDim.width = oldLayout.width;
} else {
this._layoutProvider.setComputedLayout(this._layoutProvider.getLayoutTypeForIndex(i), itemDim, i);
this._layoutProvider.setComputedLayout(layoutType, itemDim, i);
}
this.setMaxBounds(itemDim);
while (!this._checkBounds(startX, startY, itemDim, this._isHorizontal)) {
Expand All @@ -140,11 +140,12 @@ export class WrapGridLayoutManager extends LayoutManager {

//TODO: Talha creating array upfront will speed this up
if (i > oldItemCount - 1) {
this._layouts.push({ x: startX, y: startY, height: itemDim.height, width: itemDim.width });
this._layouts.push({ x: startX, y: startY, height: itemDim.height, width: itemDim.width, type: layoutType });
} else {
itemRect = this._layouts[i];
itemRect.x = startX;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the value here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

itemRect.y = startY;
itemRect.type = layoutType;
itemRect.width = itemDim.width;
itemRect.height = itemDim.height;
}
Expand Down Expand Up @@ -203,6 +204,7 @@ export class WrapGridLayoutManager extends LayoutManager {

export interface Layout extends Dimension, Point {
isOverridden?: boolean;
type: string | number;
}
export interface Point {
x: number;
Expand Down