Skip to content

Commit

Permalink
add an option for disabling double tap (#797)
Browse files Browse the repository at this point in the history
* add an option for disabling double tap

* update readme
  • Loading branch information
tobyt42 authored Jan 16, 2024
1 parent 37d128a commit bcaff69
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 31 deletions.
63 changes: 34 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ react-native run-ios
<details>
<summary>ChangeLog details</summary>

v6.8.0

1. Improved: Added enableDoubleTapZoom option

v6.7.4
1. Fixed: Fix Android crash issue

Expand Down Expand Up @@ -291,35 +295,36 @@ const styles = StyleSheet.create({

### Configuration

| Property | Type | Default | Description | iOS | Android | Windows | FirstRelease |
| ------------- |:-------------:|:----------------:| ------------------- | ------| ------- | ------- | ------------ |
| source | object | not null | PDF source like {uri:xxx, cache:false}. see the following for detail.|||| <3.0 |
| page | number | 1 | initial page index |||| <3.0 |
| scale | number | 1.0 | should minScale<=scale<=maxScale|||| <3.0 |
| minScale | number | 1.0 | min scale|||| 5.0.5 |
| maxScale | number | 3.0 | max scale|||| 5.0.5 |
| horizontal | bool | false | draw page direction, if you want to listen the orientation change, you can use [[react-native-orientation-locker]](https://github.com/wonday/react-native-orientation-locker)|||| <3.0 |
| showsHorizontalScrollIndicator | bool | true | shows or hides the horizontal scroll bar indicator on iOS|| | | 6.6 |
| showsVerticalScrollIndicator | bool | true | shows or hides the vertical scroll bar indicator on iOS|| | | 6.6 |
| fitWidth | bool | false | if true fit the width of view, can not use fitWidth=true together with scale|||| <3.0, abandoned from 3.0 |
| fitPolicy | number | 2 | 0:fit width, 1:fit height, 2:fit both(default)|||| 3.0 |
| spacing | number | 10 | the breaker size between pages|||| <3.0 |
| password | string | "" | pdf password, if password error, will call OnError() with message "Password required or incorrect password." |||| <3.0 |
| style | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... |||| <3.0 |
| renderActivityIndicator | (progress) => Component | <ProgressBar/> | when loading show it as an indicator, you can use your component|||| <3.0 |
| enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch |||| <3.0 |
| enablePaging | bool | false | only show one page in screen |||| 5.0.1 |
| enableRTL | bool | false | scroll page as "page3, page2, page1" |||| 5.0.1 |
| enableAnnotationRendering | bool | true | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing |||| 5.0.3 |
| trustAllCerts | bool | true | Allow connections to servers with self-signed certification |||| 6.0.? |
| singlePage | bool | false | Only show first page, useful for thumbnail views |||| 6.2.1 |
| onLoadProgress | function(percent) | null | callback when loading, return loading progress (0-1) |||| <3.0 |
| onLoadComplete | function(numberOfPages, path, {width, height}, tableContents) | null | callback when pdf load completed, return total page count, pdf local/cache path, {width,height} and table of contents ||| ✔ but without tableContents | <3.0 |
| onPageChanged | function(page,numberOfPages) | null | callback when page changed ,return current page and total page count |||| <3.0 |
| onError | function(error) | null | callback when error happened |||| <3.0 |
| onPageSingleTap | function(page) | null | callback when page was single tapped |||| 3.0 |
| onScaleChanged | function(scale) | null | callback when scale page |||| 3.0 |
| onPressLink | function(uri) | null | callback when link tapped |||| 6.0.0 |
| Property | Type | Default | Description | iOS | Android | Windows | FirstRelease |
| ------------------------------ | :-----------------------------------------------------------: | :----------------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------- | --------------------------- | ------------------------ |
| source | object | not null | PDF source like {uri:xxx, cache:false}. see the following for detail. |||| <3.0 |
| page | number | 1 | initial page index |||| <3.0 |
| scale | number | 1.0 | should minScale<=scale<=maxScale |||| <3.0 |
| minScale | number | 1.0 | min scale |||| 5.0.5 |
| maxScale | number | 3.0 | max scale |||| 5.0.5 |
| horizontal | bool | false | draw page direction, if you want to listen the orientation change, you can use [[react-native-orientation-locker]](https://github.com/wonday/react-native-orientation-locker) |||| <3.0 |
| showsHorizontalScrollIndicator | bool | true | shows or hides the horizontal scroll bar indicator on iOS || | | 6.6 |
| showsVerticalScrollIndicator | bool | true | shows or hides the vertical scroll bar indicator on iOS || | | 6.6 |
| fitWidth | bool | false | if true fit the width of view, can not use fitWidth=true together with scale |||| <3.0, abandoned from 3.0 |
| fitPolicy | number | 2 | 0:fit width, 1:fit height, 2:fit both(default) |||| 3.0 |
| spacing | number | 10 | the breaker size between pages |||| <3.0 |
| password | string | "" | pdf password, if password error, will call OnError() with message "Password required or incorrect password." |||| <3.0 |
| style | object | {backgroundColor:"#eee"} | support normal view style, you can use this to set border/spacing color... |||| <3.0 |
| renderActivityIndicator | (progress) => Component | <ProgressBar/> | when loading show it as an indicator, you can use your component |||| <3.0 |
| enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch |||| <3.0 |
| enablePaging | bool | false | only show one page in screen |||| 5.0.1 |
| enableRTL | bool | false | scroll page as "page3, page2, page1" |||| 5.0.1 |
| enableAnnotationRendering | bool | true | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing |||| 5.0.3 |
| enableDoubleTapZoom | bool | true | Enable double tap to zoom gesture |||| 6.8.0 |
| trustAllCerts | bool | true | Allow connections to servers with self-signed certification |||| 6.0.? |
| singlePage | bool | false | Only show first page, useful for thumbnail views |||| 6.2.1 |
| onLoadProgress | function(percent) | null | callback when loading, return loading progress (0-1) |||| <3.0 |
| onLoadComplete | function(numberOfPages, path, {width, height}, tableContents) | null | callback when pdf load completed, return total page count, pdf local/cache path, {width,height} and table of contents ||| ✔ but without tableContents | <3.0 |
| onPageChanged | function(page,numberOfPages) | null | callback when page changed ,return current page and total page count |||| <3.0 |
| onError | function(error) | null | callback when error happened |||| <3.0 |
| onPageSingleTap | function(page) | null | callback when page was single tapped |||| 3.0 |
| onScaleChanged | function(scale) | null | callback when scale page |||| 3.0 |
| onPressLink | function(uri) | null | callback when link tapped |||| 6.0.0 |

#### parameters of source

Expand Down
5 changes: 5 additions & 0 deletions android/src/main/java/org/wonday/pdf/PdfManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public void setEnableAnnotationRendering(PdfView pdfView, boolean enableAnnotati
pdfView.setEnableAnnotationRendering(enableAnnotationRendering);
}

@ReactProp(name = "enableDoubleTapZoom")
public void setEnableDoubleTapZoom(PdfView pdfView, boolean enableDoubleTap) {
pdfView.setEnableDoubleTapZoom(enableDoubleTap);
}

@ReactProp(name = "enablePaging")
public void setEnablePaging(PdfView pdfView, boolean enablePaging) {
pdfView.setEnablePaging(enablePaging);
Expand Down
7 changes: 6 additions & 1 deletion android/src/main/java/org/wonday/pdf/PdfView.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
private String password = "";
private boolean enableAntialiasing = true;
private boolean enableAnnotationRendering = true;
private boolean enableDoubleTapZoom = true;

private boolean enablePaging = false;
private boolean autoSpacing = false;
Expand Down Expand Up @@ -282,7 +283,7 @@ public void drawPdf() {
.autoSpacing(this.autoSpacing)
.pageFling(this.pageFling)
.enableSwipe(!this.singlePage)
.enableDoubletap(!this.singlePage)
.enableDoubletap(!this.singlePage && this.enableDoubleTapZoom)
.enableAnnotationRendering(this.enableAnnotationRendering)
.linkHandler(this);

Expand All @@ -297,6 +298,10 @@ public void drawPdf() {
}
}

public void setEnableDoubleTapZoom(boolean enableDoubleTapZoom) {
this.enableDoubleTapZoom = enableDoubleTapZoom;
}

public void setPath(String path) {
this.path = path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public void setProperty(T view, String propName, @Nullable Object value) {
case "enableAnnotationRendering":
mViewManager.setEnableAnnotationRendering(view, value == null ? false : (boolean) value);
break;
case "enableDoubleTapZoom":
mViewManager.setEnableDoubleTapZoom(view, value == null ? false : (boolean) value);
break;
case "enableAntialiasing":
mViewManager.setEnableAntialiasing(view, value == null ? false : (boolean) value);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public interface RNPDFPdfViewManagerInterface<T extends View> {
void setEnablePaging(T view, boolean value);
void setEnableRTL(T view, boolean value);
void setEnableAnnotationRendering(T view, boolean value);
void setEnableDoubleTapZoom(T view, boolean value);
void setEnableAntialiasing(T view, boolean value);
void setFitPolicy(T view, int value);
void setSpacing(T view, int value);
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface PdfProps {
enablePaging?: boolean,
enableRTL?: boolean,
enableAnnotationRendering?: boolean,
enableDoubleTapZoom?: boolean;
fitPolicy?: number,
trustAllCerts?: boolean,
singlePage?: boolean,
Expand Down
1 change: 1 addition & 0 deletions ios/RNPDFPdf/RNPDFPdfView.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ UIView
@property(nonatomic) BOOL enablePaging;
@property(nonatomic) BOOL enableRTL;
@property(nonatomic) BOOL enableAnnotationRendering;
@property(nonatomic) BOOL enableDoubleTapZoom;
@property(nonatomic) int fitPolicy;
@property(nonatomic) int spacing;
@property(nonatomic, strong) NSString *password;
Expand Down
Loading

0 comments on commit bcaff69

Please sign in to comment.