Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc