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:
parent
cb532ea819
commit
a9f9f6121a
1 changed files with 4 additions and 2 deletions
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue