Skip to content
Snippets Groups Projects
Commit 84ff3938 authored by ThibG's avatar ThibG Committed by Eugen Rochko
Browse files

Use ScrollToOptions for smooth scrolling if supported (#11207)

parent 4f5b221b
No related branches found
No related tags found
No related merge requests found
......@@ -26,5 +26,7 @@ const scroll = (node, key, target) => {
};
};
export const scrollRight = (node, position) => scroll(node, 'scrollLeft', position);
export const scrollTop = (node) => scroll(node, 'scrollTop', 0);
const isScrollBehaviorSupported = 'scrollBehavior' in document.documentElement.style;
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);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment