Gustavo Luigi 2024-01-10 17:31:47 -03:00
parent 3c96d8843d
commit 2dce75d449
1 changed files with 28 additions and 17 deletions

View File

@ -148,7 +148,7 @@
@endif
</div>

<div class="fixed-bottom d-lg-none text-center pb-3">
<div class="fixed-bottom d-lg-none text-center pb-3 form-anchor">

<div class="d-grid gap-2 px-4">
<a href="#lumino-form-sent" class="btn btn-primary btn-block">Angebot anfordern
@ -213,24 +213,35 @@

<script>
// Get the elements
const targetElement = document.querySelector('#lumino-form-sent');
const elementToRemove = document.querySelector('.fixed-bottom');
const targetElement = document.querySelector('#lumino-form-sent');
const elementToRemove = document.querySelector('.form-anchor');

// Create an Intersection Observer
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
// If target element is visible
if (entry.isIntersecting) {
// Remove the element to remove
elementToRemove.remove();
// Stop observing once it's removed (optional)
observer.unobserve(targetElement);
}
});
});
// Create an Intersection Observer
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
// If target element is visible
if (entry.isIntersecting) {
// Remove the element to remove
elementToRemove.style.display = 'none';
} else {
const fixedElementRect = elementToRemove.getBoundingClientRect();
const referenceElementRect = targetElement.getBoundingClientRect();

// Observe the target element
observer.observe(targetElement);
if (fixedElementRect.bottom < referenceElementRect.top) {
// Show the element to remove
elementToRemove.style.display = 'block';
} else {
// Hide the element to remove
elementToRemove.style.display = 'none';
}
}
// Stop observing once it's removed (optional)
// observer.unobserve(targetElement);
});
});

// Observe the target element
observer.observe(targetElement);

</script>
@stop