-
Notifications
You must be signed in to change notification settings - Fork 403
scroll button added #1289
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
scroll button added #1289
Changes from 2 commits
8c84a3d
d4e6d7c
55e69b5
71169dc
c39cb33
88b5523
55d3d6f
ba34d72
49c1d81
38cd840
fd0f46b
88433c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| /* Scroll to Top Button Styles */ | ||
|
|
||
| #scrollToTopBtn { | ||
| position: fixed; | ||
| bottom: 120px; | ||
| right: 40px; | ||
| background-color: #017cee; | ||
| color: white; | ||
| border: none; | ||
| border-radius: 50%; | ||
| width: 50px; | ||
| height: 50px; | ||
| padding: 0; | ||
| font-size: 24px; | ||
| cursor: pointer; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| opacity: 0; | ||
| transition: opacity 0.3s ease-in-out, background-color 0.3s ease, transform 0.2s ease; | ||
| z-index: 1000; | ||
| box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,48 @@ | ||
| {{/* | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| */}} | ||
|
|
||
| <!doctype html> | ||
| <html lang="{{ .Site.Language.Lang }}" class="no-js"> | ||
|
|
||
| <head> | ||
| {{ partial "head.html" . }} | ||
| </head> | ||
|
|
||
| <body class="td-{{ .Kind }}"> | ||
| <header> | ||
| {{ partial "navbar.html" . }} | ||
| </header> | ||
| <div class="container-fluid td-default"> | ||
| {{ block "animation-header" . }}{{ end }} | ||
| <div class="home-page-layout base-layout"> | ||
| <main role="main" class="td-main container"> | ||
| {{ block "main" . }}{{ end }} | ||
| </main> | ||
| {{ partial "suggest-change" . }} | ||
| <header> | ||
| {{ partial "navbar.html" . }} | ||
| </header> | ||
| <div class="container-fluid td-default"> | ||
| {{ block "animation-header" . }}{{ end }} | ||
| <div class="home-page-layout base-layout"> | ||
| <main role="main" class="td-main container"> | ||
| {{ block "main" . }}{{ end }} | ||
| </main> | ||
| {{ partial "suggest-change" . }} | ||
| {{ partial "page-scroll-button.html" . }} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {{ partialCached "footer.html" . }} | ||
| {{ partial "scripts.html" . }} | ||
| {{ partialCached "footer.html" . }} | ||
| {{ partial "scripts.html" . }} | ||
| </body> | ||
| {{ with .Site.Data.webpack }} | ||
| <script src="{{ relURL .main.js }}"></script> | ||
| <script src="{{ relURL .main.js }}"></script> | ||
| {{ end }} | ||
| </html> | ||
|
|
||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| {{/* | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| */}} | ||
|
|
||
| <button id="scrollToTopBtn" title="Go to top" style="display: none;"> | ||
| <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" | ||
| stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-up"> | ||
| <line x1="12" y1="19" x2="12" y2="5"></line> | ||
| <polyline points="5 12 12 5 19 12"></polyline> | ||
| </svg> | ||
| </button> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,9 @@ | |
| {{ partial "buttons/button-with-icon" (dict "text" "Suggest a change on this page" "class" "button-fixed") }} | ||
| </a> | ||
| </div> | ||
|
|
||
| <!-- Scroll to Top Button --> | ||
| <button id="scrollToTopBtn">▲</button> | ||
|
|
||
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
|
|
||
| // Enabled button with 1200px threshold | ||
| const scrollToTopBtn = document.getElementById('scrollToTopBtn'); | ||
| const scrollThreshold = 1200; | ||
|
|
||
| function toggleScrollToTopButton() { | ||
| if (!scrollToTopBtn) return; | ||
|
|
||
| const scrollPosition = document.documentElement.scrollTop || document.body.scrollTop; | ||
|
|
||
| if (scrollPosition <= scrollThreshold) { | ||
| if (scrollToTopBtn.style.opacity !== '0' && scrollToTopBtn.style.display !== 'none') { | ||
| scrollToTopBtn.style.opacity = '0'; | ||
| setTimeout(() => scrollToTopBtn.style.display = 'none', 300); | ||
| } | ||
| } else { | ||
| if (scrollToTopBtn.style.display === 'none') { | ||
| scrollToTopBtn.style.display = 'flex'; | ||
| setTimeout(() => scrollToTopBtn.style.opacity = '1', 10); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function scrollToTop() { | ||
| window.scrollTo({ | ||
| top: 0, | ||
| behavior: 'smooth' | ||
| }); | ||
| } | ||
|
|
||
| window.addEventListener('scroll', toggleScrollToTopButton); | ||
| scrollToTopBtn.addEventListener('click', scrollToTop); | ||
|
|
||
| scrollToTopBtn.onmouseover = function () { | ||
| this.style.backgroundColor = '#0056b3'; | ||
| this.style.transform = 'scale(1.1)'; | ||
| }; | ||
|
|
||
| scrollToTopBtn.onmouseout = function () { | ||
| this.style.backgroundColor = '#007bff'; | ||
| this.style.transform = 'scale(1)'; | ||
| }; | ||
|
|
||
| scrollToTopBtn.addEventListener('mousedown', function () { | ||
| this.style.border = '1.5px solid lightgreen'; | ||
| }); | ||
| scrollToTopBtn.addEventListener('mouseup', function () { | ||
| this.style.border = 'none'; | ||
| }); | ||
|
|
||
| scrollToTopBtn.addEventListener('focus', function () { | ||
| this.style.outline = '1px solid lightblue'; | ||
| }); | ||
| scrollToTopBtn.addEventListener('blur', function () { | ||
| this.style.outline = 'none'; | ||
| }); | ||
|
|
||
| toggleScrollToTopButton(); |
Uh oh!
There was an error while loading. Please reload this page.