Skip to content

Commit

Permalink
Use ScrollToOptions for smooth scrolling if supported (mastodon#11207)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and hiyuki2578 committed Oct 2, 2019
1 parent 7c85f5e commit c123873
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/javascript/mastodon/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 comments on commit c123873

Please sign in to comment.