feat: add button scroll to top
parent
26eb2f1cef
commit
5a7d5cc85c
|
|
@ -672,6 +672,14 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Scroll to top FAB -->
|
||||||
|
<div class="fixed right-4 bottom-6 md:right-10 md:bottom-10 z-50">
|
||||||
|
<button type="button" id="scrollTopFab"
|
||||||
|
class="btn btn-success btn-circle text-white shadow-xl hidden" aria-label="Kembali ke atas">
|
||||||
|
<i class="ph ph-arrow-up text-xl"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
@section Styles {
|
@section Styles {
|
||||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
||||||
}
|
}
|
||||||
|
|
@ -896,5 +904,25 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// Scroll-to-top floating action button
|
||||||
|
(function () {
|
||||||
|
const scrollFab = document.getElementById('scrollTopFab');
|
||||||
|
if (!scrollFab) return;
|
||||||
|
|
||||||
|
const toggleVisibility = () => {
|
||||||
|
scrollFab.classList.toggle('hidden', window.scrollY < 300);
|
||||||
|
};
|
||||||
|
|
||||||
|
toggleVisibility();
|
||||||
|
window.addEventListener('scroll', toggleVisibility);
|
||||||
|
|
||||||
|
scrollFab.addEventListener('click', () => {
|
||||||
|
window.scrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue