Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Jul 8, 2022
1 parent 06fb1dd commit f72cac2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
* Check out [scrollToOffset](docs/virtualizedlist.html#scrolltooffset) of VirtualizedList
*/
scrollToOffset(params: {animated?: ?boolean, offset: number, ...}) {
console.log('TESTING::FlatList scrollToOffset');
if (this._listRef) {
this._listRef.scrollToOffset(params);
}
Expand Down Expand Up @@ -434,6 +435,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
}

componentDidUpdate(prevProps: Props<ItemT>) {
console.log('TESTING::FlatList componentDidUpdate');
invariant(
prevProps.numColumns === this.props.numColumns,
'Changing numColumns on the fly is not supported. Change the key prop on FlatList when ' +
Expand Down
28 changes: 20 additions & 8 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
const animated = params ? params.animated : true;
const veryLast = this.props.getItemCount(this.props.data) - 1;
const frame = this.__getFrameMetricsApprox(veryLast);
const offset = Math.max(
0,
console.log('TESTING::VirtualizedList scrollToEnd');
console.log('TESTING::VirtualizedList frame', frame);
const offsetCalculation =
frame.offset +
frame.length +
this._footerLength -
this._scrollMetrics.visibleLength,
);
frame.length +
this._footerLength -
this._scrollMetrics.visibleLength;
const offset = Math.max(0, offsetCalculation);

if (this._scrollRef == null) {
return;
Expand Down Expand Up @@ -751,6 +752,17 @@ class VirtualizedList extends React.PureComponent<Props, State> {
parentDebugInfo: this.context.debugInfo,
});
}
if (this.props.inverted) {
console.log('');
// this.scrollToEnd({animated: false});
// const veryLast = this.props.getItemCount(this.props.data) - 1;
const veryLast = 4;
const frame = this.__getFrameMetricsApprox(veryLast);
this.scrollToOffset({offset: frame.offset, animated: true});
console.log('TESTING::VirtualizedList veryLast', veryLast);
console.log('TESTING::VirtualizedList frame', frame);
// this.scrollToOffset({offset: 310, animated: true});
}
}

componentWillUnmount() {
Expand Down Expand Up @@ -953,7 +965,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
0,
lastInitialIndex,
);
this.scrollToOffset({offset: 0, animated: false});
// this.scrollToOffset({offset: 0, animated: false});
}
const firstAfterInitial = Math.max(lastInitialIndex + 1, first);
if (!isVirtualizationDisabled && first > lastInitialIndex + 1) {
Expand Down Expand Up @@ -1016,7 +1028,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
0,
lastInitialIndex,
);
this.scrollToEnd({animated: false});
// this.scrollToOffset({offset: 1300, animated: true});
}
if (!this._hasWarned.keys && _usedIndexForKey) {
console.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public ReactHorizontalScrollView(Context context, @Nullable FpsListener fpsListe
I18nUtil.getInstance().isRTL(context)
? ViewCompat.LAYOUT_DIRECTION_RTL
: ViewCompat.LAYOUT_DIRECTION_LTR);
fullScroll(View.FOCUS_DOWN);
}

public boolean getScrollEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import onViewableItemsChangedExample from './FlatList-onViewableItemsChanged';
import WithSeparatorsExample from './FlatList-withSeparators';
import MultiColumnExample from './FlatList-multiColumn';
import StickyHeadersExample from './FlatList-stickyHeaders';
import NestedExample from './FlatList-nested';

export default ({
framework: 'React',
Expand All @@ -34,5 +35,6 @@ export default ({
WithSeparatorsExample,
MultiColumnExample,
StickyHeadersExample,
NestedExample,
],
}: RNTesterModule);

0 comments on commit f72cac2

Please sign in to comment.