mirror of
https://github.com/nasa/openmct.git
synced 2025-06-11 20:01:41 +00:00
changed from window resize event, to element ResizeObserver for more accurate tracking of tree size (#4132)
This commit is contained in:
@ -226,18 +226,21 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getSearchResults = _.debounce(this.getSearchResults, 400);
|
this.getSearchResults = _.debounce(this.getSearchResults, 400);
|
||||||
this.handleWindowResize = _.debounce(this.handleWindowResize, 500);
|
this.handleTreeResize = _.debounce(this.handleTreeResize, 300);
|
||||||
this.scrollEndEvent = _.debounce(this.scrollEndEvent, 100);
|
this.scrollEndEvent = _.debounce(this.scrollEndEvent, 100);
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
window.removeEventListener('resize', this.handleWindowResize);
|
if (this.treeResizeObserver) {
|
||||||
|
this.treeResizeObserver.disconnect();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async initialize() {
|
async initialize() {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.openmct.$injector.get('searchService');
|
this.openmct.$injector.get('searchService');
|
||||||
this.getSavedOpenItems();
|
this.getSavedOpenItems();
|
||||||
window.addEventListener('resize', this.handleWindowResize);
|
this.treeResizeObserver = new ResizeObserver(this.handleTreeResize);
|
||||||
|
this.treeResizeObserver.observe(this.$el);
|
||||||
|
|
||||||
await this.calculateHeights();
|
await this.calculateHeights();
|
||||||
|
|
||||||
@ -710,7 +713,7 @@ export default {
|
|||||||
setSavedOpenItems() {
|
setSavedOpenItems() {
|
||||||
localStorage.setItem(LOCAL_STORAGE_KEY__TREE_EXPANDED, JSON.stringify(this.openTreeItems));
|
localStorage.setItem(LOCAL_STORAGE_KEY__TREE_EXPANDED, JSON.stringify(this.openTreeItems));
|
||||||
},
|
},
|
||||||
handleWindowResize() {
|
handleTreeResize() {
|
||||||
this.calculateHeights();
|
this.calculateHeights();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user