浏览代码

improve wwads

ruki 2 年之前
父节点
当前提交
3e1f5a4042
共有 1 个文件被更改,包括 15 次插入12 次删除
  1. 15 12
      index.html

+ 15 - 12
index.html

@@ -100,24 +100,27 @@
               + '\n\n----\n\n'
               + '<a href="https://tboox.org" target="_blank" style="color: inherit; font-weight: normal; text-decoration: none;">Copyright (c) 2015-present xmake.io and tboox.org</a>'
           })
-          /*
           hook.afterEach(function (html) {
             html += '<div id="floating-panel" class="wwads-cn wwads-vertical wwads-sticky" data-id="239" style="max-width:180px"></div>';
             return html;
           });
           hook.doneEach(function () {
             var panel = document.getElementById('floating-panel');
-            var content = document.querySelector('.content');
-            var contentRect = content.getBoundingClientRect();
-            panel.style.bottom = '20px';
-            panel.style.right = '20px';
-            panel.style.width = '200px';
-            panel.style.height = '200px';
-            panel.style.position = 'fixed';
-            panel.style.background = '#fff';
-            panel.style.boxShadow = '0 0 5px rgba(0, 0, 0, 0.3)';
-            panel.innerHTML = '<p></p>';
-          });*/
+            var cover = document.querySelector('.cover');
+            var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
+            if (!isMobile && cover && !cover.checkVisibility()) {
+              panel.style.bottom = '20px';
+              panel.style.right = '20px';
+              panel.style.width = '200px';
+              panel.style.height = '260px';
+              panel.style.position = 'fixed';
+              panel.style.background = '#fff';
+              panel.style.boxShadow = '0 0 5px rgba(0, 0, 0, 0.3)';
+              panel.innerHTML = '<p></p>';
+            } else {
+              panel.style.display = 'none';
+            }
+          });
         },
         DocsifyCarbon.create('CE7I52QU', 'xmakeio')
       ]