@@ -231,9 +231,39 @@ const scrollToComments = () => {
231231
232232 const el = document .getElementById (' comments' );
233233
234- if (el ) {
235- el . scrollIntoView ({ behavior: ' smooth ' }) ;
234+ if (! el ) {
235+ return ;
236236 }
237+
238+ el .scrollIntoView ({ behavior: ' smooth' });
239+
240+ // For long multi-image notes (e.g. 50+ images), lazy image layout shifts
241+ // can cause the initial smooth scroll destination to fall short.
242+ // We poll and readjust until the comments section is within the viewport.
243+ let attempts = 0 ;
244+ const adjustScroll = () => {
245+ attempts ++ ;
246+ const target = document .getElementById (' comments' );
247+
248+ if (! target ) {
249+ return ;
250+ }
251+
252+ const rect = target .getBoundingClientRect ();
253+
254+ // If comments is still below the viewport bottom
255+ if (rect .top > window .innerHeight ) {
256+ target .scrollIntoView ({
257+ behavior: attempts > 1 ? ' auto' : ' smooth' ,
258+ });
259+
260+ if (attempts < 12 ) {
261+ setTimeout (adjustScroll , 250 );
262+ }
263+ }
264+ };
265+
266+ setTimeout (adjustScroll , 300 );
237267};
238268
239269const totalCommentsCount = computed (() => {
@@ -787,7 +817,7 @@ onUnmounted(() => {
787817 @click =" scrollToTop"
788818 title =" উপরে যান"
789819 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"
820+ class =" fixed right-4 bottom-[8 .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-20 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"
791821 >
792822 <ArrowUp class="h-4 w-4 stroke-[2.3 ]" />
793823 </button >
0 commit comments