44-->
55
66<script setup lang="ts">
7- import { computed , onMounted , onUnmounted } from ' vue'
7+ import { computed , onMounted , onUnmounted , ref } from ' vue'
88import { emit , subscribe , unsubscribe } from ' @nextcloud/event-bus'
99import { t } from ' @nextcloud/l10n'
1010
@@ -14,7 +14,6 @@ import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'
1414import DatePollIcon from ' vue-material-design-icons/CalendarBlank.vue'
1515import TextPollIcon from ' vue-material-design-icons/FormatListBulletedSquare.vue'
1616
17- import { useHandleScroll } from ' ../composables/handleScroll.ts'
1817import MarkDownDescription from ' ../components/Poll/MarkDownDescription.vue'
1918import ActionAddOption from ' ../components/Actions/modules/ActionAddOption.vue'
2019import PollInfoLine from ' ../components/Poll/PollInfoLine.vue'
@@ -34,12 +33,14 @@ import { Event } from '../Types/index.ts'
3433import Collapsible from ' ../components/Base/modules/Collapsible.vue'
3534import type { CollapsibleProps } from ' ../components/Base/modules/Collapsible.vue'
3635import { onBeforeRouteLeave , onBeforeRouteUpdate } from ' vue-router'
36+ import IntersectionObserver from ' ../components/Base/modules/IntersectionObserver.vue'
3737
3838const pollStore = usePollStore ()
3939const optionsStore = useOptionsStore ()
4040const preferencesStore = usePreferencesStore ()
4141const voteMainId = ' watched-scroll-area'
42- const scrolled = useHandleScroll (voteMainId )
42+ const topObserverVisible = ref (false )
43+ const voteHeaderDownPage = ref (false )
4344
4445const loadingOverlayProps = {
4546 name: t (' polls' , ' Loading poll…' ),
@@ -94,6 +95,10 @@ const collapsibleProps = computed<CollapsibleProps>(() => ({
9495 initialState: pollStore .currentUserStatus .countVotes === 0 ? ' max' : ' min' ,
9596}))
9697
98+ const scrolled = computed (
99+ () => ! topObserverVisible .value && voteHeaderDownPage .value ,
100+ )
101+
97102onBeforeRouteUpdate (async () => {
98103 pollStore .load ()
99104 emit (Event .TransitionsOff , 500 )
@@ -122,11 +127,11 @@ onUnmounted(() => {
122127 pollStore .viewMode ,
123128 voteMainId ,
124129 {
125- scrolled: scrolled ,
130+ scrolled ,
126131 ' vote-style-beta-510' : preferencesStore .user .useAlternativeStyling ,
127132 },
128133 ] " >
129- <HeaderBar >
134+ <HeaderBar class="sticky-top" : class = " { ' sticky-bottom-shadow ' : scrolled } " >
130135 <template #title >
131136 {{ pollStore.configuration.title }}
132137 </template >
@@ -139,6 +144,7 @@ onUnmounted(() => {
139144 </HeaderBar >
140145
141146 <div class =" vote_main" >
147+ <IntersectionObserver id="top-observer" v-model =" topObserverVisible " />
142148 <Collapsible
143149 v-if =" pollStore .configuration .description "
144150 class="sticky-left"
@@ -148,7 +154,9 @@ onUnmounted(() => {
148154
149155 <VoteInfoCards class="sticky-left" />
150156
151- <VoteTable v-show =" optionsStore .options .length " />
157+ <VoteTable
158+ v-show =" optionsStore .options .length "
159+ v-model :down-page =" voteHeaderDownPage " />
152160
153161 <NcEmptyContent
154162 v-if =" ! optionsStore .options .length "
0 commit comments