纸张滚动页眉面板不工作

paper-scroll-header-panel not working

HTML 文档正文在 neon-animated-page 中包含两个独立的 paper-scroll-header-panel。将 neon-animated-page 从第 0 页切换到第 1 页后,第 1 页上的 paper-scroll-panel 不起作用。

http://jsbin.com/winedi/edit?html,output

原因:paper-scroll-header-panel 在首次加载时会计算页眉高度。然后它只监听 iron-resize 事件。但是 neon 动画页面在切换页面时不会触发 iron-resize 事件。 来自 https://github.com/PolymerElements/paper-scroll-header-panel/blob/master/paper-scroll-header-panel.html。行号 230

 * By default, the height will be measured when it is ready.  If the height
       * changes later the user needs to either set this value to reflect the
       * new height or invoke `measureHeaderHeight()`.

解决方案:我已经通过显式调用第二个 paper-scroll-header-panel 的 measureHeaderHeight() 方法解决了这个问题。检查这个 http://jsbin.com/visazasena/edit?html,output

Polymer({
  is: "inbox-view",

  next_page: function() {
    document.querySelector("#main-page").selected = 1;
  }

});

将此更改为

Polymer({
  is: "inbox-view",

  next_page: function() {
    document.querySelector("#main-page").selected = 1;
    document.querySelector("#panel").measureHeaderHeight();

  }
});