You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
450 B

2 months ago
  1. // @flow
  2. import getWindowScroll from './getWindowScroll';
  3. import getWindow from './getWindow';
  4. import { isHTMLElement } from './instanceOf';
  5. import getHTMLElementScroll from './getHTMLElementScroll';
  6. import type { Window } from '../types';
  7. export default function getNodeScroll(node: Node | Window) {
  8. if (node === getWindow(node) || !isHTMLElement(node)) {
  9. return getWindowScroll(node);
  10. } else {
  11. return getHTMLElementScroll(node);
  12. }
  13. }