From e1e18fa93771893ce432cda49ad9c8b1c280dba6 Mon Sep 17 00:00:00 2001 From: xing Date: Thu, 2 Apr 2020 18:15:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=A7=BB=E5=8A=A8=E7=9A=84?= =?UTF-8?q?=E5=96=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tieba page.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/tieba page.js b/tieba page.js index b305acc..c5f8a87 100644 --- a/tieba page.js +++ b/tieba page.js @@ -440,6 +440,15 @@ }); } + function slio() { + let lis = document.querySelectorAll('#frslistcontent>li'); + lis.forEach(li => { + li.addEventListener('touchstart', evt => { + + }) + }) + } + function list() { delElement([ @@ -450,7 +459,6 @@ if (ads.length > 0) { let url = document.querySelector('.tl_shadow_for_app').parentNode.querySelector('a.j_common').href; ads.forEach(v => { - //v.classList.remove('tl_shadow_for_app'); let a = v.querySelector('a.j_enter_for_app'); let tid = v.getAttribute('data-tid'); a.href = url.replace(/\/(\d+)\?/.exec(url)[1], tid); @@ -732,7 +740,15 @@ function fnav() { let d = document.createElement('div'); - d.style.cssText = `position: fixed;width: 45px;right: 10px;bottom: 50px;`; + let startX; + let startY; + let sx = document.documentElement.clientWidth; + let sy = document.documentElement.clientHeight; + let tempX = localStorage.getItem('tiebaPageX'); + let endX = tempX ? tempX : 10; + let tempY = localStorage.getItem('tiebaPageY'); + let endY = tempX ? tempY : 50; + d.style.cssText = `position: fixed;width: 45px;right: ${endX}px;bottom: ${endY}px;z-index:1;`; d.innerHTML = ` @@ -750,6 +766,7 @@ `; let svgs = svgss = d.querySelectorAll('svg'); let f = 1; + let timer = null; function dd() { [svgs[0], svgs[1], svgs[2]].forEach(el => { @@ -758,10 +775,45 @@ f = f === 1 ? 2 : 1; } + function drop(e) { + e.preventDefault(); + e.stopPropagation(); + let touches = e.touches[0]; + let svg = e.target.parentNode.parentNode; + endX = sx - touches.clientX - Math.ceil(svg.offsetWidth / 2); + endY = sy - touches.clientY - Math.ceil(svg.offsetHeight / 2); + if (endX > sx - svg.offsetWidth) { + endX = sx - svg.offsetWidth + } else if (endX < 0) { + endX = 0; + } + if (endY > sy - svg.offsetHeight) { + endY = sy - svg.offsetHeight; + } else if (endY < 0) { + endY = 0; + } + svg.style.right = endX + "px"; + svg.style.bottom = endY + "px"; + } + svgs.forEach((value, key) => { if (key !== 3) { value.style.display = 'none'; + } else { + value.addEventListener('touchstart', ev => { + startX = ev.touches[0].clientX - (value.offsetLeft ? value.offsetLeft : 0); + startY = ev.touches[0].clientY - (value.offsetTop ? value.offsetTop : 0); + timer = setTimeout(() => { + value.addEventListener('touchmove', drop); + }, 600); + }); + value.addEventListener('touchend', ev => { + clearTimeout(timer); + localStorage.setItem('tiebaPageX', endX); + localStorage.setItem('tiebaPageY', endY); + value.removeEventListener('touchmove', drop); + }) } value.style.fill = 'rgba(77, 74, 210,.3)'; value.addEventListener('click', ev => {