utils: move lock and unlock scroll functions to utils

pull/72/head
OFF0 1 year ago
parent 70fb0da35a
commit 23188c161f
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -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"]');

@ -56,6 +56,12 @@ export const elem = <Name extends keyof HTMLElementTagNameMap>(
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;

Loading…
Cancel
Save