Search code examples
javascriptpolymerpolymer-1.0

How do I reset scroll position of paper-dialog-scrollable?


I have a paper-dialog with a paper-dialog-scrollable how do I reset the scroll position of the dialog everytime its open/closed?

UPDATE

<paper-dialog-scrollable id="disclaimerScroller">

When I open the modal,

this.$.disclaimer.open();
Polymer.dom(this.$.disclaimerScroller).scrollTop = 0;

// I also tried 
this.$.disclaimerScroller.scrollTop = 0

It does not seem to work


Solution

  • You can add and event listener iron-overlay-opened in paper-dialog which will fire after the paper-dialog is opened. In that listener you can simply put your code to reset the scroll position of the paper-dialog-scrollable.

    Example Code:

    <paper-dialog id="scrolling" on-iron-overlay-opened="onIronOverlayOpened">
    
    <paper-dialog-scrollable id="disclaimerScroller">
    
    onIronOverlayOpened(){       
       this.$.disclaimerScroller.$.scrollable.scrollTop = 0;
    }
    

    Demo