mirror of
https://github.com/dzeiocom/FormManager.git
synced 2025-06-07 16:49:56 +00:00
Added TextAreaInput for textarea resizing
Signed-off-by: Florian Bouillon <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
267aba9c8f
commit
c8d71bb516
24
src/modules/TextAreaInput.ts
Normal file
24
src/modules/TextAreaInput.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import InputIdentity from "./Interfaces/InputIdentity"
|
||||||
|
import DefaultInput from "./DefaultInput"
|
||||||
|
import FormManager from "../FormManager"
|
||||||
|
|
||||||
|
export default class TextAreaInput extends DefaultInput {
|
||||||
|
|
||||||
|
public constructor(element: HTMLElement, form: FormManager) {
|
||||||
|
super(element, form)
|
||||||
|
element.style.resize = 'none'
|
||||||
|
const event = () => {
|
||||||
|
element.style.minHeight = "5px"
|
||||||
|
element.style.minHeight = `calc(2em + ${element.scrollHeight+5}px)`
|
||||||
|
}
|
||||||
|
;(element as HTMLTextAreaElement).addEventListener('keydown', event)
|
||||||
|
;(element as HTMLTextAreaElement).addEventListener('keypress', event)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static identity: InputIdentity = {
|
||||||
|
input: TextAreaInput,
|
||||||
|
tagName: 'textarea',
|
||||||
|
attributes: 'data-autoresize'
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user