Przeglądaj źródła

Use ScrollToOptions for smooth scrolling if supported (#11207)

master^2
ThibG 4 lat temu
committed by Eugen Rochko
rodzic
commit
84ff393842
1 zmienionych plików z 4 dodań i 2 usunięć
  1. +4
    -2
      app/javascript/mastodon/scroll.js

+ 4
- 2
app/javascript/mastodon/scroll.js Wyświetl plik

@@ -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);

Ładowanie…
Anuluj
Zapisz