Skip to content

Commit

Permalink
Add back to top button
Browse files Browse the repository at this point in the history
  • Loading branch information
Arasteh authored Jan 4, 2025
1 parent 7710d9f commit 55fe67d
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,26 @@
</div>

<script>
// Get the button
let mybutton = document.getElementById("myBtn");

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}

// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}

const { createApp, ref, computed } = Vue;

Object.groupBy = function (array, keyGetter) {
Expand Down Expand Up @@ -374,25 +394,6 @@
const getImdbLink = imdbID => `https://www.imdb.com/title/${imdbID}`;
const getWikidataLink = film => film;

// Get the button
let mybutton = document.getElementById("myBtn");

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}

// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}

return { showMore, isShowMore, searchTerm, combineSimilarChars, posterMode, filteredItems, items, getImageUrl, getImdbLink, getWikidataLink, getItemTitleWithYear, darkMode, toggleDarkMode, sortOrder, selectedYear, availableYears, availableDesigners, selectedDesigner, getImageLink, filteredYears, filteredDesigners };
}
Expand Down

0 comments on commit 55fe67d

Please sign in to comment.