refactor(HistoryDatabase): simplify CTA button positioning and adjust layout for improved responsiveness

- Removed dynamic offset calculation for the CTA button, fixing its position.
- Updated card layout logic to ensure proper stacking and alignment.
- Increased minimum heights for both collapsed and expanded states to enhance visual consistency.
This commit is contained in:
666ghj 2025-12-31 18:05:04 +08:00
parent 2acdd7309b
commit 6fc0a0d9ad

View file

@ -10,10 +10,9 @@
<div class="gradient-overlay"></div>
</div>
<!-- CTA 按钮 -->
<!-- CTA 按钮 - 位置固定不变 -->
<div
class="cta-button"
:style="{ transform: `translateY(${ctaOffset}px)` }"
@click="toggleExpand"
>
<div class="cta-inner">
@ -101,7 +100,6 @@ const projects = ref([])
const loading = ref(true)
const isExpanded = ref(false)
const hoveringCard = ref(null)
const ctaOffset = ref(0)
const imageErrors = ref({}) //
// -
@ -135,18 +133,6 @@ const handleImageError = (event, index) => {
event.target.style.display = 'none'
}
// CTA
const calculateCtaOffset = () => {
if (!isExpanded.value) {
ctaOffset.value = 0
return
}
const rowCount = Math.ceil(projects.value.length / CARDS_PER_ROW)
// CTA
ctaOffset.value = -(rowCount * EXPANDED_ROW_HEIGHT + 100)
}
//
const getCardStyle = (index) => {
const total = projects.value.length
@ -187,14 +173,9 @@ const getCardStyle = (index) => {
const colInRow = index % CARDS_PER_ROW
const x = startX + colInRow * (CARD_WIDTH + CARD_GAP)
// translateY: . 230px.
// Row 0 is at the bottom? "Upward stacking logic (first row pushed up)".
// Assuming "first row pushed up" means visually higher.
// In CSS translate Y, negative is up.
// So row 0 should have the most negative Y? Or row 0 is at the bottom and subsequent rows stack up?
// "4" -> Row 1 is above Row 0.
// So Row 0 is at y=0 (or base), Row 1 is at y = -230px, etc.
const y = -(row * EXPANDED_ROW_HEIGHT)
// translateY: . 300px (280+).
// Row 0
const y = row * (CARD_HEIGHT + CARD_GAP)
return {
transform: `translate(${x}px, ${y}px) rotate(0deg) scale(1)`,
@ -277,17 +258,14 @@ const truncateText = (text, maxLength) => {
//
const handleMouseEnter = () => {
isExpanded.value = true
calculateCtaOffset()
}
const handleMouseLeave = () => {
isExpanded.value = false
ctaOffset.value = 0
}
const toggleExpand = () => {
isExpanded.value = !isExpanded.value
calculateCtaOffset()
}
//
@ -376,14 +354,13 @@ onMounted(() => {
pointer-events: none;
}
/* CTA 按钮 */
/* CTA 按钮 - 位置固定不变 */
.cta-button {
position: relative;
z-index: 100;
display: flex;
justify-content: center;
margin-bottom: 48px;
transition: transform 700ms cubic-bezier(0.23, 1, 0.32, 1); /* Match card duration */
cursor: pointer;
}
@ -430,14 +407,14 @@ onMounted(() => {
position: relative;
display: flex;
justify-content: center;
align-items: flex-end;
min-height: 340px;
align-items: flex-start; /* 从顶部开始排列 */
min-height: 420px; /* 折叠时的最小高度 */
padding: 0 40px;
transition: min-height 700ms cubic-bezier(0.23, 1, 0.32, 1); /* Match card duration */
}
.cards-container.expanded {
min-height: 520px;
min-height: 620px; /* 展开时增加高度,页面自动向下延长 */
}
/* 项目卡片 - 完全参照参考图 */