12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- const scrollButtons = `
- <a href="#up" id="scroll-up" class="btn btn-primary btn-sm" role="button" aria-pressed="true" style="display: sticky; position: fixed; bottom: 3rem; right: 1rem;">
- <span class="ing-caret ing-rotate-180 ing-fw"></span>
- </a>
- <a href="#down" id="scroll-down" class="btn btn-primary btn-sm" role="button" aria-pressed="true" style="display: sticky; position: fixed; bottom: 1rem; right: 1rem;">
- <span class="ing-caret ing-fw"></span>
- </a>
- `
- document.body.insertAdjacentHTML('beforeend', scrollButtons);
- const scroll_up = document.querySelector('#scroll-up');
- const scroll_down = document.querySelector('#scroll-down');
- scroll_up.style.transition = scroll_down.style.transition = 'display 1.5s ease-in-out';
- scroll_up.style.display = scroll_down.style.display = 'none';
- scroll_up.addEventListener('click', () =>
- window.scrollTo({ top: 0, behavior: 'smooth' }))
- scroll_down.addEventListener('click', () =>
- window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' }))
- const check = () => {
- scroll_down.style.display = (window.scrollY + window.innerHeight) > document.body.scrollHeight * .8 ? 'none' : 'block'
- scroll_up.style.display = (window.scrollY) < document.body.scrollHeight * .2 ? 'none' : 'block'
- }
- ['scroll', 'resize'].forEach(e => window.addEventListener(e, check))
- <<<<<<< HEAD
- =======
- document.addEventListener('DOMContentLoaded', function () {
- const links = document.querySelectorAll('a');
- links.forEach(function (link) {
- link.addEventListener('click', function (event) {
- // event.preventDefault();
- });
- });
- });
- >>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f
|