Answer the question
In order to leave comments, you need to log in
Loading content on income until the end of the block?
or at least 70% so that the height of the scroll is passed before the callback is called
Answer the question
In order to leave comments, you need to log in
import React, { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import Home from './pages/Home';
const App = () => {
const dispatch = useDispatch();
const { data } = useSelector((store) => store);
const [allowScroll, setAllowScroll] = useState(true);
const scrolling = () => {
const height = Math.max(
document.body.clientHeight,
document.documentElement.clientHeight
);
if (
window.pageYOffset > height * 0.75 ||
window.pageYOffset > height - 2000
) {
if (allowScroll) {
setAllowScroll(() => false);
setTimeout(() => {
setAllowScroll(() => true);
}, 2000);
dispatch({
type: 'DISPATCH',
});
}
}
};
return (
<div onWheel={scrolling}>
<Home />
</div>
);
};
export default App;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question