完善商店列表手风琴动画

nimaqu_dev
laurieryayoi 8 years ago
parent 2a55889199
commit 3e04234f0b

@ -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;
}

@ -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';
}
});
}

@ -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<dropDownButton.length;i++) {
dropDownButton[i].addEventListener('click',()=>{
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]);
}

Loading…
Cancel
Save