* fix: update to latest sapper fixes #416 * fix error and debug pages * requestIdleCallback makes column switching feel way nicer than double rAF * add export feature * add better csp info * workaround for sapper sub-page issue * clarify in readme about exporting * fix now config * switch from rIC to triple raf * style-loader is no longer used * update theming guide
24 lines
543 B
JavaScript
24 lines
543 B
JavaScript
import debounce from 'lodash-es/debounce'
|
|
|
|
const DEBOUNCE_DELAY = 700
|
|
|
|
const listeners = new Set()
|
|
|
|
if (process.browser && process.env.NODE_ENV !== 'production') {
|
|
window.resizeListeners = listeners
|
|
}
|
|
|
|
if (process.browser) {
|
|
window.addEventListener('resize', debounce(() => {
|
|
console.log('resize')
|
|
listeners.forEach(listener => listener())
|
|
}, DEBOUNCE_DELAY))
|
|
}
|
|
|
|
export function registerResizeListener (listener) {
|
|
listeners.add(listener)
|
|
}
|
|
|
|
export function unregisterResizeListener (listener) {
|
|
listeners.delete(listener)
|
|
}
|