聚合物core-header-panel scrollIntoView

时间:2014-09-19 03:17:33

标签: polymer core-elements

我以为我会很幸运,只是做window.scrollTo(0,500)但这不起作用,因为核心标题面板正在为我滚动。

假设您有两个元素

 <core-header-panel>
  <core-animated-pages selected="{{s}}">
      <section><my-element select={{s}}></my-element></section>
      <section><my-element select={{s}}></my-element></section>
  </core-animated-pages>
 </core-header-panel>


</template>

我在控制台中看到要滚动到的元素,但它不滚动?

<polymer-element name="my-element" attributes="select">
 <template>
     ....
 </template>    
 <script>
    Polymer('my-element', {
        select:0,
        selectChanged: function(){
            var x=this.shadowRoot.querySelector("#id")
            if (x){
                console.log(x)
                x.scrollIntoView()
            }
        }
    });
 </script>
</polymer-element>

编辑:

<polymer-element name="my-element" attributes="select">
 <template>
     <core-animated-pages fit selected="{{select}}" id="core_page">
             ....
     </core-animated-pages>
 </template>    
 <script>
    Polymer('my-element', {
        ready: function(){
            this.$.core_page.addEventListener("core-animated-pages-transition-end", function(e) {
                var x=this.shadowRoot.querySelector("#id")
                if (x){
                    console.log(x)
                    x.scrollIntoView()
                 }
             })
        }
    });
 </script>
</polymer-element>

0 个答案:

没有答案