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

Horizontal inversion #520

Merged
merged 35 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9e9e095
Added JS only fallbacks for unsupported platforms
naqvitalha Jul 7, 2022
63a208e
replace cell container
naqvitalha Jul 7, 2022
70ed2ee
update changelog
naqvitalha Jul 7, 2022
d750ecd
Update known-issues.md
naqvitalha Jul 7, 2022
57628c3
fix footer flicker
naqvitalha Jul 7, 2022
88d25d1
Improved glitch removal
naqvitalha Jul 8, 2022
06f8fbe
bug fix
naqvitalha Jul 8, 2022
e4c7472
Added footer correctiong on iOS
naqvitalha Jul 8, 2022
3f6e3c1
added changelog
naqvitalha Jul 8, 2022
4897440
Fix test
naqvitalha Jul 8, 2022
397f75e
Added viewPosition/Offset support
naqvitalha Jul 11, 2022
294ceac
added horizontal inversion
naqvitalha Jul 11, 2022
fd3dde0
Update CHANGELOG.md
naqvitalha Jul 11, 2022
f7435df
Merge branch 'scrollToImprovements' into horizontalInversion
naqvitalha Jul 11, 2022
ad9f27a
update changelog
naqvitalha Jul 11, 2022
4a29e0e
Update ios/Sources/AutoLayoutView.swift
naqvitalha Jul 11, 2022
afb22e4
format fix
naqvitalha Jul 11, 2022
b1ee6a9
fix web inversion
naqvitalha Jul 12, 2022
8172526
fix broken web implementation
naqvitalha Jul 12, 2022
b76c6f2
Merge branch 'fix-footer-layout' into scrollToImprovements
naqvitalha Jul 12, 2022
753230d
Merge branch 'scrollToImprovements' into horizontalInversion
naqvitalha Jul 12, 2022
c5ab27f
Merge branch 'extend-platform-support' into fix-footer-layout
naqvitalha Jul 12, 2022
445db76
Merge branch 'fix-footer-layout' into scrollToImprovements
naqvitalha Jul 12, 2022
7138bcc
Merge branch 'scrollToImprovements' into horizontalInversion
naqvitalha Jul 12, 2022
8b64e31
Update src/FlashList.tsx
naqvitalha Jul 12, 2022
d1133e1
Upgrade RLV to v4.1.1 (#522)
naqvitalha Jul 13, 2022
ea3ad37
Merge branch 'main' into fix-footer-layout
naqvitalha Jul 13, 2022
4718dd3
Revert "Upgrade RLV to v4.1.1 (#522)" (#525)
naqvitalha Jul 13, 2022
d54d7a8
fixed warnings
naqvitalha Jul 14, 2022
2b2162c
addressed android review comments
naqvitalha Jul 14, 2022
6862cee
address iOS comments
naqvitalha Jul 14, 2022
47ff5ad
Merge branch 'main' into fix-footer-layout
naqvitalha Jul 14, 2022
6adf8dc
Merge branch 'fix-footer-layout' into scrollToImprovements
naqvitalha Jul 15, 2022
d03f096
Merge branch 'scrollToImprovements' into horizontalInversion
naqvitalha Jul 15, 2022
9b3c7c4
Merge branch 'main' into horizontalInversion
naqvitalha Jul 15, 2022
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
- https://github.com/Shopify/flash-list/pull/519
- Added `viewPosition` and `viewOffset` support scrollTo methods
- https://github.com/Shopify/flash-list/pull/521
- Fix inverted mode while being horizontal
- https://github.com/Shopify/flash-list/pull/520
- Upgrade recyclerlistview to v4.1.1
- https://github.com/Shopify/flash-list/pull/526

Expand Down
9 changes: 6 additions & 3 deletions src/FlashList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class FlashList<T> extends React.PureComponent<
private stickyContentContainerRef?: PureComponentWrapper;
private listFixedDimensionSize = 0;
private transformStyle = { transform: [{ scaleY: -1 }] };
private transformStyleHorizontal = { transform: [{ scaleX: -1 }] };
private distanceFromWindow = 0;
private contentStyle: ContentStyle = {};
private loadStartTime = 0;
Expand All @@ -79,7 +80,6 @@ class FlashList<T> extends React.PureComponent<
applyToInitialOffset: true,
};

private emptyObject = {};
private postLoadTimeoutId?: ReturnType<typeof setTimeout>;
private sizeWarningTimeoutId?: ReturnType<typeof setTimeout>;

Expand Down Expand Up @@ -303,7 +303,7 @@ class FlashList<T> extends React.PureComponent<
stickyHeaderIndices={stickyHeaderIndices}
style={
this.props.horizontal
? this.emptyObject
? { ...this.getTransform() }
: { flex: 1, ...this.getTransform() }
}
>
Expand Down Expand Up @@ -496,7 +496,10 @@ class FlashList<T> extends React.PureComponent<
};

