Scrolling doesnt work correctly in Sidebar #1051
-
Hi, It scrolls the drawer very wirdly, all hightlight are on the wrong item. Thansk for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 11 replies
-
Hey @BennyAlex I couldn't load the codesandbox. Is it public? |
Beta Was this translation helpful? Give feedback.
-
Hey @BennyAlex So, to start, the body is shorter than the sidebar, which is weird. Set a Add this function somewhere in your code: function waitForScrollEnd() {
let lastChangedFrame = 0;
let lastX = window.scrollX;
let lastY = window.scrollY;
return new Promise<void>((resolve) => {
function tick(frames: number) {
if (frames >= 500 || frames - lastChangedFrame > 20) {
resolve();
} else {
if (window.scrollX != lastX || window.scrollY != lastY) {
lastChangedFrame = frames;
lastX = window.scrollX;
lastY = window.scrollY;
}
requestAnimationFrame(tick.bind(null, frames + 1));
}
}
tick(0);
});
} And inside the callback: if (data.action === ACTIONS.UPDATE && data.lifecycle === LIFECYCLE.TOOLTIP) {
waitForScrollEnd().then(() => {
window.dispatchEvent(new Event("resize"));
});
} |
Beta Was this translation helpful? Give feedback.
-
It's working for me. joyride-mui.mp4 |
Beta Was this translation helpful? Give feedback.
-
Hey @BennyAlex |
Beta Was this translation helpful? Give feedback.
Hey @BennyAlex
So, to start, the body is shorter than the sidebar, which is weird. Set a
min-height: 100vh
to fix that.But even the minHeight, the sidebar scrolls too when the Joyride is scrolling, which causes the spotlight to be rendered in the wrong position.
I could fix it by dispatching a resize event when all the scrolling ends. I'm not sure if there's a better option, but it works.
Add this function somewhere in your code: