Skip to content

Commit 229b6cb

Browse files
committed
feat: make version color bar sticky
1 parent 22cec58 commit 229b6cb

1 file changed

Lines changed: 63 additions & 18 deletions

File tree

web/src/views/home/HomePage.vue

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const searchHistory = useStorage<string[]>(
6363
const isSearchInputFocused = ref(false);
6464
const isSearchHistoryPanelOpen = ref(false);
6565
const stickyDiffResultRef = ref<HTMLElement>();
66+
const versionColorScrollRef = ref<HTMLElement>();
67+
const versionListScrollRef = ref<HTMLElement>();
6668
const isDiffResultSticky = ref(false);
6769
6870
const showSearchHistory = computed(
@@ -129,6 +131,22 @@ onMounted(updateStickyState);
129131
useEventListener(window, 'scroll', updateStickyState, { passive: true });
130132
useEventListener(window, 'resize', updateStickyState);
131133
134+
const syncScrollLeft = (
135+
source: HTMLElement | undefined,
136+
target: HTMLElement | undefined,
137+
) => {
138+
if (!source || !target || source.scrollLeft === target.scrollLeft) return;
139+
target.scrollLeft = source.scrollLeft;
140+
};
141+
142+
const syncVersionColorScroll = () => {
143+
syncScrollLeft(versionColorScrollRef.value, versionListScrollRef.value);
144+
};
145+
146+
const syncVersionListScroll = () => {
147+
syncScrollLeft(versionListScrollRef.value, versionColorScrollRef.value);
148+
};
149+
132150
const handleClearLocalCache = async () => {
133151
if (!window.confirm('Do you want to clear local data?')) return;
134152
await clearLocalCache();
@@ -276,34 +294,61 @@ const handleClearLocalCache = async () => {
276294
<div>{{ handleDiff.loading ? `STOP` : `DIFF` }}</div>
277295
</div>
278296
</div>
279-
<div ref="stickyDiffResultRef" pt="--gap" sticky top-0 bg-white>
297+
<div ref="stickyDiffResultRef" pt="--gap" sticky top-0 z-10 bg-white>
280298
<DiffResultList />
299+
<div
300+
ref="versionColorScrollRef"
301+
flex
302+
gap-16px
303+
overflow-x-auto
304+
hidden-scrollbar
305+
@scroll="syncVersionColorScroll"
306+
>
307+
<div
308+
v-for="item in androidVersionList"
309+
:key="item.version"
310+
flex-1
311+
min-w-120px
312+
>
313+
<div
314+
h-2px
315+
w-full
316+
flex
317+
:class="{
318+
'bg-cyan-200': !androidVersionColors[item.version].length,
319+
}"
320+
>
321+
<div
322+
v-for="bg in androidVersionColors[item.version]"
323+
:key="bg"
324+
h-full
325+
flex-1
326+
:style="{
327+
background: bg,
328+
}"
329+
></div>
330+
</div>
331+
</div>
332+
</div>
281333
</div>
282-
<div mb="--gap" flex gap-16px overflow-scroll hidden-scrollbar>
334+
<div
335+
ref="versionListScrollRef"
336+
mb="--gap"
337+
flex
338+
gap-16px
339+
overflow-x-auto
340+
hidden-scrollbar
341+
@scroll="syncVersionListScroll"
342+
>
283343
<div
284344
v-for="item in androidVersionList"
285345
:key="item.version"
286346
flex-1
347+
min-w-120px
287348
flex
288349
flex-col
289350
items-center
290351
>
291-
<div
292-
h-2px
293-
w-full
294-
flex
295-
:class="{ 'bg-cyan-200': !androidVersionColors[item.version].length }"
296-
>
297-
<div
298-
v-for="bg in androidVersionColors[item.version]"
299-
:key="bg"
300-
h-full
301-
flex-1
302-
:style="{
303-
background: bg,
304-
}"
305-
></div>
306-
</div>
307352
<div text-12px leading-16px font-600 flex justify-center gap-4px>
308353
<div>{{ item.version }}</div>
309354
<div

0 commit comments

Comments
 (0)