[bump npm] handle layout / order change on search if selected el is still part of the new search

This commit is contained in:
Kevin Ngo
2018-10-08 03:07:49 -07:00
parent 585a7600ac
commit ddb2deacd4
4 changed files with 21 additions and 2 deletions

View File

@@ -47,6 +47,21 @@ AFRAME.registerComponent('search', {
* Click listener for search result.
*/
AFRAME.registerComponent('search-result-list', {
init: function () {
const obv = new MutationObserver(mutations => {
for (let i = 0; i < mutations.length; i++) {
if (mutations[i].attributeName === 'data-index') {
this.refreshLayout();
}
}
});
obv.observe(this.el, {attributes: true, childList: false, subtree: true});
},
refreshLayout: function () {
this.el.emit('layoutrefresh', null, false);
},
click: bindEvent(function (evt) {
this.el.sceneEl.emit('menuchallengeselect',
evt.target.closest('.searchResult').dataset.id,