Skip to content

Commit

Permalink
Merge pull request #1 from wysher/fix/window-error-on-ssr
Browse files Browse the repository at this point in the history
fix: crash on SSR with 'window is not defined'
  • Loading branch information
wysher authored May 5, 2020
2 parents 76f2f81 + 1326c15 commit 79f6b74
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/Overlay.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@
$: openedState = isOpen && hasParent && hasContent;
function addListeners() {
if (!window) return;
window.addEventListener('resize', updatePosition);
if (closeOnScroll) window.addEventListener('scroll', close);
else if (updateOnScroll) window.addEventListener('scroll', updatePosition);
}
function removeListeners() {
if (!window) return;
window.removeEventListener('resize', updatePosition);
window.removeEventListener('scroll', updatePosition);
window.removeEventListener('scroll', close);
Expand Down

0 comments on commit 79f6b74

Please sign in to comment.