Answer the question
In order to leave comments, you need to log in
How to make a universal selector?
There is code like this (Vue method):
handleScroll() {
let obj = document.querySelector('h2');
let {top,bottom} = obj.getBoundingClientRect();
let height = document.documentElement.clientHeight;
this.scrolled = top < height && bottom >0;
}
let obj = document.querySelector('любой элемент которому задам этот метод');
Answer the question
In order to leave comments, you need to log in
As an option, create a separate vue component.
Or just animate all elements that satisfy the condition:
handleScroll() {
let objList = document.querySelectorAll('h2');
objList.forEach(function(el) {
let {top,bottom} = el.getBoundingClientRect();
let height = document.documentElement.clientHeight;
if(top < height && bottom > 0) {
el.classList.add('bounceInLeft');
} else {
el.classList.remove('bounceInLeft');
}
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question