From 3e04234f0b803246d7dddf0ca0aa2bc45fe658ab Mon Sep 17 00:00:00 2001 From: laurieryayoi <14360417+laurieryayoi@users.noreply.github.com> Date: Sun, 25 Nov 2018 04:20:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=95=86=E5=BA=97=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=89=8B=E9=A3=8E=E7=90=B4=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/theme/material/css/project.min.css | 3 +-- public/theme/material/js/project.min.js | 6 ++---- resources/views/material/user/shop.tpl | 24 +++++++++++++++-------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/public/theme/material/css/project.min.css b/public/theme/material/css/project.min.css index e14a5b8a..18961614 100755 --- a/public/theme/material/css/project.min.css +++ b/public/theme/material/css/project.min.css @@ -135,7 +135,7 @@ } .shop-drop .card-tag { flex-basis: 49%; - margin: 5px 0 0 0; + margin: 3px 0 3px 0; text-align: center; } .shop-flex .card { @@ -939,7 +939,6 @@ a.tag-gold,.tag-gold { .dropdown-area.dropdown-active { transform: scale(1,1); opacity: 1; - height: auto; } diff --git a/public/theme/material/js/project.min.js b/public/theme/material/js/project.min.js index dfbce523..c64464d2 100755 --- a/public/theme/material/js/project.min.js +++ b/public/theme/material/js/project.min.js @@ -101,17 +101,15 @@ $(function(){ function listenDown() { button.addEventListener("click",()=>{ if (!dropdownarea.classList.contains('dropdown-active')) { - // dropdownarea.classList.remove('dropdown-hide'); requestAnimationFrame(()=>{ dropdownarea.classList.add('dropdown-active'); }); + dropdownarea.style.height = dropdownarea.scrollHeight + parseInt(window.getComputedStyle(dropdownarea).paddingBottom) + 'px'; //我也不知道为什么少一个padding-bottom的长度 } else { requestAnimationFrame(()=>{ dropdownarea.classList.remove('dropdown-active'); }) - // setTimeout(()=>{ - // dropdownarea.classList.add('dropdown-hide'); - // },100); + dropdownarea.style.height = '0px'; } }); } diff --git a/resources/views/material/user/shop.tpl b/resources/views/material/user/shop.tpl index 1255fcfe..8da45176 100755 --- a/resources/views/material/user/shop.tpl +++ b/resources/views/material/user/shop.tpl @@ -268,16 +268,24 @@ function buy(id,auto) { let dropDownGridArea = document.querySelectorAll('.shop-gridarea'); let dropDownButton = document.querySelectorAll('.shop-table .card'); let dropDownArea = document.querySelectorAll('.dropdown-area'); - let buyButton = document.querySelectorAll('.btn.shop-btn'); for (let i=0;i{ - if (window.getComputedStyle(dropDownGridArea[i]).gridTemplateRows == dropDownButton[i].offsetHeight + 10 + 'px 0px 36px') { - dropDownGridArea[i].style.gridTemplateRows = 'auto auto'; - } else if (window.getComputedStyle(dropDownGridArea[i]).gridTemplateRows == dropDownButton[i].offsetHeight + 10 + 'px 0px') { - dropDownGridArea[i].style.gridTemplateRows = 'auto auto'; - } else { - dropDownGridArea[i].style.gridTemplateRows = 'auto 0px'; - } + let buttonMarginTop = parseInt(window.getComputedStyle(dropDownButton[i]).marginTop); + let buttonHeight = dropDownButton[i].offsetHeight + buttonMarginTop; + let buyHeight = dropDownGridArea[i].offsetHeight - buttonHeight; + if (window.getComputedStyle(dropDownGridArea[i]).gridTemplateRows == buttonHeight + 'px 0px ' + buyHeight + 'px') { + dropDownGridArea[i].style.gridTemplateRows = 'auto auto auto'; + } else if (window.getComputedStyle(dropDownGridArea[i]).gridTemplateRows == buttonHeight + 'px 0px') { + dropDownGridArea[i].style.gridTemplateRows = 'auto auto'; + } else { + let loop = setInterval(()=>{ + dropDownGridArea[i].style.gridTemplateRows = 'auto ' + (parseInt(window.getComputedStyle(dropDownGridArea[i]).gridTemplateRows.split(' ')[1]) - 13) + 'px';//没有办法只能这么算了 + if (parseInt(window.getComputedStyle(dropDownGridArea[i]).gridTemplateRows.split(' ')[1]) < 15) { + clearInterval(loop); + dropDownGridArea[i].style.gridTemplateRows = 'auto 0px'; + } + },10); + } }); custDropdown(dropDownButton[i], dropDownArea[i]); }