How to stop touch event propagation in React-Native

前端 未结 5 1124
南笙
南笙 2021-02-05 09:12

I have a scrollview with a grid of images when I long press on an image I’d like to stop propagating the mouse events to the scrollview and just monitor the movements. With the

5条回答
  •  逝去的感伤
    2021-02-05 09:54

    I solved this issue by wrap my press event with class method that set inner variable to true, then did the original logic, and after it finished, set again the inner variable to false. Then, you can wrap your container component event handler to check if inner variable set to true or false. for example:

    
        
            
        
    
    
    doSomething1() {
        this.preventDefault = true;
        doSomeLogic();
        this.preventDefault = false;
    }
    
    doSomething2() {
        if(!this.preventDefault) {
    
        }
    }
    

提交回复
热议问题