Files
directus/app/src/composables/use-element-size
2020-11-09 12:29:01 -05:00
..
2020-07-29 11:24:52 -04:00
2020-07-29 11:24:52 -04:00
2020-08-11 11:24:14 -04:00

useElementSize

function useElementSize(element: Element): { width: Ref<number>, height: Ref<number> }

Allows you to reactively watch an elements width and height.

Usage

<template>
	<div ref="el">
		My size is: {{ width }} x {{ height }}
	</div>
</template>

<script lang="ts">
import { defineComponent } from '@vue/composition-api';
import { useElementSize } from '@/composables/use-element-size';

export default defineComponent({
	setup(props) {
		const el = ref<Element>(null);
		const { width, height } = useElementSize(el);
		return { el, width, height };
	}
});
</script>