Wait for initial page to be rendered before scrolling it into view (#696)
The ResizeObserver triggers the first time when the element has a height of 0, which apparently did not work with scrolling it into view.
Due to immediately disconnecting the observer, the next resize event, which would successfully scroll the page into view, was never handled
Regression introduced with 0c1abebaf4
This commit is contained in:
@@ -114,6 +114,10 @@ export function HorizontalPager(props: IReaderProps) {
|
||||
}
|
||||
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
if (!initialPageElement.offsetHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
initialPageElement.scrollIntoView({ inline: 'center' });
|
||||
resizeObserver.disconnect();
|
||||
});
|
||||
|
||||
@@ -172,6 +172,10 @@ export function VerticalPager(props: IReaderProps) {
|
||||
}
|
||||
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
if (!initialPageElement.offsetHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
initialPageElement.scrollIntoView();
|
||||
resizeObserver.disconnect();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user