I am using app-route and iron-pages with a paper-toolbar to display my views.
On one of my views, main-view
, displays a randomly chosen image which changes
you should definitely add on-tap
to render new images. Your image won't change, because iron-pages
are observing some value (specified in selected
property) so, when you click on main-view and route property already had value "main-view", observer will not trigger.
Adding on-tap on element that is handling changes will make it always trigger. Some easy example:
<iron-pages selected="{{route}}" attr-for-selected="name">
<example-element name="main-view" on-tap="handleClick" id="main"></example-element>
<another-element name="second-view"></another-element>
</iron-pages>
and inside handleClick
function something like:
handleClick: function() {
this.$.main.renderImage();
}
Of course inside main-view
element you can declare renderImage
function which will handle rest of the logic
And don't forget to make some debounce since you don't want to propably render 20 new images in 1 second. You can use Polymer native debounce
function
You can read more about it here: https://www.polymer-project.org/1.0/docs/devguide/instance-methods