Skip to content

Commit

Permalink
fix(esco-content-menu): timed call only on resizing - better reactivity
Browse files Browse the repository at this point in the history
  • Loading branch information
jgribonvald committed Nov 26, 2018
1 parent 1fe709a commit 9c7e3c4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
29 changes: 16 additions & 13 deletions @uportal/esco-content-menu/src/components/ContentFavorites.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ export default {
},
mounted() {
this.$nextTick(function() {
window.addEventListener('resize', this.updateSlider);
window.addEventListener('resize', this.timedUpdate);
this.updateSlider();
});
},
beforeDestroy() {
window.removeEventListener('resize', this.updateSlider);
window.removeEventListener('resize', this.timedUpdate);
},
computed: {
_portletCardSize() {
Expand Down Expand Up @@ -211,20 +211,23 @@ export default {
this.$refs.favSwiper.swiper.slidePrev(800);
this.updateSlider();
},
updateSlider() {
timedUpdate() {
setTimeout(() => {
if (!this.isHidden) {
if (!this.$refs.favSwiper.swiper.initialized) {
this.$refs.favSwiper.swiper.init();
} else {
this.$refs.favSwiper.swiper.update();
}
this.disableNext = this.$refs.favSwiper.swiper.isEnd;
this.disablePrev = this.$refs.favSwiper.swiper.isBeginning;
this.calculateSize();
}
this.updateSlider();
}, 300);
},
updateSlider() {
if (!this.isHidden) {
if (!this.$refs.favSwiper.swiper.initialized) {
this.$refs.favSwiper.swiper.init();
} else {
this.$refs.favSwiper.swiper.update();
}
this.disableNext = this.$refs.favSwiper.swiper.isEnd;
this.disablePrev = this.$refs.favSwiper.swiper.isBeginning;
this.calculateSize();
}
},
},
};
</script>
Expand Down
4 changes: 2 additions & 2 deletions @uportal/esco-content-menu/src/components/Ellipsis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
mounted() {
this.$nextTick(function() {
window.addEventListener('resize', this.timedRun);
this.timedRun();
this.handleSubstrSentence();
});
},
beforeDestroy() {
Expand All @@ -28,7 +28,7 @@ export default {
timedRun() {
setTimeout(() => {
this.handleSubstrSentence();
}, 200);
}, 300);
},
handleSubstrSentence() {
const stNode = this.$refs.sentence;
Expand Down
7 changes: 7 additions & 0 deletions @uportal/esco-content-menu/src/components/PortletCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</div>
<div class="portlet-card-description">
<ellipsis
ng-if="append"
:message="truncate(description)"
:line-height="'20px'"
:end-char="'...'" />
Expand Down Expand Up @@ -86,8 +87,14 @@ export default {
this.portletDesc.layoutObject.iconUrl !== null
? this.computeIconUrl(this.portletDesc.layoutObject.iconUrl)
: null,
append: false,
};
},
mounted() {
this.$nextTick(function() {
this.append = true;
});
},
computed: {
mainClass() {
let appClasses = [];
Expand Down

0 comments on commit 9c7e3c4

Please sign in to comment.