2016-03-04 20 views
1

下面是聚合物IronResizableBehavior演示改性的「調整大小」元件上被隱藏或不隱藏的,而不是對火描述的未隱藏的只是在窗口被調整大小。當調整窗口的大小事件觸發,但聚合物文檔(https://elements.polymer-project.org/elements/iron-resizable-behavior)表示:聚合物IronResizableBehavior鐵resize事件/在文檔

此事件會當他們變成具有被隱藏後顯示,由另一可調整大小的被解僱時做出了明確調整,或當該窗口已被調整大小。

因此,當我隱藏/取消隱藏下面的「x-puck」元素時,我希望事件也會被觸發。我究竟做錯了什麼?

<link rel="import" href="../../iron-resizable-behavior.html"> 
<link rel="import" href="../../../paper-button/paper-button.html"> 

<dom-module id="x-puck"> 
    <style> 
    </style> 

    <template> 

    <b>I'm an un-hidden element!</b> 

    </template> 

</dom-module> 

<script> 
    Polymer({ 

    is: 'x-puck', 

    behaviors: [ 
     Polymer.IronResizableBehavior 
    ], 

    listeners: { 
     'iron-resize': '_onIronResize' 
    }, 

    attached: function() { 
     this.async(this.notifyResize, 1); 
    }, 

    _onIronResize: function() { 
     alert('x-puck _onIronResize called!'); 
    } 
    }); 
</script> 


<dom-module id="x-app"> 
    <style> 
    </style> 

    <template> 
    <paper-button on-tap="showElement">Show</paper-button> 
    <paper-button on-tap="hideElement">Hide</paper-button> 

    <x-puck id="xPuck" hidden$="{{hide}}"></x-puck> 
    </template> 

</dom-module> 

<script> 
    Polymer({ 

    is: 'x-app', 

    behaviors: [ 
     Polymer.IronResizableBehavior 
    ], 

    properties: { 
     hide: { 
     type: Boolean, 
     value: true 
     } 
    }, 

    showElement: function() { 
     this.hide = false; 
    }, 

    hideElement: function() { 
     this.hide = true; 
    } 
    }); 
</script> 

回答

3

我快速度看的IronResizableBehavior的源代碼,並沒有看到任何會支持,實施,只要其CCS display性質發生變化,也將被調整的元素(它本質上是hidden屬性做什麼)。

看着iron-pages元素,you can see that it explicitely calls notifyResize whenever an element is unhidden,所以我認爲這是它的工作方式。

我建議你爲了得到更多關於這方面的反饋打開an issue on the Github repo,如果我是正確的,以糾正這種誤導性陳述。

+0

你的分析是正確的。這不是簡單的說,如果一個元素一直隱藏在一般意義上的(或調整爲此事)所以對於IronResizableBehavior整個rasion的理由是有辦法更改時明確地通知子樹。 –

+0

感謝您的澄清。 –

+0

IMO,你也是正確的,因爲文件是一種誤導。 https://github.com/PolymerElements/iron-resizable-behavior/issues/16 –