Skip to content

Commit

Permalink
wip: Refactor catalog based panel #919
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Aug 22, 2024
1 parent 9bd3ed9 commit 2168886
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
11 changes: 5 additions & 6 deletions core/client/components/collection/KScrollDown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<script setup>
import { ref, watch } from 'vue'
import { useQuasar, scroll } from 'quasar'
import { useQuasar, scroll as qScroll } from 'quasar'
import { clamp } from '../../utils'
// Props
Expand Down Expand Up @@ -50,7 +50,6 @@ const props = defineProps({
// Data
const $q = useQuasar()
const { setVerticalScrollPosition, getVerticalScrollPosition, getScrollHeight } = scroll
const isVisible = ref(false)
// Watch
Expand All @@ -63,20 +62,20 @@ function refresh () {
const targetElement = document.getElementById(props.target)
if (!targetElement) return
const containerHeight = targetElement.offsetHeight
const scrollHeight = getScrollHeight(targetElement)
const scrollHeight = qScroll.getScrollHeight(targetElement)
const diff = scrollHeight - containerHeight
if (diff <= 0) isVisible.value = false
else {
const ratio = clamp(getVerticalScrollPosition(targetElement) / diff, 0, 1)
const ratio = clamp(qScroll.getVerticalScrollPosition(targetElement) / diff, 0, 1)
const percent = Math.round(ratio * 10000) / 10000
isVisible.value = percent < 1
}
}
function scrollOnce () {
const targetElement = document.getElementById(props.target)
if (!targetElement) return
const position = getVerticalScrollPosition(targetElement)
setVerticalScrollPosition(targetElement, position + targetElement.offsetHeight, props.duration)
const position = qScroll.getVerticalScrollPosition(targetElement)
qScroll.setVerticalScrollPosition(targetElement, position + targetElement.offsetHeight, props.duration)
refresh()
}
Expand Down
7 changes: 3 additions & 4 deletions core/client/components/collection/KScrollToTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<script setup>
import { ref, watch } from 'vue'
import { useQuasar, scroll } from 'quasar'
import { useQuasar, scroll as qScroll } from 'quasar'
// Props
const props = defineProps({
Expand Down Expand Up @@ -43,7 +43,6 @@ const props = defineProps({
// Data
const $q = useQuasar()
const { setVerticalScrollPosition, getVerticalScrollPosition } = scroll
const isVisible = ref(false)
// Watch
Expand All @@ -55,12 +54,12 @@ watch(() => [$q.screen.width, $q.screen.height], () => {
function refresh () {
const targetElement = document.getElementById(props.target)
if (!targetElement) return
isVisible.value = getVerticalScrollPosition(targetElement) > 0
isVisible.value = qScroll.getVerticalScrollPosition(targetElement) > 0
}
function scrollToTop () {
const targetElement = document.getElementById(props.target)
if (!targetElement) return
setVerticalScrollPosition(targetElement, 0, props.duration)
qScroll.setVerticalScrollPosition(targetElement, 0, props.duration)
refresh()
}
Expand Down
1 change: 1 addition & 0 deletions map/client/components/catalog/KProjectsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:base-query="baseQuery"
:filter-query="filter.query"
:dense="true"
:scrollToTop="false"
:header="toolbar"
header-class="full-width no-wrap"
@selection-changed="onProjectSelected"
Expand Down
1 change: 1 addition & 0 deletions map/client/components/catalog/KViewsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:base-query="baseQuery"
:filter-query="filterQuery"
:dense="true"
:scrollToTop="false"
:header="toolbar"
header-class="full-width no-wrap"
@selection-changed="onViewSelected"
Expand Down

0 comments on commit 2168886

Please sign in to comment.