向 vaadin-split-layout 元素中的元素添加 iron-resize

Adding iron-resize to elements within a vaadin-split-layout element

我正在使用 vaadin-split-layout 元素垂直分割屏幕。

我将以下内容作为我应用程序样式的一部分。

        .flex-horizontal {
          @apply(--layout-horizontal);
        }
        .flex-vertical {
          @apply(--layout-vertical);
        }
        .flexchild {
          @apply(--layout-flex);
        }

以下是vaadin-split-layout。 easymetahub-d3-graph 支持 IronResizeableBehavior。我需要 ID 为 thetopd3graphcontainer 的元素来响应铁调整大小行为,因此 easymetahub-d3-graph 响应 vaadin-split-layout.[=19 中的铁调整大小=]

          <vaadin-split-layout orientation="vertical">
          <div id="thetop" class="card flexchild">
            <vaadin-horizontal-layout>
              <div class="flex-vertical" style="margin-top: 20px; margin-bottom: 70px;">
                <paper-icon-button class="command" id="changeButton" title="Save changes" icon="save" disabled$="[[!changelog.length]]" on-tap="openSaveChanges"></paper-icon-button>
                <paper-icon-button class="command" title="Harvest Data" src="images/app-icon-32.png" on-tap="openHarvestData"></paper-icon-button>
                <paper-icon-button class="command" title="Monitor Harvests" icon="watch-later" on-tap="openMonitorHarvest"></paper-icon-button>
                <div class="flexchild"></div>
                <div class="rootnode">Root</div>
                <div class="dependentnode">Dependent</div>
                <div class="referencenode">Reference</div>
                <div class="unassignednode">Unassigned</div>
              </div>
              <div id="d3graphcontainer" style="width: 100%; height: 50vh; min-height: 300px;">
                <easymetahub-d3-graph graph="[[result]]" selected-node="{{entitydetail}}" selected-link="{{selectedLink}}" changelog="{{changelog}}" class="flex-vertical"></easymetahub-d3-graph>
              </div>
            </vaadin-horizontal-layout>
          </div>
          <iron-pages id="ip" selected="0">
            <no-detail></no-detail>
            <entity-display entitydetail="{{entitydetail}}" changelog="{{changelog}}"></entity-display>
            <link-detail linkdetail="{{selectedLink}}"></link-detail>
          </iron-pages>
          </vaadin-split-layout>

我错过了什么?

我找到了解决办法。我在拆分的顶部放置了一个 vaadin-split-layout。

    <vaadin-split-layout orientation="vertical" style="height: 100%;">
      <vaadin-split-layout orientation="horizontal" style="height: 50%; min-height: 100px;">
        <iron-resize-div id="sidebar" class="flex-vertical"v style="min-width: 85px; max-width: 85px;">
          <paper-icon-button style="width: 85px;" class="command" id="changeButton" title="Save changes" icon="save" disabled$="[[!changelog.length]]" on-tap="openSaveChanges"></paper-icon-button>
          <paper-icon-button style="width: 85px;" class="command" title="Harvest Data" src="images/app-icon-32.png" on-tap="openHarvestData"></paper-icon-button>
          <paper-icon-button style="width: 85px;" class="command" title="Monitor Harvests" icon="watch-later" on-tap="openMonitorHarvest"></paper-icon-button>
          <div style="width: 85px;" class="flexchild"></div>
          <div class="rootnode" style="width: 85px;">Root</div>
          <div class="dependentnode" style="width: 85px;">Dependent</div>
          <div class="referencenode" style="width: 85px;">Reference</div>
          <div class="unassignednode" style="width: 85px;">Unassigned</div>
        </iron-resize-div>
        <easymetahub-d3-graph graph="[[result]]" selected-node="{{entitydetail}}" selected-link="{{selectedLink}}" changelog="{{changelog}}" class="flex-vertical"></easymetahub-d3-graph>
      </vaadin-split-layout>

以下列为iron-resize-div

  "use strict";
  import {html, PolymerElement} from '@polymer/polymer/polymer-element.js';
  import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
  import {IronResizableBehavior} from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';

  /**
   * @customElement
   * @polymer
   */
  class IronResizeDiv extends mixinBehaviors([IronResizableBehavior], PolymerElement) {

    static get template() {
      return html`
      <style>
        :host {
          display: block;
          height: 100%;
          width: 100%;
        }
        .general {
          width: 98%;
          height: 98%;
        }
      </style>
      <div class="general">
        <slot></slot>
      </div>
      `;
    }

    static get properties() {
      return {
      };
    }

    connectedCallback() {
      super.connectedCallback();
      this.addEventListener('iron-resize', this.onIronResize.bind(this));
    }

    onIronResize() {
      this.width = this.offsetWidth;
      this.height = this.offsetHeight;
      this.notifyResize();
    }



  }

  window.customElements.define('iron-resize-div', IronResizeDiv);

垂直拆分顶部的内容现在可以按照我的意愿工作了。