there doesn't seem to be a polymer-layout event

二次信任 提交于 2019-12-11 02:35:09

问题


I'm looking for an event fired by polymer-layout when it's finished laying out, similar to the polymer-grid-layout event. Doesn't seem to be one. Am I missing something?

After my attempts at polymer-grid-layout (Autosizing canvas inside a polymer grid layout) I've decided to convert everything to nested polymer-layouts instead. After a few hiccups (e.g. the dart version of polymer-layout doesn't work if you put polymer-layout as an element directly under template, whereas the js version does - don't know which is wrong) the approach seems to be working.

The one exception is that I was previously relying on polymer-grid-layout to tell me when the canvas had been resized properly. But with polymer-layout I have the same timing problem but without the same solution it appears.

Any way around this?

thanks

Anders


回答1:


Dart polymer_element/polymer_ui_element are a bit outdated. I'll take a look at what changes were be made in JS polymer-layout since I last revisited Dart polymer-layout (probably Mo/Di).

Can you please create an issue in https://github.com/ErikGrimes/polymer_elements so you get notified when the update is made.




回答2:


You are right that polymer-layout is missing a layout event. I filed an issue here https://github.com/Polymer/polymer-layout/issues/3

In the meantime, you should be able to capture the timeline in attached.

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

I used nested async because I don't want to worry about whose attached is called first (this one, or the one in the polymer-layout). And yes, this is exactly the kind of fiddly construction that is avoided by having an event.



来源:https://stackoverflow.com/questions/22111447/there-doesnt-seem-to-be-a-polymer-layout-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!