Files
pqs-9100_client/frontend/src/hooks/useViewSize.ts

36 lines
833 B
TypeScript
Raw Normal View History

2024-10-28 13:25:45 +08:00
import { ref } from 'vue'
export const useViewSize = () => {
const popupBaseView = ref(null)
2024-11-01 13:29:00 +08:00
const viewWidth = ref(0)
const viewHeight = ref(0)
2024-10-28 13:25:45 +08:00
/**
*
*/
const updateDimensions = () => {
if (popupBaseView.value) {
2024-11-01 13:29:00 +08:00
viewWidth.value = popupBaseView.value.offsetWidth
viewHeight.value = popupBaseView.value.offsetHeight
2024-10-28 13:25:45 +08:00
}
}
/**
*
*/
onMounted(() => {
updateDimensions()
window.addEventListener('resize', updateDimensions)
})
/**
*
*/
onUpdated(() => {
updateDimensions()
})
return { popupBaseView, viewWidth, viewHeight }
}