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]); }