I am using react-full-page
and it's working almost fine but there are 2 problems
<a href='#someId'>Go There</a>
it is going but after scroll it is returning to where he was before the clickhttp://localhost:3000/#someIdWhereIWantThePageToBeOpened
it is staying in the top even when I have disabled scroll by disableScroll.on();
Any suggestions how to fix them? Thanks ahead
const [fullTog, setFullTog] = useState('normal');
let hrefPosition = window
.location
.href
.substring(window.location.href.indexOf("#") + 1, window.location.href.length);
disableScroll.on();
useEffect(() => {
if (document.getElementById(hrefPosition) !== null) {
disableScroll.off();
let ind = 0;
let toDeGoTo = setInterval(function () {
if (ind === 10) {
clearInterval(toDeGoTo);
disableScroll.off();
};
document
.getElementById(hrefPosition)
.scrollIntoView({behavior: 'smooth'});
ind++;
console.log(ind);
}, 200);
} else {
console.log(document.getElementById(hrefPosition));
setTimeout(function () {
disableScroll.off();
}, 2000);
}
setTimeout(() => {
setFullTog('full-page');
disableScroll.off();
}, 2000);
}, [])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.