不监听iOS上的滚动事件

时间:2018-12-27 08:41:43

标签: javascript ios iframe

我的程序是这样工作的,我将滚动侦听器放在从iFrame取出的主体上,并向上滚动一定的角度,然后将固定的过滤器隐藏在所有设备的网站标题中android它可以工作,但是没有ios,无论我滚动多少过滤器它都不会隐藏,感觉就像没有在iPhone上听到滚动事件。我无法在两天内解决这个问题!

componentDidMount() {
    let body = iframe.getDocument().body;
    body.addEventListener('scroll', this.scrollToFilter)
    this.setState({body})
}

scrollToFilter = (e) => {
    if(this.state.viewFilter && e.target.scrollTop > 180){
        this.setState({viewFilter:false})
    }

    if(!this.state.viewFilter && e.target.scrollTop < 160){
        this.setState({viewFilter:true})
    }
}



body {
color: @font-general-color;
background-color: @body-background-color;
font-size: @font-general-size;
.media-xs({font-size: @font-general-responsive-size;});
font-family: @font-general-name;
-webkit-overflow-scrolling: touch;
}

html,body {
height: 100vh;
width: 100vw;
overflow: auto;
position:relative;
}

在iPhone上无法正常工作,好像没有捕获滚动事件

滚动位置固定时隐藏的过滤器

0 个答案:

没有答案