简体   繁体   English

使用PanResponder向上滑动时使View呈现

[英]Make View render while swiping up with PanResponder

I am able to change the position (swipe up) of my View accordingly with PanResPonder. 我可以使用PanResPonder相应地更改视图的位置(向上滑动)。 The problem is during the swipe motion, the content of the View being dragged for the swipe do not render. 问题在于滑动动作期间,为滑动而拖动的视图的内容未渲染。

I tried using flexGrow:1 and flex:1 so as the View enlarge with the swipe, the View would be getting filled by content. 我尝试使用flexGrow:1和flex:1,以便随着视图的滑动放大,视图将被内容填充。

I know there a few libraries out there for swipes but I think this is fairly doable without library. 我知道那里有一些图书馆可以刷卡,但是我认为没有图书馆就可以做到。 Thanks in advance cheers. 在此先感谢您的欢呼。

It really depends on your approach there. 这实际上取决于您在那里的处理方式。 First things first. 首先是第一件事。

You have to understand about JS Bridge and Native on react-native. 您必须了解react-native上的JS Bridge和Native。 The JSBridge is single-treaded and all the fired renders go through there. JSBridge是单踩的,所有发射的渲染图都经过那里。 It means you can easily get dropped on FPS if you do not take it into account. 这意味着如果不考虑FPS,您很容易就可以放弃。 The Native, well, is native code running, thats all. 好吧,本机就是运行本机代码,仅此而已。

To have performant app, you have to keep the passes over the bridge to a minimun. 要拥有高性能的应用程序,您必须将通行证保持在最低水平。

The PanResponder touches happen on the native side, while the component renders use the bridge. PanResponder触摸发生在本机端,而组件渲染使用桥。 You should put some code there, but i would bet that the problem is with too many renders happening and the JS Bridge gets overloaded. 您应该在此处放置一些代码,但是我敢打赌,问题出在渲染太多,而JS Bridge变得超载了。

Also try to use Direct Manipulation ( https://facebook.github.io/react-native/docs/direct-manipulation.html ) to avoit rendering one entire tree and perform it on the native side. 还可以尝试使用直接操纵( https://facebook.github.io/react-native/docs/direct-manipulation.html )避免渲染一棵完整的树并在本机侧执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM