-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the README.md #8
Comments
Can you explain this issue in detail? |
You can give a short jquery or javascript snippet to use these animation classes. A short demo type... |
still open??? |
Hello @vaibhav111tandon, i could add my snippet from #34 which is a frequently use for such animations |
@vaibhav111tandon This is my javascript how i add css classes when the element is in viewport /**
* Add a css class when the element appears in viewport
*
* @param {IntersectionObserverEntry[]} entries
*/
function func2(entries) {
entries.forEach(entry => {
const elem = entry.target;
if (entry.isIntersecting) {
elem.classList.add('in-viewport');
observer.unobserve(elem);
}
})
}
const observer = new IntersectionObserver(func2, {
root: null,
rootMargin: '0px',
threshold: .5
});
/**
* Set or remove a css class when the element is in viewport
*
* @param {string} selector
*/
export function inViewport(selector = '.if-viewport') {
document.querySelectorAll(selector).forEach(elem => {
observer.observe(elem);
});
} The HTML looks like: <div class="if-viewport vov fade-in-up">
This is some content with a fade-in-up animation when if appears in viewport
</div> The javascript adds the The issue I have, the initial state before it is visible in the viewport should be |
Add the usage of classes through JavaScript and jQuery
The text was updated successfully, but these errors were encountered: