22import { Head , Link , router , usePage } from ' @inertiajs/vue3' ;
33import {
44 ArrowLeft ,
5+ ArrowUp ,
56 ArrowBigUp ,
67 User as UserIcon ,
78 X ,
@@ -12,7 +13,7 @@ import {
1213 Pencil ,
1314 MessageSquare ,
1415} from ' lucide-vue-next' ;
15- import { computed , ref , watch } from ' vue' ;
16+ import { computed , ref , watch , onMounted , onUnmounted } from ' vue' ;
1617
1718import NoteReader from ' @/components/resources/NoteReader.vue' ;
1819import PdfViewer from ' @/components/resources/PdfViewer.vue' ;
@@ -247,6 +248,42 @@ const totalCommentsCount = computed(() => {
247248
248249 return count ;
249250});
251+
252+ // Scroll to Top state & handlers
253+ const showScrollTop = ref (false );
254+
255+ const handleScroll = () => {
256+ if (typeof window === ' undefined' ) {
257+ return ;
258+ }
259+
260+ const scrollPos =
261+ window .scrollY ||
262+ document .documentElement ?.scrollTop ||
263+ document .body ?.scrollTop ||
264+ 0 ;
265+ showScrollTop .value = scrollPos > 300 ;
266+ };
267+
268+ const scrollToTop = () => {
269+ if (typeof window === ' undefined' ) {
270+ return ;
271+ }
272+
273+ window .scrollTo ({
274+ top: 0 ,
275+ behavior: ' smooth' ,
276+ });
277+ };
278+
279+ onMounted (() => {
280+ window .addEventListener (' scroll' , handleScroll , { passive: true });
281+ handleScroll ();
282+ });
283+
284+ onUnmounted (() => {
285+ window .removeEventListener (' scroll' , handleScroll );
286+ });
250287 </script >
251288
252289<template >
@@ -569,12 +606,8 @@ const totalCommentsCount = computed(() => {
569606 </p >
570607 </div >
571608
572- <!-- Quick Jump to Comments Bar (Ideal for long multi-image notes ) -->
609+ <!-- Quick Jump to Comments Bar (Available for all resource types ) -->
573610 <div
574- v-if ="
575- primaryFormat === 'image' &&
576- (resource.items || []).length > 2
577- "
578611 class =" mt-4 flex items-center justify-between rounded-2xl border border-slate-200/90 bg-white px-4 py-2.5 shadow-2xs dark:border-gray-800 dark:bg-gray-900"
579612 >
580613 <div
@@ -738,4 +771,25 @@ const totalCommentsCount = computed(() => {
738771 :subjects =" subjects || []"
739772 @save =" () => {} "
740773 />
774+
775+ <!-- Floating Scroll to Top Button -->
776+ <Transition
777+ enter-active-class="transition duration-150 ease-out"
778+ enter-from-class="opacity-0 translate-y-2 scale-95"
779+ enter-to-class="opacity-100 translate-y-0 scale-100"
780+ leave-active-class="transition duration-100 ease-in"
781+ leave-from-class="opacity-100 translate-y-0 scale-100"
782+ leave-to-class="opacity-0 translate-y-2 scale-95"
783+ >
784+ <button
785+ v-if =" showScrollTop"
786+ type =" button"
787+ @click =" scrollToTop"
788+ title =" উপরে যান"
789+ aria-label =" Scroll to top"
790+ class =" fixed right-4 bottom-[calc(4.5rem+env(safe-area-inset-bottom)+0.5rem)] z-50 flex h-9.5 w-9.5 cursor-pointer items-center justify-center rounded-full bg-slate-900/90 text-white shadow-lg ring-1 ring-black/10 backdrop-blur-xs transition duration-150 hover:scale-105 hover:bg-indigo-600 active:scale-95 sm:right-6 sm:bottom-6 sm:h-10 sm:w-10 dark:bg-gray-800/90 dark:text-gray-100 dark:ring-white/10 dark:hover:bg-indigo-600 dark:hover:text-white"
791+ >
792+ <ArrowUp class="h-4 w-4 stroke-[2.3 ]" />
793+ </button >
794+ </Transition >
741795</template >
0 commit comments