changed from window resize event, to element ResizeObserver for more accurate tracking of tree size (#4132)

This commit is contained in:
Jamie V 2021-08-18 16:38:48 -07:00 committed by GitHub
parent 9f48764210
commit a99ce7733c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -226,18 +226,21 @@ export default {
},
created() {
this.getSearchResults = _.debounce(this.getSearchResults, 400);
this.handleWindowResize = _.debounce(this.handleWindowResize, 500);
this.handleTreeResize = _.debounce(this.handleTreeResize, 300);
this.scrollEndEvent = _.debounce(this.scrollEndEvent, 100);
},
destroyed() {
window.removeEventListener('resize', this.handleWindowResize);
if (this.treeResizeObserver) {
this.treeResizeObserver.disconnect();
}
},
methods: {
async initialize() {
this.isLoading = true;
this.openmct.$injector.get('searchService');
this.getSavedOpenItems();
window.addEventListener('resize', this.handleWindowResize);
this.treeResizeObserver = new ResizeObserver(this.handleTreeResize);
this.treeResizeObserver.observe(this.$el);
await this.calculateHeights();
@ -710,7 +713,7 @@ export default {
setSavedOpenItems() {
localStorage.setItem(LOCAL_STORAGE_KEY__TREE_EXPANDED, JSON.stringify(this.openTreeItems));
},
handleWindowResize() {
handleTreeResize() {
this.calculateHeights();
}
}