diff --git a/src/main.js b/src/main.js index 940d882..9efb74a 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,6 @@ import {generatePrivateKey, getEventHash, getPublicKey, nip19, signEvent} from 'nostr-tools'; import {zeroLeadingBitsCount} from './utils/crypto'; -import {elem, elemCanvas, elemShrink, parseTextContent} from './utils/dom'; +import {elem, elemCanvas, elemShrink, lockScroll, parseTextContent, unlockScroll} from './utils/dom'; import {bounce, dateTime, formatTime} from './utils/time'; import {getHost, getNoxyUrl, isWssUrl} from './utils/url'; import {sub24hFeed, subNote, subProfile} from './subscriptions' @@ -463,9 +463,6 @@ function appendReplyForm(el) { requestAnimationFrame(() => writeInput.focus()); } -const lockScroll = () => document.body.style.overflow = 'hidden'; -const unlockScroll = () => document.body.style.removeProperty('overflow'); - let fitlerDifficulty = JSON.parse(localStorage.getItem('filter_difficulty')) ?? 0; const filterDifficultyInput = document.querySelector('#filterDifficulty'); const filterDifficultyDisplay = document.querySelector('[data-display="filter_difficulty"]'); diff --git a/src/utils/dom.ts b/src/utils/dom.ts index 7b3c41b..06b8cd0 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -56,6 +56,12 @@ export const elem = ( return el; }; +/** freeze global page scrolling */ +export const lockScroll = () => document.body.style.overflow = 'hidden'; + +/** free global page scrolling */ +export const unlockScroll = () => document.body.style.removeProperty('overflow'); + export const isValidURL = (url: URL) => { if (!['http:', 'https:'].includes(url.protocol)) { return false;