Skip to content

Commit

Permalink
Merge pull request #1835 from neeru24/neeru24/issue1834
Browse files Browse the repository at this point in the history
Back to Top Button Disappears on Start Writing Tab During Scroll
  • Loading branch information
hiteashgupta1 authored Nov 10, 2024
2 parents a984942 + eb4d670 commit 340a6f1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
24 changes: 24 additions & 0 deletions start_writing.css
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,30 @@ textarea#blogContent::placeholder {
color: #D3D3D3; /* Light grey color for dark mode */
}

#backToTop {
position: fixed;
bottom: 20px;
right: 30px;
width: 50px;
height: 50px;
background-color: #007bff;
color: white;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
transition: opacity 0.3s;
opacity: 0;
visibility: hidden;
}

#backToTop.show {
opacity: 1;
visibility: visible;
}

.footer-content {
font-size: 0.9rem;
}
Expand Down
20 changes: 20 additions & 0 deletions start_writing.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@ async function getWritingSuggestions() {
}
}

// Get the Back to Top button element
const backToTopButton = document.getElementById('backToTop');

// Add scroll event to show/hide the button
window.addEventListener('scroll', () => {
if (window.scrollY > 300) {
backToTopButton.classList.add('show');
} else {
backToTopButton.classList.remove('show');
}
});

// Add click event to scroll to the top smoothly
backToTopButton.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});


document.getElementById("getSuggestions").addEventListener("click", getWritingSuggestions);

1 comment on commit 340a6f1

@vercel
Copy link

@vercel vercel bot commented on 340a6f1 Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.