Sha256: 55040cb37d15535be582f0b6aba6e9ff279cd1ab1607be0c5a9c26f1082ded1f

Contents?: true

Size: 852 Bytes

Versions: 22

Compression:

Stored size: 852 Bytes

Contents

import { CocoComponent } from "@assets/js/coco/component";

export default CocoComponent("seamlessTextarea", () => {
  return {
    height: null,
    observer: null,
    value: null,

    options: ["multiline", "focus"],

    init() {
      this.value = this.$refs.textarea.value;
      this.$nextTick(() => {
        this.onResize();

        if (this.$options.focus) {
          this.$refs.textarea.focus();
          this.$refs.textarea.selectionStart = this.$refs.textarea.value.length;
        }
      });
    },

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

      if (textarea) {
        textarea.style.height = "4px";
        const newHeight = textarea.scrollHeight;
        textarea.style.height = `${newHeight}px`;

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
coveragebook_components-0.16.0 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.15.0 app/components/coco/utilities/seamless_textarea/seamless_textarea.js