Updating scroll component on image load.

This commit is contained in:
2020-07-06 02:40:10 +02:00
parent af9c4a36c6
commit 9b1d38d9ff
3 changed files with 37 additions and 41 deletions

View File

@@ -70,18 +70,17 @@ function scroll(direction) {
function mounted() {
this.target = this.$slots.default[0].elm;
this.target.addEventListener('scroll', () => {
this.updateScroll();
});
this.target.addEventListener('scroll', () => this.updateScroll());
window.addEventListener('resize', this.updateScroll);
// typically triggered by slotted component when an image loads, affecting scrollWidth
this.$on('load', () => this.updateScroll());
this.updateScroll();
setTimeout(() => this.updateScroll(), 150); // allow CSS to calculate
}
function beforeDestroy() {
this.target.removeEventListener('scroll', this.updateScroll);
window.removeEventListener('resize', this.updateScroll);
}