Sha256: 2858e8449b9b4dbb560378a731788627f5fb47655a0da8c06117eb9e826b86b9

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

import { CocoComponent } from "@js/coco";
import { withSizeObserver } from "@js/base/mixins";

export default CocoComponent("appSeamlessTextarea", () => {
  return {
    use: [withSizeObserver()],

    height: null,
    observer: null,
    value: null,

    get singleLine() {
      return this.assertData("multiline", "false");
    },

    init() {
      this.value = this.$refs.textarea.value;
    },

    onResize() {
      const textarea = this.$refs.textarea;

      if (textarea) {
        const styles = window.getComputedStyle(textarea);
        const fontSize = styles.getPropertyValue("font-size");

        textarea.style.height = "4px";
        let newHeight = textarea.scrollHeight - parseInt(fontSize, 10) * 0.16;
        textarea.style.height = `${newHeight}px`;

        if (this.height !== newHeight) {
          this.height = newHeight;
        }
      }
    },
  };
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coveragebook_components-0.5.0 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js