From fbaf7095106c4103fcc25686ce4bfb784df8d1e6 Mon Sep 17 00:00:00 2001 From: Kushal K S V S Date: Sun, 27 Aug 2017 13:26:40 -0700 Subject: [PATCH] Add Go to top button --- tests/make_png/bitmap.c | 1 + tests/make_png/html/scripts/top.js | 15 +++++++++++++++ tests/make_png/html/styles/top.css | 13 +++++++++++++ 3 files changed, 29 insertions(+) diff --git a/tests/make_png/bitmap.c b/tests/make_png/bitmap.c index 5fa1f2bb3..8158af74c 100644 --- a/tests/make_png/bitmap.c +++ b/tests/make_png/bitmap.c @@ -663,6 +663,7 @@ void Print_Head( FILE* fp ){ \n\ \n\ \n\ + \n\ \n\ \n\ \n\ diff --git a/tests/make_png/html/scripts/top.js b/tests/make_png/html/scripts/top.js index b3fabf8c0..e77372e4f 100644 --- a/tests/make_png/html/scripts/top.js +++ b/tests/make_png/html/scripts/top.js @@ -92,3 +92,18 @@ function class_one_four(){ div.className = 'animation one_four'; } +// When the user scrolls down 20px from the top of the document, show the button +window.onscroll = function() {scrollFunction()}; + +function scrollFunction() { + if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { + document.getElementById("myBtn").style.display = "block"; + } else { + document.getElementById("myBtn").style.display = "none"; + } +} +// When the user clicks on the button, scroll to the top of the document +function topFunction() { + document.body.scrollTop = 0; + document.documentElement.scrollTop = 0; +} diff --git a/tests/make_png/html/styles/top.css b/tests/make_png/html/styles/top.css index c2c0029a0..d6518db7d 100644 --- a/tests/make_png/html/styles/top.css +++ b/tests/make_png/html/styles/top.css @@ -34,6 +34,19 @@ th { width: 50%; height: auto; } +#myBtn { + display: none; + position: fixed; + bottom: 10px; + right: 10px; + z-index: 99; + cursor: pointer; + padding: 15px; + border-radius: 10px; + background-color: #555; + color: white; +} + /*Top Page styling begins*/ #frame_1{ width:49%;