In Polymer template: dom-repeat items - Is it possible to shuffle repeating items?
Asked
Active
Viewed 93 times
1 Answers
0
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;
}

JoelCode
- 326
- 1
- 7