Reputation: 1680
In Polymer template: dom-repeat items - Is it possible to shuffle repeating items?
Upvotes: 0
Views: 97
Reputation: 336
Yes, use a sort function that will randomly assign the item position rather than actually sorting it.
<template is="dom-repeat" items="[[items]]" sort="_sortItems" initial-count="1">
<a href$="#[[section]]/[[item.id]]" class="item" aria-label$="More information about [[item.title]]">
<shrine-item item="[[item]]"></shrine-item>
</a>
</template>
_sortItems: function() {
return Math.round(Math.random()*3) - 1;
}
Upvotes: 0