Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back to Top Button Disappears on Start Writing Tab During Scroll #1835

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

Loading