Skip to content

Commit 2cef10b

Browse files
committed
add back to top button to footer
1 parent 46d9011 commit 2cef10b

4 files changed

Lines changed: 60 additions & 26 deletions

File tree

index.html

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -399,38 +399,17 @@ <h3>LinkedIn</h3>
399399
</div>
400400

401401
<!-- =========================== back to top =========================== -->
402-
<div>
403-
<img id="btt" src="wp-content/Icon_Back_to_top.svg" alt="Back to top" tabindex="0" role="button">
404-
</div>
402+
405403
</main>
406404
</div>
407405
</div>
408406

409-
<imscentral-footer></imscentral-footer>
407+
<!-- <div>
408+
<img id="btt" src="wp-content/Icon_Back_to_top.svg" alt="Back to top" tabindex="0" role="button">
409+
</div> -->
410410

411411
<!-- =========================== Additional Support / Footer links =========================== -->
412-
<!-- <footer aria-label="Footer" id="themeFooter">
413-
<div id="boomer-footer" class="boomer_footer_menu"></div>
414-
<div id="dw-footer" class="ibm-alternate ibm-padding-normal">
415-
<div class="ibm-columns ibm-padding-bottom-0">
416-
<div class="ibm-col-1-1">
417-
<div class="ibm-footer-corporate-links">
418-
<ul>
419-
<li><a href="https://www.ibm.com/contact/us" target="_blank" style="color: #78A9FF;">Contact</a></li>
420-
<li><div></div></li>
421-
<li><a href="http://www.ibm.com/privacy/us/en/" target="_blank" style="color: #78A9FF;">Privacy</a></li>
422-
<li><div></div></li>
423-
<li><a href="https://www.ibm.com/legal?lnk=flg-tous-usen" target="_blank" style="color: #78A9FF;">Terms of use</a></li>
424-
<li><div></div></li>
425-
<li><a href="http://www.ibm.com/accessibility/us/en/" target="_blank" style="color: #78A9FF;">Accessibility</a></li>
426-
</ul>
427-
</div>
428-
<p class="copyright">Copyright IBM Corporation 2023, 2025</p>
429-
<div id="ibm-footer-locale-selector"></div>
430-
</div>
431-
</div>
432-
</div>
433-
</footer> -->
412+
<imscentral-footer></imscentral-footer>
434413

435414
<!-- post-load actions/listeners -->
436415
<script src="jekyll-tipue-search/assets/tipuesearch/postLoad.js"></script>

web-components/footer/footer.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,35 @@ p {
3131
color: #a8a8a8;
3232
}
3333

34+
#back-to-top {
35+
/* display:none; */
36+
opacity: 0;
37+
z-index: 99;
38+
transition: transform .2s;
39+
position: fixed;
40+
bottom: 5%;
41+
right: 5%;
42+
animation: fadeInAnimation 2s;
43+
animation-iteration-count: 1;
44+
animation-fill-mode: forwards;
45+
}
46+
47+
@keyframes fadeInAnimation {
48+
0% {
49+
opacity: 0;
50+
}
51+
52+
100% {
53+
opacity: 1;
54+
}
55+
}
56+
57+
#back-to-top:hover {
58+
cursor: pointer;
59+
filter: invert(5%);
60+
transform: scale(1.2);
61+
}
62+
3463
@media screen and (max-width: 35em) {
3564
footer > ul, footer > p {
3665
padding-left: 1em;

web-components/footer/footer.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<link href="web-components/footer/footer.css" rel="stylesheet">
22
<footer>
3+
<div>
4+
<img id="back-to-top" src="wp-content/Icon_Back_to_top.svg" alt="Back to top" tabindex="0" role="button">
5+
</div>
36
<ul>
47
<li><a href="https://www.ibm.com/contact/us" target="_blank">Contact</a></li>
58
<li><div></div></li>

web-components/footer/footer.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@ function createComponent(html) {
2828
// Create shadow root for element
2929
const shadow = this.attachShadow({mode: 'closed'});
3030
shadow.innerHTML = html;
31+
32+
const backToTopBtn = shadow.getElementById('back-to-top');
33+
window.onscroll = () => {
34+
if (document.body.scrollTop > 450 || document.documentElement.scrollTop > 450) {
35+
backToTopBtn.style.opacity = '1';
36+
// backToTopBtn.style.display = 'block';
37+
// backToTopBtn.style.animation = 'fadeIn 1s';
38+
} else {
39+
backToTopBtn.style.opacity = '0';
40+
// backToTopBtn.style.display = 'none';
41+
}
42+
}
43+
44+
backToTopBtn.addEventListener('click', () => {
45+
document.body.scrollTop = 0;
46+
document.documentElement.scrollTop = 0;
47+
})
48+
backToTopBtn.addEventListener('keydown', (event) => {
49+
if (event.key === 'Enter') {
50+
document.body.scrollTop = 0;
51+
document.documentElement.scrollTop = 0;
52+
}
53+
})
3154
}
3255
}
3356

0 commit comments

Comments
 (0)