You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
567 B
23 lines
567 B
import type { Ref } from 'vue';
|
|
import { onMounted, onUnmounted, ref } from 'vue';
|
|
import type { ScreenMap } from '../../_util/responsiveObserve';
|
|
import ResponsiveObserve from '../../_util/responsiveObserve';
|
|
|
|
function useBreakpoint(): Ref<ScreenMap> {
|
|
const screens = ref<ScreenMap>({});
|
|
let token = null;
|
|
onMounted(() => {
|
|
token = ResponsiveObserve.subscribe(supportScreens => {
|
|
screens.value = supportScreens;
|
|
});
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
ResponsiveObserve.unsubscribe(token);
|
|
});
|
|
|
|
return screens;
|
|
}
|
|
|
|
export default useBreakpoint;
|