This commit is contained in:
2024-10-03 16:22:20 +09:00
parent e512da9a48
commit d865938430
62 changed files with 931 additions and 905 deletions

View File

@@ -3,12 +3,15 @@
* @module composables/windowDimensions
*/
const tabletMaxWidth = 1024;
const mobileMaxWidth = 640;
/**
* Enums for viewport types
* @readonly
* @enum {number}
*/
export const enum ViewPortType {
const enum ViewPortType {
DESKTOP,
TABLET,
MOBILE,
@@ -18,7 +21,7 @@ export const enum ViewPortType {
* Vue Composable for getting window dimensions and viewport type based on width
* @returns {object} returns the references of width, height, and viewport type
*/
export function useWindowDimensions() {
function useWindowDimensions() {
const width = ref<number>(0);
const height = ref<number>(0);
const viewPortType = ref<ViewPortType>(ViewPortType.DESKTOP);
@@ -26,9 +29,9 @@ export function useWindowDimensions() {
function update(event: Event | undefined) {
width.value = window.innerWidth;
height.value = window.innerHeight;
if (width.value >= 1024) {
if (width.value >= tabletMaxWidth) {
viewPortType.value = ViewPortType.DESKTOP;
} else if (width.value < 640) {
} else if (width.value < mobileMaxWidth) {
viewPortType.value = ViewPortType.MOBILE;
} else {
viewPortType.value = ViewPortType.TABLET;
@@ -44,3 +47,5 @@ export function useWindowDimensions() {
return { width, height, viewPortType };
}
export { useWindowDimensions, ViewPortType };