web-browser-window
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

web-browser-window

Web browser window utilities.

Install

npm install web-browser-window --save

Use

  • getViewportWidth(): number — Returns viewport width. Accounts for page zoom.

    • Doesn't work in iOS Safari:
      • Doesn't account for page zoom.
  • getViewportWidthWithScrollbar(): number — Returns viewport width, including the vertical scrollbar width, if it's shown. Accounts for page zoom.

    • Works in iOS Safari:
      • Doesn't account for page zoom.
  • getViewportHeight(): number — Returns viewport height. Accounts for page zoom.

    • Doesn't work in iOS Safari:
      • Doesn't account for the top URL bar.
      • Doesn't account for the bottom actions bar.
      • Doesn't account for page zoom.
  • getViewportHeightWithScrollbar(): number — Returns viewport height, including the horizontal scrollbar height, if it's shown. Accounts for page zoom.

    • Works in iOS Safari
  • getVerticalScrollBarWidth(): number — Returns the width of the vertical scroll bar.

    • Doesn't work in iOS Safari
  • async scrollIntoView(element: Element, options: object) — Scrolls a DOM Element into view.

    • Available options:
      • duration — (required) Scroll animation duration.
  • async enterFullScreen(element: Element): boolean — Enters fullscreen mode for element. Returns true if succeeded, throws an error otherwise.

  • async exitFullScreen(): boolean — Exits fullscreen mode. Returns true if succeeded, throws an error otherwise.

  • async toggleFullScreen(element: Element): boolean — Toggles fullscreen mode for element. Returns true if succeeded, throws an error otherwise.

  • isFullScreen(): boolean — Tells whether the page is currently in fullscreen mode.

  • isFullScreenSupported(): boolean — Tells whether fullscreen mode is supported.

  • isFullScreenElement(element: Element): boolean — Tells whether the element is currently in fullscreen mode.

  • getFullScreenElement(): Element? — Returns the element that is currently in fullscreen mode.

  • onFullScreenChange(listener) — Listens to fullscreen mode enter/exit. The listener doesn't receive any arguments.

Test

npm test

GitHub Ban

On March 9th, 2020, GitHub, Inc. silently banned my account (erasing all my repos, issues and comments) without any notice or explanation. Because of that, all source codes had to be promptly moved to GitLab. The GitHub repo is now only used as a backup (you can star the repo there too), and the primary repo is now the GitLab one. Issues can be reported in any repo.

License

MIT

Package Sidebar

Install

npm i web-browser-window

Weekly Downloads

0

Version

0.2.2

License

MIT

Unpacked Size

13.5 kB

Total Files

19

Last publish

Collaborators

  • catamphetamine