Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#46383 [react-select] Fix animatedScrollTo …
Browse files Browse the repository at this point in the history
…method by @Methuselah96

* Fix animatedScrollTo method

* Add test

* Add change

* Add file

* Fix
  • Loading branch information
Methuselah96 authored and danielrearden committed Sep 22, 2020
1 parent ee8e095 commit ed8bf83
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions types/react-select/src/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export function getScrollParent(element: React.Ref<any>): Element;
// ------------------------------

export function animatedScrollTo(
element: Element,
element: HTMLElement | typeof window,
to: number,
duration: number,
callback: (element: Element) => void
duration?: number,
callback?: (element: HTMLElement | typeof window) => void
): void;

// Scroll Into View
Expand Down
7 changes: 7 additions & 0 deletions types/react-select/test/animatedScrollTo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { animatedScrollTo } from "react-select/src/utils";

// Inspired by https://github.com/JedWatson/react-select/blob/master/docs/App/PageNav.js#L70
const el = document.querySelector<HTMLElement>('#test');
if (el && el.offsetTop) {
animatedScrollTo(window, el.offsetTop);
}
1 change: 1 addition & 0 deletions types/react-select/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"files": [
"index.d.ts",
"test/animatedScrollTo.ts",
"test/data.ts",
"test/styled-components.tsx",
"test/AtlaskitDummy.ts",
Expand Down

0 comments on commit ed8bf83

Please sign in to comment.