Skip to content

Commit

Permalink
timeline: fix top overlay on albums
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Apr 4, 2024
1 parent 6b45773 commit ac55fad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/Timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
<EmptyContent v-if="showEmpty" />

<!-- Top overlay showing date -->
<TimelineTopOverlay ref="topOverlay" :heads="heads" :container="refs.container?.$el" />
<TimelineTopOverlay
ref="topOverlay"
:heads="heads"
:container="refs.container?.$el"
:recycler="refs.recycler?.$el"
/>
<!-- Main recycler view for rows -->
<RecycleScroller
Expand Down
15 changes: 13 additions & 2 deletions src/components/top-matter/TimelineTopOverlay.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="top-overlay" :class="{ show: !!text }">{{ text }}</div>
<div class="top-overlay" :style="{ top }" :class="{ show: !!text }">{{ text }}</div>
</template>

<script lang="ts">
Expand All @@ -12,6 +12,7 @@ export default defineComponent({
data: () => ({
text: String(),
top: String(),
}),
props: {
Expand All @@ -24,6 +25,11 @@ export default defineComponent({
type: Element,
required: false,
},
recycler: {
type: Element,
required: false,
},
},
methods: {
Expand All @@ -32,13 +38,18 @@ export default defineComponent({
},
getText() {
// Get position of recycler
const rrect = this.recycler?.getBoundingClientRect();
if (!rrect) return; // ??
// Get position of container
const crect = this.container?.getBoundingClientRect();
if (!crect) return; // ??
this.top = `${rrect.top - crect.top}px`;
// Get photo just below the top of the container
const elem: any = document
.elementsFromPoint(crect.left + 5, crect.top + 50)
.elementsFromPoint(rrect.left + 5, rrect.top + 50)
.find((e) => e.classList.contains('p-outer-super'));
const overPhoto: IPhoto | null = elem?.__vue__?.data;
Expand Down

0 comments on commit ac55fad

Please sign in to comment.