2014-10-09 40 views
1

當我使用紙張菜單按鈕創建帶有紙張項目的疊加層時,我注意到在首次打開時會計算生成的核心下拉大小。聚合物:模型更改時的核心下拉式疊加更新大小

當我然後更新自動綁定綁定的模板模型時,我確實會得到新的紙張項目,但覆蓋層的大小與第一次打開時的大小保持不變。

有沒有辦法在這種疊加層的模型變化上獲得自動調整大小?

這是我的代碼:

<div class="toolbar toolbar-1" layout horizontal center> 
    <paper-menu-button icon="settings-cell"> 
    <template repeat="{{devices}}"> 
     <paper-item>{{devicename}}</paper-item> 
    </template> 
    </paper-menu-button> 
</div> 

<script> 

scope = document.querySelector('template[is=auto-binding]'); 

scope.devices = [{"devicename": "No device"}]; 
</script> 

當我再手動更改scope.devices到[{"devicename": "No device"}, {"devicename": "Device 1"}]和已經開通前的菜單,我在疊加滾動。

回答

2

我得到的答案從IRC:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Hello World</title> 
    <script src="http://www.polymer-project.org/components/platform/platform.js"></script> 
    <link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html"> 
    <link rel="import" href="http://www.polymer-project.org/components/paper-item/paper-item.html"> 
    <link rel="import" href="http://www.polymer-project.org/components/paper-menu-button/paper-menu-button.html"> 
    <link rel="import" href="http://www.polymer-project.org/components/core-icons/core-icons.html"> 
    <polymer-element name="x-test"> 
    <template> 
     <h1>{{title}}</h1> 
     <paper-menu-button id="a" icon="menu"> 
     <template repeat="{{devices}}"> 
      <paper-item>{{devicename}}</paper-item> 
     </template> 
     </paper-menu-button> 
     <button on-tap="{{add}}">Add</button> 
    </template> 
    <script> 
     Polymer('x-test', { 
     devices: [{devicename: "abc"}, {devicename: "def"}], 
     add: function() { 
      this.devices.push({devicename: "more"}); 

      var el = this.querySelector("::shadow paper-menu-button::shadow core-dropdown::shadow core-dropdown-overlay"); 
      el.target.style.width = null; 
      el.target.style.height = null; 
     }, 
     created: function() { 
      this.title = document.title; 
     } 
     }); 
    </script> 
    </polymer-element> 
</head> 
<body> 
    <x-test></x-test> 
</body> 
</html> 

這似乎是在覈心下拉疊加的錯誤。重置target.style.width和height似乎可以使其工作。

+0

欲瞭解更多信息,請參閱以下票:https://github.com/Polymer/paper-dropdown/issues/2 – Christof 2015-02-26 12:31:07