Skip to content

Pointer Events

Murhaf Sousli edited this page Nov 20, 2019 · 10 revisions

Background: In version 4, we were using scrollbar's native element events for click, hover and drag functions. we had one tiny issue that we were unable to scroll when the mouse is over the scrollbar because it is blocking the viewport.

Background: In version 5, we changed that and used the viewport events for click, hover and drag functions


In version 7, we added 2 ways for detecting the pointer-events

<ng-scrollbar pointerEventsMethod="viewport || scrollbar">
  • pointerEventsMethod="viewport", will detect pointer events using viewport's mousemove, mousedown and mouseleave events.

  • pointerEventsMethod="scrollbar", will detect pointer events using scrollbar mousedown, mouseenter and mouseleave event.

In a nutshell, here are the pros and cons of each method with the [appearance] option:

Appearance ↓ viewport scrollbar
Standard
  • Only if both scrollbars appear, the content may overlap under the scrollbar
  • Scrolling over scrollbar works
  • The content never overlap under the scrollbars
  • Scrolling over scrollbar doesn't work
Compact
  • Content overlaps under the scrollbar as intended
  • Scrolling over scrollbar works
  • The content overlaps under the scrollbar as intended
  • Scrolling over scrollbar doesn't work

My recommendation: If scrolling over scrollbar isn't a big deal, then go with pointerEventsMethod="scrollbar".


Theoretically scrollbar method is more performant because viewport method checks if the pointer is over the scrollbars while the pointer is moving over the viewport.

But most of the time, there won't be any difference in performance unless you have a complex design. try both and see what best fits your app.

📌 Note

The pointer-events are disabled on mobile browsers by design. because there is no pointer 😄