2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Updated AdminX scroll margin to work consistently on different screens (#18127)

refs https://github.com/TryGhost/Product/issues/3832
This commit is contained in:
Jono M 2023-09-14 07:31:38 +01:00 committed by GitHub
parent cb532ea819
commit a9f9f6121a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,13 +12,15 @@ const ScrollSectionContext = createContext<ScrollSectionContextData>({
export const useScrollSectionContext = () => useContext(ScrollSectionContext);
const scrollMargin = 193;
const scrollToSection = (element: HTMLDivElement) => {
const root = document.getElementById('admin-x-root')!;
const top = element.getBoundingClientRect().top + root.scrollTop;
root.scrollTo({
behavior: 'smooth',
top: top - 193
top: top - scrollMargin
});
};
@ -61,7 +63,7 @@ export const ScrollSectionProvider: React.FC<{
return newSections;
});
}, {
rootMargin: '-20% 0px -40% 0px'
rootMargin: `-${scrollMargin - 10}px 0px -40% 0px`
}), []);
const updateSection = useCallback((id: string, element: HTMLDivElement) => {