Another attempt at getting the trade flipping and collapsing looking correct
This commit is contained in:
parent
7c62c57433
commit
37d8bd5981
7 changed files with 386 additions and 233 deletions
|
|
@ -124,61 +124,4 @@ const $$ = selector => Array.from(document.querySelector(selector));
|
|||
resetCardMultiselectState();
|
||||
}
|
||||
});
|
||||
|
||||
// Expose tradeOfferCard globally if not already defined.
|
||||
if (!window.tradeOfferCard) {
|
||||
window.tradeOfferCard = function() {
|
||||
return {
|
||||
flipped: false,
|
||||
show_back: false,
|
||||
collapsed: false,
|
||||
/*
|
||||
* flipWithCollapse() now applies the height transition directly on the visible card face.
|
||||
* It measures the current face (front or back) and the target face's height,
|
||||
* then animates the current face's height change before toggling the flip.
|
||||
*
|
||||
* Make sure your template markup includes:
|
||||
* - x-ref="front" on the front card face
|
||||
* - x-ref="back" on the back card face
|
||||
*/
|
||||
flipWithCollapse() {
|
||||
// Determine the currently visible face and the target face.
|
||||
const currentFace = this.flipped ? this.$refs.back : this.$refs.front;
|
||||
const targetFace = this.flipped ? this.$refs.front : this.$refs.back;
|
||||
const container = this.$refs.container;
|
||||
|
||||
// Temporarily force target face to display to measure its height.
|
||||
const originalHeight = targetFace.style.height;
|
||||
const originalDisplay = targetFace.style.display;
|
||||
const originalPosition = targetFace.style.position;
|
||||
const originalVisibility = targetFace.style.visibility;
|
||||
targetFace.style.height = 'auto';
|
||||
targetFace.style.display = 'block';
|
||||
targetFace.style.position = 'absolute';
|
||||
targetFace.style.visibility = 'hidden';
|
||||
const targetHeight = targetFace.offsetHeight + 18;
|
||||
targetFace.style.height = originalHeight;
|
||||
targetFace.style.display = originalDisplay;
|
||||
targetFace.style.position = originalPosition;
|
||||
targetFace.style.visibility = originalVisibility;
|
||||
|
||||
container.setAttribute('x-collapse.duration.500ms.min.' + targetHeight + 'px', '');
|
||||
this.collapsed = true;
|
||||
setTimeout(() => {
|
||||
this.show_back = this.flipped;
|
||||
this.flipped = !this.flipped;
|
||||
setTimeout(() => {
|
||||
this.show_back = !this.show_back;
|
||||
}, 250)
|
||||
setTimeout(() => {
|
||||
this.collapsed = false;
|
||||
setTimeout(() => {
|
||||
container.removeAttribute('x-collapse.duration.500ms.min.' + targetHeight + 'px');
|
||||
}, 550);
|
||||
}, 550);
|
||||
}, 550);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue