utils: move updateelemheight to dom utils

pull/72/head
OFF0 2 years ago
parent ca4594a7e7
commit efda7737c8
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -1,6 +1,6 @@
import {generatePrivateKey, getPublicKey, nip19, signEvent} from 'nostr-tools';
import {zeroLeadingBitsCount} from './utils/crypto';
import {elem, elemCanvas, elemShrink, parseTextContent} from './utils/dom';
import {elem, elemCanvas, elemShrink, parseTextContent, updateElemHeight} from './utils/dom';
import {bounce, dateTime, formatTime} from './utils/time';
import {getHost, getNoxyUrl, isWssUrl} from './utils/url';
import {powEvent} from './system';
@ -561,17 +561,6 @@ writeInput.addEventListener('input', () => {
});
writeInput.addEventListener('blur', () => sendStatus.textContent = '');
function updateElemHeight(el) {
el.style.removeProperty('height');
if (el.value) {
el.style.paddingBottom = 0;
el.style.paddingTop = 0;
el.style.height = el.scrollHeight + 'px';
el.style.removeProperty('padding-bottom');
el.style.removeProperty('padding-top');
}
}

@ -162,3 +162,17 @@ export const elemShrink = (el: HTMLElement) => {
shrink.addEventListener('animationend', () => shrink.remove(), {once: true});
return shrink;
};
export const updateElemHeight = (
el: HTMLInputElement | HTMLTextAreaElement
) => {
el.style.removeProperty('height');
if (el.value) {
el.style.paddingBottom = '0';
el.style.paddingTop = '0';
el.style.height = el.scrollHeight + 'px';
el.style.removeProperty('padding-bottom');
el.style.removeProperty('padding-top');
}
};

Loading…
Cancel
Save