-
Notifications
You must be signed in to change notification settings - Fork 734
Feat/sortable list no scroll #1958
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
Conversation
const onLayout = useCallback((event: LayoutChangeEvent) => { | ||
// Round height for Android | ||
const newHeight = Math.round(event.nativeEvent.layout.height); | ||
itemHeight.value = newHeight; | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider moving it to the main index file and pass the callback thru the context
It's easier to see the declaration of itemHeight and its initialization in the same file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH this does not bother me, but ok.
What bothered me more is the logic index === 0 ? onItemLayout : undefined
inside the item, but I was not able to move that to the list, let me know if you have a solution for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my case, what I did is pass onLayout to all items.
But save the layout only once and have any callback arriving afterwards do nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is much simpler when using ScrollView
, here we have a FlatList
.
If it is possible to do it, then it's either by:
- Changing the
renderItem
function which will look odd and might affect performance. - Do it in the
CellRendererComponent
and that's not what you meant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it matter if it's FlatList or ScrollView.
The code I suggested is in the on item layout callback
const tempTranslateY = useSharedValue(0); | ||
const tempItemsOrder = useSharedValue(itemsOrder.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving these to useDragAfterLongPressGesture
hook.
I'd move the logic to the hook, any reason onDragStart, onDragUpdate, onDragEnd shouldn't be part of the hook's code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should look at this hook and the one in the SortableGridList
and extract a single one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, very possible.
But I prefer to do it once the components are stable and we know for sure the logic shared between them is the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So let's keep it as is? Do you want to add a task a TODO or...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not fix it? Is it a big change?
If we'll decide not to share code, the code we'll just stuck there..
Description
SortableList - a new component (scroll-while-dragging is not supported in this phase).
Changelog
SortableList - a new component (scroll-while-dragging is not supported in this phase).