question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple WebViews in PagerView

See original GitHub issue

I am trying to display multiple webviews (with vertical scroll in them) using PagerView.

The issue that I am having is that when I scroll the web page in WebView, for some reason PagerView also handles the tap-and-drag gesture and sometimes may swipe the page. This is not the desired behavior and I am wondering how can it be avoided?

Here’s the working example:

import { Dimensions, View } from 'react-native';
import PagerView from 'react-native-pager-view';
import WebView from 'react-native-webview';

const { width, height } = Dimensions.get('window');

export default function App() {  
  return (
    <View style={{ flex: 1 }}>
      <PagerView overScrollMode='never' style={{ width, height}}>
        <View style={{ flex: 1 }}>
          <WebView source={{ uri: 'https://www.lipsum.com/' }} />
        </View>
        <View style={{ flex: 1 }}>
          <WebView source={{ uri: 'https://cn.lipsum.com/' }} />
        </View>
        <View style={{ flex: 1 }}>
          <WebView source={{ uri: 'https://es.lipsum.com/' }} />
        </View>
        <View style={{ flex: 1 }}>
          <WebView source={{ uri: 'https://it.lipsum.com/' }} />
        </View>
      </PagerView>
    </View>
  );
}

https://user-images.githubusercontent.com/873278/154859909-3cfe0e92-136a-49c6-80ce-8f3ebf03dbe7.mov

Thanks for any help!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:12

github_iconTop GitHub Comments

2reactions
manosKascommented, Jul 8, 2022

@zhuanghongji yeah thats more or less what i did but i experimented a bit with pager view 6.0.0-rc2 with lazy load and i got a better result

1reaction
jiantao88commented, Jul 19, 2022

@manosKas I didn’t use react-native-webview 。This library does not meet my needs,I am using the webview packaged by my own project

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logic to use multiple webview in TabLayout to handle memory ...
Use ViewPager . ViewPager will hold maximum 3 fragments in memory at any time(without changing the default offscreen page limit).
Read more >
Android WebView | Part 2: WebView on Top ViewPager2
Modify fragment creation and make sure we can open different pages on each viewpager. First for the blog, second for promotions. Modify the...
Read more >
Espresso Web - Android Developers
Espresso-Web is an entry point to work with Android WebView UI ... onData() method, a WebView interaction comprises several Atoms.
Read more >
How to restore the state of a WebView in a layout “Tabs + ...
replace the file eu/lucazanini/viewpager/MainActivity.java ... When swiping between different app sections, select // the corresponding tab.
Read more >
Android ViewPager Example Tutorial - DigitalOcean
In our android ViewPager application we'll implement a ViewPager that swipes through three views with different images and texts.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found