Skip to content

Commit

Permalink
modify ratio from observer, add alt and lazy loading on img (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
ail3ngrimaldi authored Jun 25, 2024
1 parent db46abd commit b6ee21c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion usecases.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ article h3 a {
{% for case in use_case.cases %}
<li class="animated white-bg use-cases-card">
<div class="img-container">
<img src="{{ case.img }}" />
<img src={{ case.img }} loading="lazy" alt={{ case.title }} />
</div>
<div class="use-cases-content">
<h3 class="boldest header-2">{{ case.title }}</h3>
Expand Down Expand Up @@ -152,6 +152,23 @@ article h3 a {
{% endfor %}

<script>
document.addEventListener("DOMContentLoaded", function() {
const observerUseCases = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate');
observerUseCases.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
const animatedElements = document.querySelectorAll('.animated');
animatedElements.forEach(element => {
observerUseCases.observe(element);
});
});
document.querySelectorAll('.show_more').forEach((button, index) => {
button.addEventListener('click', () => {
const examples = button.closest('.use-cases-content').querySelector('.examples');
Expand Down

0 comments on commit b6ee21c

Please sign in to comment.