diff options
author | Yaroslsav-95 <contact@yaroslavps.com> | 2018-10-08 10:30:16 +0300 |
---|---|---|
committer | Yaroslsav-95 <contact@yaroslavps.com> | 2018-10-08 10:30:16 +0300 |
commit | 7851ef3fd924987468b377b890cb37962805e6dc (patch) | |
tree | f3cf87e62f5dc9bad6b9d392a73ab7c5eec263da /weblog/static/weblog/js | |
parent | b8680d1de69535a8c10812fef44c15684501f0c5 (diff) | |
download | w3blog-7851ef3fd924987468b377b890cb37962805e6dc.tar.gz w3blog-7851ef3fd924987468b377b890cb37962805e6dc.zip |
floating sidebar
Diffstat (limited to 'weblog/static/weblog/js')
-rwxr-xr-x | weblog/static/weblog/js/weblog.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/weblog/static/weblog/js/weblog.js b/weblog/static/weblog/js/weblog.js index ff72827..654fb4a 100755 --- a/weblog/static/weblog/js/weblog.js +++ b/weblog/static/weblog/js/weblog.js @@ -12,6 +12,23 @@ function toggleNode(caller){ target.classList.toggle('show'); } +function floatSidebar(){ + var sidebar = document.querySelector(".weblog-sidebar.floating-sidebar"); + var sidebar_filler = document.querySelector(".sidebar-filler"); + var blog_content = document.querySelector(".blog-content"); + var offset = document.querySelector("nav").offsetHeight + + document.querySelector(".breadcrumb").offsetHeight; + if((document.body.scrollTop > offset || document.documentElement.scrollTop > offset)){ + sidebar.classList.add("float"); + sidebar.style.left = blog_content.offsetLeft + blog_content.offsetWidth + "px"; + sidebar_filler.classList.remove("hidden"); + } + else{ + sidebar.classList.remove("float"); + sidebar_filler.classList.add("hidden"); + } +} + function loadBlogPosts(url, page = 2, isinfinite = false){ var req = new XMLHttpRequest(); function insert(response, isinfinite){ |