Detect ScrollView has reached the end

前端 未结 7 1109
栀梦
栀梦 2020-12-23 21:32

I have a Text with long text inside a ScrollView and I want to detect when the user has scrolled to the end of the text so I can enable a button.

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 22:07

    For Horizontal ScrollView (e.g. Carousels) replace isCloseToBottom function with isCloseToRight

    isCloseToRight = ({ layoutMeasurement, contentOffset, contentSize }) => {
        const paddingToRight = 20;
        return layoutMeasurement.width + contentOffset.x >= contentSize.width - paddingToRight;
    };
    

提交回复
热议问题