How to sync two scrollviews in react native?

丶灬走出姿态 提交于 2019-12-20 12:42:08

问题


My requirement is to create a table with fixed header and first column, table data will scroll in both horizontal and vertical directions.

for this I have used 3 scrollviews , following gif will make it clear

  1. 1st scrollview is the header name row, it is set to horizontal = true (i.e its scroll direction is horizontal)
  2. 2nd scrollview is kcname 1st column of the table, it is vertical scroll, both of these have scrollEnabled={false}, as they wont take scroll gesture, they are scroll programmatically using scrollTo
  3. 3rd scrollview is body cell table filled with data, this view has 2 scrollviews as parent , one to take horizontal scroll and another to take vertical scroll.

the scroll values of two body scroll views are put in scrollTo of the other two scrollview using refs on onScroll event, scrollEventThrottle value is 16 .

My problem is how to sync these scrollviews scrolls as this clearly shows lag, which is not acceptable


回答1:


Disable scrollTos animation like this:

this.toolbar.scrollTo({
  x: yourXValue,
  animated: false,
});

Then there is no lag :)



来源:https://stackoverflow.com/questions/43338997/how-to-sync-two-scrollviews-in-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!