Skip to content

Updated event

Murhaf Sousli edited this page Oct 12, 2023 · 3 revisions

The NgScrollbar component has an output (updated) which emits when:

  • After its view is initialized
  • Setting new options (_e.g. an input is changed)
  • Resize sensor emitted (e.g. the content size is changed)

Example: Check when content becomes scrollable

<ng-scrollbar #scrollbar="ngScrollbar" (updated)="onScrollbarUpdate(scrollbar.state)"></ng-scrollbar>
onScrollbarUpdated(state: NgScrollbarState) {
  if (state.isVerticallyScrollable) {
    console.log('Scrollable');
  } else {
    console.log('Not Scrollable');
  }
}

Here is a demo stacbklitz