当前位置:网站首页>Resolve the horizontal (vertical) sliding conflict between viewpager and WebView
Resolve the horizontal (vertical) sliding conflict between viewpager and WebView
2022-07-05 09:36:00 【Black Mountain demon 2018】
Rookies still talk about the problems encountered in the project .
Problem description :
Use... In projects viewpager + fragment To achieve multi-channel switching , One of them fragment There's a webview, This webview Loaded H5 page
There are left and right sliding carousels , Outer parent control (viewpager) Will intercept and consume left-right sliding events , therefore H5 You can't slide the left and right rotating pictures in .
Problem solving :
1. The first scheme is when the channel page is H5 When , Ban the outer layer viewpager Slide left and right , namely webview call requestDisallowInterceptTouchEvent(true) Don't let the parent layout intercept events . But this plan is too violent , If the product manager agrees .
2. The second scheme is native native And H5 Interact , from H5 tell native Location of its own rotation map , And then in webview Of onTouchListener Of onTouch Do the corresponding processing in the method , If the sliding gesture is in this range , be requestDisallowInterceptTouchEvent(true) Don't let the parent layout intercept events . conversely , Then let the parent layout intercept events . This scheme has many limitations , If H5 The need is clear , Just fixed in a certain area, there is a rotating broadcast that slides left and right , And the future will not change much , Then this plan is feasible , But if H5 The page has many controls that can slide left and right , And future demand is not necessarily , Then the scope of these controls must be told to the native . And the range judgment of the client will also follow H5 The changes of change follow the changes , In this case, it is not advisable . Specific reference https://www.jianshu.com/p/a6f9d4046985
3. The third scheme is also Native native And H5 Interact , Principle similarity . But it is different from scheme II ,H5 There is no need to tell native native The scope of specific rotation control , Native native You only need to define whether to let the parent layout intercept events for H5 Call .H5 The rotation control on only needs to be in the corresponding touchstart and touchmove Just adjust the original method . For details, please refer to https://www.jianshu.com/p/818d566c4c5a, I adopted this plan in the project .
边栏推荐
- 【el-table如何禁用】
- LeetCode 503. Next bigger Element II
- Explain NN in pytorch in simple terms CrossEntropyLoss
- OpenGL - Model Loading
- Svgo v3.9.0+
- How to choose the right chain management software?
- C # image difference comparison: image subtraction (pointer method, high speed)
- VS Code问题:长行的长度可通过 “editor.maxTokenizationLineLength“ 进行配置
- 太不好用了,长文章加图文,今后只写小短文
- 基于宽表的数据建模应用
猜你喜欢
High performance spark_ Transformation performance
百度智能小程序巡检调度方案演进之路
The most comprehensive promotion strategy: online and offline promotion methods of E-commerce mall
Priority queue (heap)
Deep understanding of C language pointer
How to empty uploaded attachments with components encapsulated by El upload
The research trend of map based comparative learning (gnn+cl) in the top paper
C language - input array two-dimensional array a from the keyboard, and put 3 in a × 5. The elements in the third column of the matrix are moved to the left to the 0 column, and the element rows in ea
AUTOSAR from getting started to mastering 100 lectures (103) -dbc file format and creation details
What should we pay attention to when entering the community e-commerce business?
随机推荐
Wxss template syntax
2309. The best English letters with both upper and lower case
What are the advantages of the live teaching system to improve learning quickly?
OpenGL - Lighting
Unity skframework framework (XXII), runtime console runtime debugging tool
一文读懂TDengine的窗口查询功能
Lepton 无损压缩原理及性能分析
OpenGL - Model Loading
小程序启动性能优化实践
[object array A and object array B take out different elements of ID and assign them to the new array]
基于模板配置的数据可视化平台
mysql安装配置以及创建数据库和表
Node の MongoDB Driver
2310. The number of bits is the sum of integers of K
Kotlin introductory notes (III) kotlin program logic control (if, when)
Can't find the activitymainbinding class? The pit I stepped on when I just learned databinding
What about wechat mall? 5 tips to clear your mind
Applet data attribute method
Progressive JPEG pictures and related
Why does everyone want to do e-commerce? How much do you know about the advantages of online shopping malls?