11<template >
2- <div id =" bot-ui" >
2+ <div id =" bot-ui" :style = " { bottom: dynamicBottom + 'px' } " >
33 <!-- Conditionally show toggle button with highlight -->
44 <div class =" toggle-container" v-show =" !(isMobile && showChat)" >
55 <div v-if =" !showChat" class =" pulse-ring" ></div >
@@ -88,6 +88,8 @@ export default {
8888 windowWidth: 0 , // Changed from window.innerWidth to avoid SSR error
8989 showTooltip: true ,
9090 tooltipDismissDuration: 2 * 60 * 60 * 1000 , // 2 hours in milliseconds
91+ dynamicBottom: 20 , // Default bottom position
92+ stopFromBottom: 110 , // Stop 100px from page bottom
9193 };
9294 },
9395 computed: {
@@ -100,11 +102,14 @@ export default {
100102 },
101103 mounted () {
102104 window .addEventListener (" resize" , this .handleResize );
105+ window .addEventListener (" scroll" , this .handleScroll );
103106 this .handleResize (); // Set initial windowWidth on client-side
107+ this .handleScroll (); // Set initial bottom position
104108 this .updateTooltipVisibility (); // Check tooltip dismissal state on mount
105109 },
106110 beforeUnmount () {
107111 window .removeEventListener (" resize" , this .handleResize );
112+ window .removeEventListener (" scroll" , this .handleScroll );
108113 },
109114 methods: {
110115 toggleChat () {
@@ -116,6 +121,20 @@ export default {
116121 },
117122 handleResize () {
118123 this .windowWidth = window .innerWidth ;
124+ this .handleScroll (); // Recalculate position on resize
125+ },
126+ handleScroll () {
127+ // Only apply scroll positioning on desktop
128+ if (this .isMobile ) {
129+ this .dynamicBottom = 15 ;
130+ return ;
131+ }
132+ const distanceToPageBottom =
133+ document .documentElement .scrollHeight -
134+ window .scrollY -
135+ window .innerHeight ;
136+ // Keep element at least stopFromBottom pixels from the page bottom
137+ this .dynamicBottom = Math .max (20 , this .stopFromBottom - distanceToPageBottom);
119138 },
120139 onIframeLoad () {
121140 this .isLoading = false ;
0 commit comments