2014-11-21 68 views
0

core-(animated)-pages集合中,我需要我选择的页面对它成为选定页面的事实做出反应。我无法弄清楚要捕捉什么事件。试过一个简单的load,但没有被调用。使用核心页面,是否有页面加载事件?

如果默认情况下没有这样的事件,on-core-select可以以某种方式触发my-element中的事件,让它知道它应该加载它的数据?

  <core-animated-pages id="appPages" selected="{{selectedPage}}" valueattr="data-name" transitions="slide-from-right" on-core-select="{{pageSelected}}"> 
       <my-page data-name="Round 1" color="red"> 
        <div>Page 1</div> 
       </my-page> 
       <my-page data-name="Round 2" color="yellow"> 
        <div>Page 2</div> 
       </my-page> 
       <my-page data-name="Round 3" color="grey"> 
        <div>Page 3</div> 
       </my-page> 
      </core-animated-pages> 



<polymer-element name="my-page" attributes="color"> 
<template> 
    <section data-name="Round 1" layout vertical center center-justified style="background:{{color}};"> 
     <content></content> 
    </section> 
</template> 
<script> 
    Polymer('my-page', { 
     load: function (e) { 
      console.info(e) 
     } 
    }); 
</script> 

+0

正在做一些接近的方式你所谈论的是用烙铁导演和我的核心动画,网页制作每个页面的路线和监听路线改变,然后做我的功能。 – 2014-11-21 20:07:02

+0

谢谢,我现在正在做类似的事情,请参阅下一个回答 – Jens 2014-11-24 09:29:06

+0

的评论非常高兴你能够正常工作。只有在2种方法中我所知道的功能的不同之处在于flatiron-director会得到路由页面。 www.url.com#第1页。应该刚刚发布我的代码,但我不能100%确定那是你正在寻找的。 – 2014-11-24 13:33:52

回答

0

基于核心 - 动画 - 页文档(https://www.polymer-project.org/docs/elements/core-elements.html#core-animated-pages),元素需要你的转换名称和查找包含相同的字元素。例如:

<core-animated-pages transitions="hero-transition"> 
    <section id="page1"> 
    <div id="hero1" hero-id="hero" hero></div> 
    </section> 
    <section id="page2"> 
     <div id="hero2" hero-id="hero" hero></div> 
    </section> 
</core-animated-pages> 

这应该有助于避免编写显示/隐藏元素的逻辑。 文档还显示转换发生之前和之后触发的事件。

0

好像有是在不同时间发射的两个事件:

  • core-animated-pages-transition-prepare
  • core-animated-pages-transition-end

https://github.com/Polymer/core-animated-pages

<!-- 
    Fired before a page transition occurs. Both pages involved in the transition are visible when 
    this event fires. This is useful if there is something the client needs to do when a page becomes visible. 

    @event core-animated-pages-transition-prepare 
--> 

<!-- 
    Fired when a page transition completes. 

    @event core-animated-pages-transition-end 
--> 
+0

这很有趣,但似乎没有帮助我的情况。这两个事件处理程序似乎没有关于它正在处理的页面的任何信息。死路。 我回去检查'on-core-selected',实际上'detail.item'可以用来获取页面内的东西,特别是'core-ajax'元素,然后我可以触发一个'go()'来获取新数据。 感谢让我重新思考:-) – Jens 2014-11-24 09:25:26