Skip to content

Commit 910edd6

Browse files
author
Manwei
committed
Modify
1.Change 'isScrollView' to 'snapshotContentContainer',and tag this options is Android only
1 parent f7be9eb commit 910edd6

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Returns a Promise of the image URI.
4242
- `"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*.
4343
- `"data-uri"`: same as `base64` but also includes the [Data URI scheme](https://en.wikipedia.org/wiki/Data_URI_scheme) header.
4444
- **`filename`** *(string)*: the name of the generated file if any (Android only). Defaults to `ReactNative_snapshot_image_${timestamp}`.
45-
- **`isScrollView`** *(bool)*: View is evaluated the real height when the value is true.
45+
- **`snapshotContentContainer`** *(bool)*: View is evaluated the real height when the value is true.(Android only)
4646

4747
## Caveats
4848

android/src/main/java/fr/greweb/reactnativeviewshot/RNViewShotModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ public void takeSnapshot(int tag, ReadableMap options, Promise promise) {
6464
Integer width = options.hasKey("width") ? (int)(displayMetrics.density * options.getDouble("width")) : null;
6565
Integer height = options.hasKey("height") ? (int)(displayMetrics.density * options.getDouble("height")) : null;
6666
String result = options.hasKey("result") ? options.getString("result") : "file";
67-
Boolean isScrollView = options.hasKey("isScrollView") ? options.getBoolean("isScrollView"):false;
67+
Boolean snapshotContentContainer = options.hasKey("snapshotContentContainer") ? options.getBoolean("snapshotContentContainer"):false;
6868
try {
6969
String name = options.hasKey("filename") ? options.getString("filename") : null;
7070
File tmpFile = "file".equals(result) ? createTempFile(getReactApplicationContext(), format, name) : null;
7171
UIManagerModule uiManager = this.reactContext.getNativeModule(UIManagerModule.class);
72-
uiManager.addUIBlock(new ViewShot(tag, format, compressFormat, quality, width, height, tmpFile, result,isScrollView,promise));
72+
uiManager.addUIBlock(new ViewShot(tag, format, compressFormat, quality, width, height, tmpFile, result,snapshotContentContainer,promise));
7373
}
7474
catch (Exception e) {
7575
promise.reject(ViewShot.ERROR_UNABLE_TO_SNAPSHOT, "Failed to snapshot view tag "+tag);

android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ViewShot implements UIBlock {
3636
private File output;
3737
private String result;
3838
private Promise promise;
39-
private Boolean isScrollView;
39+
private Boolean snapshotContentContainer;
4040

4141
public ViewShot(
4242
int tag,
@@ -47,7 +47,7 @@ public ViewShot(
4747
@Nullable Integer height,
4848
File output,
4949
String result,
50-
Boolean isScrollView,
50+
Boolean snapshotContentContainer,
5151
Promise promise) {
5252
this.tag = tag;
5353
this.extension = extension;
@@ -57,7 +57,7 @@ public ViewShot(
5757
this.height = height;
5858
this.output = output;
5959
this.result = result;
60-
this.isScrollView = isScrollView;
60+
this.snapshotContentContainer = snapshotContentContainer;
6161
this.promise = promise;
6262
}
6363

@@ -124,7 +124,7 @@ private void captureView (View view, OutputStream os) {
124124
}
125125

126126
//evaluate real height
127-
if (this.isScrollView){
127+
if (this.snapshotContentContainer){
128128
h=0;
129129
ScrollView scrollView = (ScrollView)view;
130130
for (int i = 0; i < scrollView.getChildCount(); i++) {

0 commit comments

Comments
 (0)