forked from DebaucheryLibrarian/traxxx
Updating scroll component on image load.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user