Skip to content

Commit

Permalink
chore: restore scroll into view from main
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlj95 committed Nov 29, 2024
1 parent dcbfbd5 commit 5312bdd
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/app/common/scroll-into-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { inject, InjectionToken } from '@angular/core'
import { PLATFORM_SERVICE } from '@/common/platform.service'
import { noop } from 'rxjs'

const scrollIntoView: (element: HTMLElement) => void = (element: HTMLElement) =>
const scrollIntoView: ScrollIntoView = (element: HTMLElement) =>
element.scrollIntoView && element.scrollIntoView({ block: 'nearest' })
export type ScrollIntoView = (element: HTMLElement) => void

/**
* @visibleForTesting
*
Expand All @@ -15,12 +17,9 @@ const scrollIntoView: (element: HTMLElement) => void = (element: HTMLElement) =>
* As workaround, creating another provider for it when testing using the same factory.
* That's why it's exported
*/
export const SCROLL_INTO_VIEW_FACTORY: () => (
element: HTMLElement,
) => void = () => (inject(PLATFORM_SERVICE).isBrowser ? scrollIntoView : noop)
export const SCROLL_INTO_VIEW = new InjectionToken<
(element: HTMLElement) => void
>(
export const SCROLL_INTO_VIEW_FACTORY: () => ScrollIntoView = () =>
inject(PLATFORM_SERVICE).isBrowser ? scrollIntoView : noop
export const SCROLL_INTO_VIEW = new InjectionToken<ScrollIntoView>(
/* istanbul ignore next */
isDevMode ? 'ScrollIntoView' : 'SIV',
{
Expand Down

0 comments on commit 5312bdd

Please sign in to comment.