html_scroll.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. include_once "include/constantes.php";
  3. ?>
  4. <a href="#top" id="scroll-up" class="btn btn-primary btn-sm" role="button" aria-pressed="true" style="display: none; position: fixed; bottom: 3rem; right: 1rem;">
  5. <?= $ICO['arriba'] ?>
  6. </a>
  7. <!-- Scroll down -->
  8. <a href="#bottom" id="scroll-down" class="btn btn-primary btn-sm" role="button" aria-pressed="true" style="display: none; position: fixed; bottom: 1rem; right: 1rem;">
  9. <?= $ICO['abajo'] ?>
  10. </a>
  11. <script>
  12. $(document).ready(function() {
  13. $(window).scroll(function() {
  14. if ($(this).scrollTop() > 100) {
  15. $('#scroll-up').fadeIn();
  16. } else {
  17. $('#scroll-up').fadeOut();
  18. }
  19. if ($(this).scrollTop() < $(document).height() - $(window).height() - 100) {
  20. $('#scroll-down').fadeIn();
  21. } else {
  22. $('#scroll-down').fadeOut();
  23. }
  24. });
  25. $('#scroll-up').click(function() {
  26. $("html, body").animate({
  27. scrollTop: 0
  28. }, 600);
  29. return false;
  30. });
  31. $('#scroll-down').click(function() {
  32. $("html, body").animate({
  33. scrollTop: $(document).height()
  34. }, 600);
  35. return false;
  36. });
  37. });
  38. </script>