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

Fix ScrollView Snapshots #35

Merged
merged 4 commits into from Feb 20, 2017
Merged

Fix ScrollView Snapshots #35

merged 4 commits into from Feb 20, 2017

Conversation

Manweill
Copy link
Contributor

@Manweill Manweill commented Feb 9, 2017

#34

1.evaluated the real height when the isScrollView is true
2.upgrade README.md

gre#34

1.evaluated the real height when the isScrollView is true
2.upgrade README.md
@Manweill
Copy link
Contributor Author

Manweill commented Feb 9, 2017

@gre
I fix the problem #34, but now has new problem.
if a webview in scrollView,
when scrollView takeSnapshot,
the webview content does not draw in the image. can u support me ?

Copy link
Owner

@gre gre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the feature. I think it can be useful.
I'm a bit concerned about one thing though: it's probably that you will reach the max height the Bitmap can take (in Android at least). By experimenting, I've seen that Android don't like to have bitmap greater than the screen size (in nb of pixels). You might have an exception and promise would fail. to be tested.

Please see my comments.

README.md Outdated
@@ -42,6 +42,7 @@ Returns a Promise of the image URI.
- `"base64"`: encode as base64 and returns the raw string. Use only with small images as this may result of lags (the string is sent over the bridge). *N.B. This is not a data uri, use `data-uri` instead*.
- `"data-uri"`: same as `base64` but also includes the [Data URI scheme](https://en.wikipedia.org/wiki/Data_URI_scheme) header.
- **`filename`** *(string)*: the name of the generated file if any (Android only). Defaults to `ReactNative_snapshot_image_${timestamp}`.
- **`isScrollView`** *(bool)*: View is evaluated the real height when the value is true.
Copy link
Owner

@gre gre Feb 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about setting that on JS side, it seems redundant information with checking view instanceof ScrollView ? OR at least, the naming is not good ('isScrollView' can be determined without the user to tell).

I guess such a argument is still a good idea to have on JS side, because you want to choose between one of these option: snapshot the ScrollView actual display (default) vs the underlying 'container' size?

then maybe you need to rename to something like snapshotContentContainer . to reflect the 'contentContainer' naming convention of RN ScrollView. or maybe you have a better name?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second note: best would be to also implement it in iOS, but otherwise, please note in the README it's Android only for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I also think that. isScrollView is not good ,but i can't think other one. i am english is very bad.
and then, i can't implement it in iOS, because i can't coding swift,. i will try iOS but not just yet

h=0;
ScrollView scrollView = (ScrollView)view;
for (int i = 0; i < scrollView.getChildCount(); i++) {
h += scrollView.getChildAt(i).getHeight();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that the best reliable way to compute the height? there is no other available option on ScrollView? what if one of the child have margin?

Copy link
Contributor Author

@Manweill Manweill Feb 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't know that is the bast reliable way to compute the height ; i find them by google. and i use in my project is success. but i don't tested one of the child have margin scenc. tomorrow i will be trying this;

Copy link
Contributor Author

@Manweill Manweill Feb 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gre
hi, i tested it, it can compute the realy height, when the one of the child have margin(two in de ScrollView, one marginTop 100 ,other one marginTop -300). now, how i rename isScrollView to snapshotContentContainer and modify README. create new pull request or just modify in my fork project

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah you can modify in your branch and push to your github fork

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's ok. you see again

Manwei and others added 3 commits February 13, 2017 08:33
1.Change 'isScrollView' to 'snapshotContentContainer',and tag this options is Android only
@gre gre merged commit bb92625 into gre:master Feb 20, 2017
@gre gre mentioned this pull request Feb 28, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants