Skip to content

Instantly share code, notes, and snippets.

@elgervb
Created February 13, 2019 09:14
Show Gist options
  • Save elgervb/850e01f723bb85696655b00868051652 to your computer and use it in GitHub Desktop.
Save elgervb/850e01f723bb85696655b00868051652 to your computer and use it in GitHub Desktop.
import { Injectable } from "@angular/core";
/**
* Angular scroll service
*/
@Injectable({
providedIn: "root"
})
export class ScrollService {
constructor() { }
/**
* Scrolls an element into view and provide optional scroll options
*
* See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
*/
scrollToElement(element: HTMLElement, options?: ScrollIntoViewOptions) {
element.scrollIntoView(options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment