Skip to content

Commit

Permalink
fix: Adjust the store page scrolling behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Aug 5, 2024
1 parent f8f7057 commit 20a0ef7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 7 additions & 5 deletions xmcl-keystone-ui/src/components/StoreProjectExternal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
{{ t('modrinth.externalResources') }}
</v-subheader>
<div class="my-2 flex w-full flex-1 flex-grow-0 flex-wrap gap-4 px-4">
<a
<span
v-for="link of project.links"
:key="link.url"
:href="link.url"
class="flex flex-grow-0 items-center gap-1"
class="flex flex-grow-0 items-center"
>
<v-icon>open_in_new</v-icon> {{ link.name }}
</a>
<v-icon left>open_in_new</v-icon>
<a :href="link.url">
{{ link.name }}
</a>
</span>
</div>
</div>
</template>
Expand Down
12 changes: 12 additions & 0 deletions xmcl-keystone-ui/src/views/StoreEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const { push } = useRouter()
function ensureQuery(query: Record<string, string | (string| null)[] | null | undefined>) {
query.page = '1'
scrollToView()
if (!query.query) {
if (query.sort === '0') {
query.sort = '1'
Expand Down Expand Up @@ -486,6 +487,13 @@ const items = computed(() => {
// Scroll to the search result
const container = ref<any>(null)
const exploreHeader = ref<any | null>(null)
function scrollToView() {
const component = exploreHeader.value
const el = component?.$el as HTMLElement | undefined
if (el) {
el.scrollIntoView({ behavior: 'smooth' })
}
}
watch(items, () => {
if (query.value || gameVersion.value || modLoaders.value.length > 0 || _modrinthCategories.value.length > 0 || curseforgeCategory.value) {
// Scroll to the element
Expand All @@ -501,6 +509,10 @@ watch(items, () => {
}
})
watch(page, () => {
scrollToView()
})
// Hovered project
const hovered = ref(undefined as ExploreProject | undefined)
const onMouseEnter = (event: MouseEvent, proj: ExploreProject) => {
Expand Down

0 comments on commit 20a0ef7

Please sign in to comment.