mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-12-20 12:19:27 +00:00
[Glitch] Use ScrollToOptions for smooth scrolling if supported
Port 84ff393842
to glitch-soc
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
This commit is contained in:
parent
c5495a448c
commit
46829e009e
|
@ -26,5 +26,7 @@ const scroll = (node, key, target) => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const scrollRight = (node, position) => scroll(node, 'scrollLeft', position);
|
const isScrollBehaviorSupported = 'scrollBehavior' in document.documentElement.style;
|
||||||
export const scrollTop = (node) => scroll(node, 'scrollTop', 0);
|
|
||||||
|
export const scrollRight = (node, position) => isScrollBehaviorSupported ? node.scrollTo({ left: position, behavior: 'smooth' }) : scroll(node, 'scrollLeft', position);
|
||||||
|
export const scrollTop = (node) => isScrollBehaviorSupported ? node.scrollTo({ top: 0, behavior: 'smooth' }) : scroll(node, 'scrollTop', 0);
|
||||||
|
|
Loading…
Reference in a new issue