Skip to content

Commit 416c24b

Browse files
authored
Update post.html
scroll to top button
1 parent 97ccdae commit 416c24b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

post.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
.smooth {transition: box-shadow 0.3s ease-in-out;}
1616
::selection{background-color: aliceblue}
1717
:root{::-webkit-scrollbar{height:10px;width:10px;}::-webkit-scrollbar-track{background:#efefef;border-radius:6px}
18-
::-webkit-scrollbar-thumb{background:#d5d5d5;border-radius:6px} ::-webkit-scrollbar-thumb:hover{background:#c4c4c4}}
18+
::-webkit-scrollbar-thumb{background:#d5d5d5;border-radius:6px} ::-webkit-scrollbar-thumb:hover{background:#c4c4c4}}
19+
/*scroll to top*/
20+
.scroll-top {position: fixed;z-index: 50;padding: 0;right: 30px;bottom: 100px;opacity: 0;visibility: hidden;transform: translateY(15px);height: 46px;width: 46px;cursor: pointer;display: flex;align-items: center;justify-content: center;border-radius: 50%;transition: all .4s ease;border: none;box-shadow: inset 0 0 0 2px #ccc;color: #ccc;background-color: #fff;}.scroll-top.is-active {opacity: 1;visibility: visible;transform: translateY(0);}.scroll-top .icon-tabler-arrow-up {position: absolute;stroke-width: 2px;stroke: #333;}.scroll-top svg path {fill: none;}.scroll-top svg.progress-circle path {stroke: #333;stroke-width: 4;transition: all .4s ease;}.scroll-top:hover {color: var(--ghost-accent-color);}.scroll-top:hover .progress-circle path, .scroll-top:hover .icon-tabler-arrow-up {stroke: var(--ghost-accent-color);}
1921
</style>
2022
</head>
2123
<body class="bg-white font-sans leading-normal tracking-normal">
@@ -159,8 +161,18 @@ <h3 class="font-bold break-normal font-normal text-gray-600 text-base md:text-xl
159161

160162
</div>
161163

162-
163-
164+
<!-- Scroll Top Button -->
165+
<button class="btn-toggle-round scroll-top js-scroll-top" type="button" title="Scroll to top">
166+
<svg class="progress-circle" width="100%" height="100%" viewBox="-1 -1 102 102">
167+
<path d="M50,1 a49,49 0 0,1 0,98 a49,49 0 0,1 0,-98"/>
168+
</svg>
169+
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrow-up" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="cuurentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
170+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
171+
<line x1="12" y1="5" x2="12" y2="19" />
172+
<line x1="18" y1="11" x2="12" y2="5" />
173+
<line x1="6" y1="11" x2="12" y2="5" />
174+
</svg>
175+
</button>
164176

165177
<div class="bg-gray-200">
166178

@@ -294,6 +306,9 @@ <h3 class="font-bold break-normal font-normal text-gray-600 text-base md:text-xl
294306

295307
});
296308

309+
// scroll to top
310+
const t=document.querySelector(".js-scroll-top");if(t){t.onclick=()=>{window.scrollTo({top:0,behavior:"smooth"})};const e=document.querySelector(".scroll-top path"),o=e.getTotalLength();e.style.transition=e.style.WebkitTransition="none",e.style.strokeDasharray=`${o} ${o}`,e.style.strokeDashoffset=o,e.getBoundingClientRect(),e.style.transition=e.style.WebkitTransition="stroke-dashoffset 10ms linear";const n=function(){const t=window.scrollY||window.scrollTopBtn||document.documentElement.scrollTopBtn,n=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight),s=Math.max(document.documentElement.clientHeight,window.innerHeight||0);var l=o-t*o/(n-s);e.style.strokeDashoffset=l};n();const s=100;window.addEventListener("scroll",(function(e){n();(window.scrollY||window.scrollTopBtn||document.getElementsByTagName("html")[0].scrollTopBtn)>s?t.classList.add("is-active"):t.classList.remove("is-active")}),!1)}
311+
297312
</script>
298313

299314
</body>

0 commit comments

Comments
 (0)