web-browser-window
v0.2.2
Published
Web browser window
Downloads
6
Maintainers
Readme
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.
- Doesn't work in iOS Safari:
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.
- Works in iOS Safari:
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.
- Doesn't work in iOS Safari:
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 DOMElement
into view.- Available
options
:duration
— (required) Scroll animation duration.
- Available
async enterFullScreen(element: Element): boolean
— Enters fullscreen mode forelement
. Returnstrue
if succeeded, throws an error otherwise.async exitFullScreen(): boolean
— Exits fullscreen mode. Returnstrue
if succeeded, throws an error otherwise.async toggleFullScreen(element: Element): boolean
— Toggles fullscreen mode forelement
. Returnstrue
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 theelement
is currently in fullscreen mode.getFullScreenElement(): Element?
— Returns the element that is currently in fullscreen mode.onFullScreenChange(listener)
— Listens to fullscreen mode enter/exit. Thelistener
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.