2014-11-28 4 views

답변

0

사용자 정의 요소를 만들 수 있습니다

<link rel="import" href="/bower_components/polymer/polymer.html"> 
<link rel="import" href="/bower_components/paper-fab/paper-fab.html"> 

<polymer-element name="custom-fab" extends="paper-fab" on-tap="scrollToTop"> 
    <template> 
     <shadow></shadow> 
    </template> 

    <script> 

     var scrollTop = function() { 
      var scrollDuration = 500; 
      var scrollStep = -window.scrollY/(scrollDuration/15), 
       scrollInterval = setInterval(function(){ 
        if (window.scrollY != 0) { 
         window.scrollBy(0, scrollStep); 
        } 
        else clearInterval(scrollInterval); 
       },15); 

     } 

     Polymer({ 

      scrollToTop: function() { 
       scrollTop(); 
      } 

     }); 
    </script> 
</polymer-element>