window
Small wrappers around common window operations — opening/closing/focusing
windows, scrolling, reloading, and reading or watching viewport size.
Import: @rtorcato/browser-common/window
Example
import {
openWindow,
closeWindow,
focusWindow,
blurWindow,
scrollToTop,
scrollToBottom,
reloadWindow,
getWindowSize,
onWindowResize,
} from '@rtorcato/browser-common/window'
openWindow('https://example.com', '_blank')
scrollToTop('smooth')
const { width, height } = getWindowSize()
const off = onWindowResize(() => console.log(window.innerWidth))
off()
Exports
openWindow(url, target?, features?)—window.open; returns the newWindowornullif blockedcloseWindow()— closes the current windowfocusWindow()— focuses the current windowblurWindow()— blurs the current windowscrollToTop(behavior?)— scrolls to the top ('auto'or'smooth')scrollToBottom(behavior?)— scrolls todocument.body.scrollHeightreloadWindow()— reloads the current pagegetWindowSize()—{ width, height }frominnerWidth/innerHeightonWindowResize(callback)— subscribe to resize; returns an unsubscribe function
See the API reference for full signatures.