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

Render off screen area #31

Closed
timLoewel opened this issue Jan 20, 2017 · 4 comments
Closed

Render off screen area #31

timLoewel opened this issue Jan 20, 2017 · 4 comments

Comments

@timLoewel
Copy link

Hi,

is it possible to capture a whole View, even the parts that are not yet on screen (like in a scrollview)?
Or even better: capture a View that has not yet been given to the render method?
e.g.

createView(){ 
		return <View>
			<Text>Hello World</Text>
		</View>
	}
...
RNViewShot.takeSnapshot(this.createView(), {
					 format: 'png',
					result: 'file',
					 });

Is this planned, and would this at all be possible with the current architecture?
Best, Tim

@gre
Copy link
Owner

gre commented Jan 20, 2017

you can "render off-screen" by rendering it in a View that is not displayed or absolute "out of the screen".
It's a bit hacky but i've been using it in prod.

just a quick example:

class Stuff extends Component {
  snapIt() { return RNViewShot.takeSnapshot(this.refs.root, {...}) }
  render () {
    return <View ref="root">...</View>;
  }
}
class MyApp extends Component {
  doIt = () => { this.refs.stuff.snapIt().then(...) }
  render () {
    return <View>
      <View style={{ position: "absolute", left: 1000 /* basically should be screenSize.width */ }}>
        <Stuff ref="stuff" />
      </View>
      .. your app content..
      <Button onPress={this.doIt} label="RENDER IT!" />
    </View>
  }
}

@timLoewel
Copy link
Author

Cool, This Works. Thanks a lot.

@gre gre mentioned this issue Jan 26, 2017
@tza17313
Copy link

tza17313 commented Apr 23, 2017

@gre Have you ever encountered a view outside the Image will have a certain probability can not be captured; I am sure this picture has been loaded . if I set the left to 0, the Image ca be captured.

Platform : android (6.0.1 and 7.0) ;
react-native : 0.43.1
react-native-view-shot : 1.9.1

@hugoh59
Copy link

hugoh59 commented Jul 31, 2020

Do you have an exemple for a functional component?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants