Modified VirtualListCell component to enable 'useNativeDriver' as Animated parameter#1304
Modified VirtualListCell component to enable 'useNativeDriver' as Animated parameter#1304alariej wants to merge 1 commit intomicrosoft:masterfrom
Conversation
… in the animated style
|
|
|
Thanks for taking the time to make a contribution. My understanding is that the native driver supports both "top" and "left". It doesn't make sense that it would support the former but not the latter. Do you have evidence that "left" is not supported? It makes sense that "width" is not supported by the native animation driver, but I don't think there's any need to animate the width of a cell, since the width is normally unchanged in typical use cases. @berickson1 wrote much of this code originally, so perhaps he has some thoughts here. |
|
You are right that 'left' could actually be included in the animation. However, it doesn't seem to be part of the animation in the current VirtualListCell code: There is no variable called '_leftAnimation' nor a 'timing' definition for anything but the 'top' value. It could be that 'left' animation was planned in the original concept, but never implemented. In any case, I wonder if it really makes sense to animate 'left' at all, since a VirtualListView is by definition / inheritance a vertically organized component. Please let me know what you think. If required, I could either modify this PR, or submit a new PR with the 'left' animation. Ref: https://github.com/microsoft/reactxp/blob/master/extensions/virtuallistview/src/VirtualListCell.tsx |
|
Also, this code in VirtualListCell: 'left' is not part of 'transform', and there is no 'translateX' anywhere. |
|
OK, thanks. The PR looks good to me. Let's give @berickson1 another day to respond. If he doesn't have time to look at it, I'll merge it as is. |
berickson1
left a comment
There was a problem hiding this comment.
Apologies on the delay, I wrote feedback but never submitted my review. In it's current state, this looks like a breaking change to me since the width and left prop won't be respected beyond the initial size that is provided.
| width: this._widthValue, | ||
| }); | ||
| this._staticStylePosition = RX.Styles.createViewStyle({ | ||
| width: this.props.width, |
There was a problem hiding this comment.
This change will make the width (and left position) of items static after it's first loaded. VLV cells currently support changing widths via a prop. I'm not sure this is a desirable change, at the very least it's a breaking change. Typically width doesn't change on an item in common cases, but I can't speak for all the uses of VLV.
|
OK thanks for the feedback @erictraut and @berickson1. Let me take another look at this PR and see if I can come up with a better solution to make it non-breaking. |
The VirtualListCell component of the VirtualListView extension does not use
useNativeDriver: truefor Animated styles, resulting in no animations on Android.This PR modifies the component to use 'useNativeDriver' for animating the 'top' value (moving the cell vertically in the list). The 'width' and 'left' values needed to be moved to a static style, as these values are not supported by 'useNativeDriver' (and it seems to me they were not part of the 'timing' animation anyway).
Tested on a physical device (LG G6 running Android 9).