滑动到底部才允许关闭
const [disabled, setDisabled] = useState(true);
useEffect(() => {
if (!visible) {
setDisabled(true);
return;
}
const scrollDiv = document.getElementById('terms-and-condition-content');
scrollDiv?.addEventListener('scroll', () => {
setDisabled(prevState => prevState && scrollDiv?.scrollTop + scrollDiv?.clientHeight !== scrollDiv?.scrollHeight);
});
}, [visible]);
body:
<div>
<div id="terms-and-condition-content">
test
</div>
<div disabled={disabled}>
button
<div>
<div>