wonday / react-native-pdf

A <Pdf /> component for react-native
MIT License
1.6k stars 555 forks source link

[Feature Request] Disable Scrolling #292

Closed export-mike closed 5 years ago

export-mike commented 5 years ago

I want to add the pdf viewer to a Scrollview so a user can scroll past the PDF viewer.

I can do this just fine with a react-native-webview scrollEnabled={false}

Or are there any ideas on how I can do this with the existing API for react-native-pdf?

wonday commented 5 years ago

There no API of react-native-pdf can do this now. Maybe you can add an transparent cover on it...

export-mike commented 5 years ago

hmm interesting to prevent touches?

would this then prevent scaling? pinch to zoom etc?

LVBK commented 5 years ago

@export-mike Easy method: I use a view to block scroll event. Then use @dudigital/react-native-zoomable-view as wrapper for pinch zoom and drag move. This way is fast and easy. But pdf resolution will not change when zoom in/out.

Custom method: I just made a custom as you want. It work perfectly on iOS support PDFKit. But android still have a bug can see apart or move to another page. See (https://github.com/LVBK/react-native-pdf) more detail.

If you find out something cool. Please share with me :)

wonday commented 5 years ago

You also can try enablePaging=true minScale=1 maxScale=1

It can only show one page and can not scroll/zoom.

Amosel commented 5 years ago

If you just want to block touch events, use <View pointerEvents={'none'} />

magcrider commented 1 year ago

If you just want to block touch events, use <View pointerEvents={'none'} />

I tried with this, and it worked, but when I changed the state dynamically from 'none' to 'auto' (or the other way around), the components were reloaded, and I lost the initial zoom value, So what I ended up doing was adding an absolute View on top of the PDF component

arpankumarlahiri commented 9 months ago

Hey, what if I want to disable scroll but still want option to zoom...