Fix intersection button send again (removed validation inside forEach)

This commit is contained in:
Igor Guastalla de Lima
2019-08-30 09:11:30 -03:00
parent 0c9977a92a
commit 4b4e6ca31a

View File

@@ -531,21 +531,14 @@
if (this[key]) this[key] = queries[key]; if (this[key]) this[key] = queries[key];
} }
}, },
observeRequestButton: function () { observeRequestButton() {
let isTheInitialIntersection = true;
const sendButtonElement = this.$refs.sendButton;
const requestElement = this.$refs.request.$el; const requestElement = this.$refs.request.$el;
const observer = new IntersectionObserver((entries, observer) => { const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => { entries.forEach(entry => {
if (entry.isIntersecting) { this.$refs.sendButton.classList.toggle('show');
if (!isTheInitialIntersection) {
sendButtonElement.classList.toggle('show');
} else {
isTheInitialIntersection = false;
}
}
}); });
}, {threshold: 1}); }, { threshold: 1 });
observer.observe(requestElement); observer.observe(requestElement);
} }
}, },