private getTransform() {
return (this.props.inverted && this.transformStyle) || undefined;
const transformStyle = this.props.horizontal
? this.transformStyleHorizontal
: this.transformStyle;
return (this.props.inverted && transformStyle) || undefined;
}

private getContentContainerInfo() {
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/PlatformHelper.web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,31 @@ describe("Platform Helper Web", () => {
x: 30,
y: 30,
});
const transformHorizontalInvertedStyle = getCellContainerPlatformStyles(
true,
{
x: 30,
y: 30,
isHorizontal: true,
}
);
const expectedTransform = "translate(20px,70px)";
const expectedTransformInverted = "translate(30px,30px) scaleY(-1)";
const expectedTransformHorizontalInverted =
"translate(30px,30px) scaleX(-1)";

expect(transformStyle?.transform).toBe(expectedTransform);
expect(transformStyle?.WebkitTransform).toBe(expectedTransform);
expect(transformInvertedStyle?.transform).toBe(expectedTransformInverted);
expect(transformInvertedStyle?.WebkitTransform).toBe(
expectedTransformInverted
);
expect(transformHorizontalInvertedStyle?.transform).toBe(
expectedTransformHorizontalInverted
);
expect(transformHorizontalInvertedStyle?.WebkitTransform).toBe(
expectedTransformHorizontalInverted
);
});
it("can return an animator", () => {
expect(getItemAnimator()!["animateWillMount"]).toBeDefined();
Expand Down
2 changes: 1 addition & 1 deletion src/native/config/PlatformHelper.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const PlatformConfig = {
};
const getCellContainerPlatformStyles = (
inverted: boolean,
parentProps: { x: number; y: number }
parentProps: { x: number; y: number; isHorizontal?: boolean }
): { transform: string; WebkitTransform: string } | undefined => {
return undefined;
};
Expand Down
2 changes: 1 addition & 1 deletion src/native/config/PlatformHelper.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const PlatformConfig = {
};
const getCellContainerPlatformStyles = (
inverted: boolean,
parentProps: { x: number; y: number }
parentProps: { x: number; y: number; isHorizontal?: boolean }
): { transform: string; WebkitTransform: string } | undefined => {
return undefined;
};
Expand Down
2 changes: 1 addition & 1 deletion src/native/config/PlatformHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const PlatformConfig = {
};
const getCellContainerPlatformStyles = (
inverted: boolean,
parentProps: { x: number; y: number }
parentProps: { x: number; y: number; isHorizontal?: boolean }
): { transform: string; WebkitTransform: string } | undefined => {
return undefined;
};
Expand Down
4 changes: 2 additions & 2 deletions src/native/config/PlatformHelper.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const PlatformConfig = {
};
const getCellContainerPlatformStyles = (
inverted: boolean,
parentProps: { x: number; y: number }
parentProps: { x: number; y: number; isHorizontal?: boolean }
): { transform: string; WebkitTransform: string } | undefined => {
const transformValue = `translate(${parentProps.x}px,${parentProps.y}px)${
inverted ? ` scaleY(-1)` : ``
inverted ? ` ${parentProps.isHorizontal ? `scaleX` : `scaleY`}(-1)` : ``
}`;
return { transform: transformValue, WebkitTransform: transformValue };
};
Expand Down