调整 选择时, 在对话框里面(Resize when selecting

2019-10-22 22:27发布

resizeable_dialog.html

<link rel="import" href="../../packages/polymer/polymer.html">

<link rel="import" href="../../packages/paper_elements/paper_dialog.html">
<link rel="import" href="../../packages/paper_elements/paper_button.html">
<link rel="import" href="../../packages/paper_elements/paper_tabs.html">
<link rel="import" href="../../packages/paper_elements/paper_tab.html">
<link rel="import" href="../../packages/paper_elements/paper_icon_button.html">
<link rel="import" href="../../packages/core_elements/core_toolbar.html">
<link rel="import" href="../../packages/core_elements/core_pages.html">

<polymer-element name="resizeable-dialog">
  <template>
    <style>
      :host {
        display: block;
      }
    </style>
    <paper-button on-click="{{open}}">Open Dialog</paper-button>    
    <paper-dialog id="dialog" transition="core-transition-bottom" backdrop>
      <paper-tabs selected="{{selected}}">
        <paper-tab>Page 1</paper-tab>
        <paper-tab>Page 2</paper-tab>
      </paper-tabs>
      <section>
        <core-pages selected="{{selected}}">
          <div style="width: 100px; height: 100px;">
            <div>Page 1: 100x100</div>
            <paper-button on-click="{{notifyResize}}">Call 'notifyResize'</paper-button>          
          </div>
          <div style="width: 400px; height: 400px;">
            <div>Page 2: 400x400</div>
            <paper-button on-click="{{notifyResize}}">Call 'notifyResize'</paper-button>          
          </div>
        </core-pages>
      </section>
    </paper-dialog>

  </template>
  <script type="application/dart" src="resizeable_dialog.dart"></script>
</polymer-element>

resizeable_dialog.dart

library resizable_dialog;

import 'package:polymer/polymer.dart';
import 'package:paper_elements/paper_dialog.dart';

@CustomTag('resizeable-dialog')
class ResizeableDialog extends PolymerElement {

  ResizeableDialog.created() : super.created();
  @observable int selected = 0;

  notifyResize() {
    $['dialog'] as PaperDialog..notifyResize();
    print('"notifyResize" called.');
  }

  open() {
    $['dialog'] as PaperDialog..open();
  }

}

这是我的对话,我觉得你得到使用TabBar的想法。 我的问题是, <paper-dialog>在某些点计算其尺寸被上映之前。 但是,由于我<core-pages>可以有不同的宽度和高度,我必须调整每当用户选择一个选项卡以确保该对话框中,当前选择的页的全部内容是可见的。

该方法<paper-dialog>.notifyResize()中不达特某种原因存在。 它规定在这里 ,中paper-elements文档,但我不能调用它,因为它不DART中。

我怎样才能做到这一点? 我怎么能要求的对话框重新测量它的尺寸?

Answer 1:

您应该能够解决像

import 'dart:js' as js;
...
new js.JsObject.fromBrowserObject($['dialog'])
   .callMethod('notifyResize', []);

要么

import 'package:paper_elements/paper_dialog.dart';
...
($['dialog'] as PaperDialog).jsElement
    .callMethod('notifyResize', []);

请创建在github.com/dart-lang/paper-elements回购一份错误报告(或核心元素,因为我觉得这个功能应该从核心覆盖继承)



文章来源: Resize when selecting inside the dialog