Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

两个scrollview 联动出现不一致 #65

Open
thh0613 opened this issue Dec 27, 2018 · 2 comments
Open

两个scrollview 联动出现不一致 #65

thh0613 opened this issue Dec 27, 2018 · 2 comments
Assignees

Comments

@thh0613
Copy link

thh0613 commented Dec 27, 2018

我在使用bindingx 做两个列表联动,因为scroll 动画暂时不支持list,我用的是两个scrollview, 然后在一个scrollview 手滑动时,另一个scrollview做bindingx 的 eventType 为scroll的scroll.contentOffsetY动画,在动画中,会出现第二个列表滑动有滞后的情况。

    onTouchRight() {
                let leftList = this.$refs.leftList.ref;
                let rightList = this.$refs.rightList.ref;
    
                this.bindingToken = Binding.bind({
                    eventType: 'scroll',
                    anchor: rightList,
                    props: [{
                        element: leftList,
                        property: 'scroll.contentOffsetY',
                        expression: {
                            origin: `y+0`
                        }
                    }]
                }) 
            }
@Rowandjj
Copy link
Contributor

Rowandjj commented Dec 29, 2018

@thh0613 hi, 麻烦提供下更多信息。

  1. 机型、Bindingx版本、weex版本;
  2. 可复现demo,放到jsplayground;

@Rowandjj Rowandjj self-assigned this Dec 29, 2018
@thh0613
Copy link
Author

thh0613 commented Dec 29, 2018

我查到原因了,在WXViewUpdateService.java这个类,内部类ContentOffsetYUpdater 实现update方法时,切换到主线程然后更新UI,这里是用handle发送message,那么会有一帧(16ms,demo的延迟是20ms)的延迟。如果想要实现两个scroll联动,肯定会持续更新,即肯定会持续发送消息。所以就会另一个scroller会滞后。用原生做了一个例子,

 private final RecyclerView.OnScrollListener mLayerOSL = new MyOnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, final int dx, final int dy) {
            super.onScrolled(recyclerView, dx, dy);
            // 当楼层列表滑动时,单元(房间)列表也滑动

          /*  mHandler.post(new Runnable() {
                @Override
                public void run() {
                    mRvRoom.scrollBy(dx, dy);
                }
            });*/

            mRvRoom.scrollBy(dx,dy);
        }
    };

如果我打开注释,在handle内部更新,就会造成这两个列表联动的不一致。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants