Skip to content

Commit

Permalink
Merge pull request #186 from agileware-jp/fix-88498
Browse files Browse the repository at this point in the history
Feature 88498 カンバン・バックログでトップへ戻るボタンをクリックしたときのスクロールスピードが遅く、一番上に戻った後下にスクロールしても自動で浮上してしまう
  • Loading branch information
morioka-hibiki authored Sep 9, 2024
2 parents c3a2bbc + 172352d commit 06ff30c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/js/backToTop.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
*/
let backToTopBtn = null

function backToTop(speed) {
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
if (scrollTop > 0) {
window.requestAnimationFrame(() => backToTop(speed));
window.scrollTo(0, scrollTop - scrollTop / speed);
}
function backToTop() {
window.scroll({ top: 0, behavior: "smooth" });
}

export function createBackToTopBtn() {
Expand All @@ -18,7 +14,7 @@ export function createBackToTopBtn() {
backToTopBtn.textContent = 'トップへ戻る'
backToTopBtn.style.display = 'none'

backToTopBtn.addEventListener('click', () => backToTop(2))
backToTopBtn.addEventListener('click', () => backToTop())

document.body.appendChild(backToTopBtn)
}
Expand Down

0 comments on commit 06ff30c

Please sign in to comment.