Skip to content

Commit

Permalink
Back to Top Button Disappears on Start Writing Tab During Scroll
Browse files Browse the repository at this point in the history
Fixes #1834
  • Loading branch information
neeru24 committed Nov 10, 2024
1 parent a984942 commit eb4d670
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);

0 comments on commit eb4d670

Please sign in to comment.