🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@moxy/grow-element-fn

Package Overview
Dependencies
Maintainers
21
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moxy/grow-element-fn

Update textarea height to its content with lines number customization

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
21
Created
Source

grow-element-fn

Update textarea height to its content with lines number customization.

Summary

Library to auto-grow and auto-shrink textarea to fit its content. Works perfect with vertical scrollbar.

Recomended textarea styles:
word-wrap: break-word;
white-space: pre-line;
line-height: 30px; // should be defined

Install via NPM

npm install --save grow-element-fn

Browser compatibility

ChromeFirefoxIEEDGESafariiOS SafariAndroidOpera MiniWindows Phone IE
yes5710+??+??

Usage

import growElementFn from 'grow-element-fn';
const textarea = document.getElementById("my-textarea");

function growTextarea() {
  growElementFn({
    el: textarea,
    minLines: 1,
    maxLines: 4,
    extraLine: true,
  });
}

growTextarea();
textarea.addEventListener('focus', growTextarea);
textarea.addEventListener('blur', growTextarea);
textarea.addEventListener('input', growTextarea);

Options:

el (Element, required): reference to DOM element.

minLines (Number = 1): minimum lines of textarea.

maxLines (Number = 0): maximum lines of textarea to display no scrollbar. If maxLines is 0 textarea won't have maximum lines limit.

extraLine (boolean = false): add extra line in the bottom of textarea. Usefull to remove content jumping on slow devices.

License: MIT

Keywords

textarea

FAQs

Package last updated on 09 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts