File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { throttle } from 'lodash-es'
2+ import { onBeforeUnmount , onMounted , ref } from 'vue'
3+
4+ export const useIsMobile = ( breakpoint : number = 768 ) => {
5+ const isMobile = ref < boolean > ( window . innerWidth < breakpoint )
6+ const handleResize = throttle ( ( ) => {
7+ isMobile . value = window . innerWidth < breakpoint
8+ } , 200 )
9+
10+ onMounted ( ( ) => {
11+ window . addEventListener ( 'resize' , handleResize )
12+ } )
13+ onBeforeUnmount ( ( ) => {
14+ window . removeEventListener ( 'resize' , handleResize )
15+ } )
16+ return { isMobile }
17+ }
Original file line number Diff line number Diff line change 349349 </div >
350350
351351 <!-- Floating Cart Button (Mobile Only) -->
352- <button @click =" scrollToCart"
352+ <button v-if = " !isMobile || (!sidebarOpen && isMobile) " @click =" scrollToCart"
353353 class =" fixed bottom-6 right-6 xl:hidden w-16 h-16 bg-emerald-600 hover:bg-emerald-700 rounded-full shadow-2xl flex items-center justify-center cursor-pointer transition-all duration-300 hover:scale-110 z-50" >
354354 <svg class =" w-7 h-7 text-white" fill =" none" stroke =" currentColor" viewBox =" 0 0 24 24" >
355355 <path stroke-linecap =" round" stroke-linejoin =" round" stroke-width =" 2"
@@ -374,10 +374,12 @@ import { useAuthStore } from '@/stores/auth.store'
374374import { useI18n } from ' vue-i18n'
375375import { setLocale } from ' @/plugins/i18n'
376376import type { Locale } from ' @/locales'
377+ import { useIsMobile } from ' @/composables/isMobile.composable'
377378
378379// Cart store
379380const cart = useCartStore ()
380381const authStore = useAuthStore ()
382+ const { isMobile } = useIsMobile ()
381383const { t } = useI18n ()
382384
383385// Sidebar
You can’t perform that action at this time.
0 commit comments