{"id":7972,"date":"2021-06-30T22:20:08","date_gmt":"2021-06-30T19:20:08","guid":{"rendered":"https:\/\/elzero.org\/?p=7972"},"modified":"2022-09-28T18:02:05","modified_gmt":"2022-09-28T15:02:05","slug":"tutorials-scroll-to-top-button","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/tutorials-scroll-to-top-button\/","title":{"rendered":"Scroll To Top Button"},"content":{"rendered":"<h3>\u0627\u0644 Code<\/h3>\r\n\r\n<script type=\"text\/plain\" class=\"language-html\">\r\n<span class=\"up\">Up<\/span>\r\n<\/script>\r\n\r\n<script type=\"text\/plain\" class=\"language-css\">\r\nbody {\r\n  height: 5000px;\r\n}\r\n.up {\r\n  position: fixed;\r\n  bottom: 10px;\r\n  right: -30px;\r\n  background-color: #ff5722;\r\n  color: white;\r\n  font-weight: bold;\r\n  font-size: 12px;\r\n  padding: 5px;\r\n  border-radius: 4px;\r\n  font-family: Arial, Tahoma;\r\n  cursor: pointer;\r\n  transition: 0.2s;\r\n}\r\n.up.show {\r\n  right: 10px;\r\n}\r\n<\/script>\r\n\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\nlet span = document.querySelector(\".up\");\r\n\r\nwindow.onscroll = function () {\r\n  \/\/ console.log(this.scrollY);\r\n  \/\/ if (this.scrollY >= 1000) {\r\n  \/\/   span.classList.add(\"show\");\r\n  \/\/ } else {\r\n  \/\/   span.classList.remove(\"show\");\r\n  \/\/ }\r\n  this.scrollY >= 1000 ? span.classList.add(\"show\") : span.classList.remove(\"show\");\r\n};\r\n\r\nspan.onclick = function () {\r\n  window.scrollTo({\r\n    top: 0,\r\n    behavior: \"smooth\",\r\n  });\r\n};\r\n\r\n<\/script>","protected":false},"excerpt":{"rendered":"<p>\u0627\u0644 Code<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[879],"tags":[],"class_list":["post-7972","post","type-post","status-publish","format-standard","hentry","category-front-end-tutorials"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/7972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=7972"}],"version-history":[{"count":1,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/7972\/revisions"}],"predecessor-version":[{"id":7973,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/7972\/revisions\/7973"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=7972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=7972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=7972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}