Skip to content

A Node module to retrieve the current style of scrollbar in macOS (“overlay” or “legacy”)

License

Notifications You must be signed in to change notification settings

pulsar-edit/get-scrollbar-style

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get-scrollbar-style

This package is a targeted replacement for scrollbar-style for use in Pulsar.

The original purpose of scrollbar-style was to allow the user to

  1. retrieve the current scrollbar style on macOS; and
  2. find out when that setting changes.

These days, task 2 is (strangely) easier than task 1 for an Electron app. Electron’s systemPreferences API allows us to subscribe to the needed NSPreferredScrollerStyleDidChangeNotification notification event that is issued when the user changes this setting… but there appears to be no imperative way of obtaining the same information.

This package exposes a single method that, when called, uses NSScroller.preferredScrollerStyle to return the current scrollbar style on macOS. The return value will be one of

  • overlay (for scrollbars that appear atop the content when you scroll and disappear when you stop scrolling),
  • legacy (for traditional scrollbars that are always visible and have their own track), or
  • unknown (neither of the above; this will only be possible if macOS adds more scrollbar modes in the future).

On Windows and Linux, this package exposes the same function, but the return value is always legacy.

const getScrollbarStyle = require('get-scrollbar-style')
console.log(getScrollbarStyle()) // => 'legacy' or 'overlay'

About

A Node module to retrieve the current style of scrollbar in macOS (“overlay” or “legacy”)

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published