You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Layout] Use React view as content view of a native scroll view; how can I measure React components so that I can set the contentSize correctly? #1897
I'm trying to build a scrollable page of information that has a parallax image header. QMBParallaxScrollViewController looks like a good choice to implement it, and is likely to have native performance. It's agnostic to what the content of the scrollview might be.
Below the parallax header, I have dynamic content that I want to use React Native to lay out for me.
However, in order to plonk a RCTRootView into the scroll view's content view and expect scrolling to work, we need to know how long the content of the RCTRootView is. The only way to measure this right now is outlined here: http://stackoverflow.com/questions/29828971/react-native-measure-a-view (basically #953) but I've not been able to get that to work.
changed the title [-]Use React view as content view of a native scroll view; need to measure React components to set contentSize correctly[/-][+]Use React view as content view of a native scroll view; how can I measure React components so that I can set the contentSize correctly?[/+]on Jul 7, 2015
changed the title [-]Use React view as content view of a native scroll view; how can I measure React components so that I can set the contentSize correctly?[/-][+][Layout] Use React view as content view of a native scroll view; how can I measure React components so that I can set the contentSize correctly?[/+]on Jul 7, 2015
Sounds like the native component is what needs to know the height? ReactNative hasn't been embedded in this way yet (so far just with a pre-defined root view frame. You'll probably need to wire up your own native hooks to report the size of the content (onLayout should give you that) then use that to update the frame of the root view from your native QMBParallaxScrollViewController.
But honestly I'd probably just rebuild the parallax logic yourself into a react native ScrollView instead. It's not too hard and will probably save a lot of headache if you can get the feel you want.
Thanks for your suggestions. onLayout looks like the next thing to try here. Good to know of the options.
I don't think I feel confident enough to build the parallax logic quite yet. I've already tried using the attempt here: https://github.com/lelandrichardson/react-native-parallax-viewbut it's buggy (the image jumps about) and I notice that the scrolling behaviour isn't quite exactly as I expect it.
EDIT: The parallax view project has been improved since the time of writing to make use of the Animation API. It works quite well now!
Activity
[-]Use React view as content view of a native scroll view; need to measure React components to set contentSize correctly[/-][+]Use React view as content view of a native scroll view; how can I measure React components so that I can set the contentSize correctly?[/+]nicklockwood commentedon Jul 7, 2015
cc: @sahrens
brentvatne commentedon Jul 7, 2015
@fatuhoku - you can use
onLayouton a containing view to get the dimensions, check out the LayoutEventsExample[-]Use React view as content view of a native scroll view; how can I measure React components so that I can set the contentSize correctly?[/-][+][Layout] Use React view as content view of a native scroll view; how can I measure React components so that I can set the contentSize correctly?[/+]sahrens commentedon Jul 8, 2015
Sounds like the native component is what needs to know the height? ReactNative hasn't been embedded in this way yet (so far just with a pre-defined root view frame. You'll probably need to wire up your own native hooks to report the size of the content (onLayout should give you that) then use that to update the frame of the root view from your native QMBParallaxScrollViewController.
But honestly I'd probably just rebuild the parallax logic yourself into a react native ScrollView instead. It's not too hard and will probably save a lot of headache if you can get the feel you want.
sahrens commentedon Jul 8, 2015
It will be even easier once the Animated API lands - #1900
hokster7 commentedon Jul 8, 2015
Thanks for your suggestions.
onLayoutlooks like the next thing to try here. Good to know of the options.I don't think I feel confident enough to build the parallax logic quite yet. I've already tried using the attempt here: https://github.com/lelandrichardson/react-native-parallax-view
but it's buggy (the image jumps about) and I notice that the scrolling behaviour isn't quite exactly as I expect it.EDIT: The parallax view project has been improved since the time of writing to make use of the Animation API. It works quite well now!