UNPKG

viewport-funcs

Version:

A very limited subset of viewport functions I use every day

19 lines (15 loc) 430 B
const cache = require('./cache') module.exports = function() { if (Date.now() - cache.rect.prev > 10) { cache.rect.data = { width: window.innerWidth, height: window.innerHeight, left: window.scrollX, top: window.scrollY, right: window.scrollX + window.innerWidth, bottom: window.scrollY + window.innerHeight } cache.rect.prev = Date.now() } return cache.rect.data }