summaryrefslogtreecommitdiff
path: root/src/client/app/common/size.ts
blob: 6abb3057470e68f6604110ef008fbe5905cfcce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export default {
	install(Vue) {
		Vue.directive('size', {
			inserted(el, binding) {
				const query = binding.value;
				const width = el.clientWidth;
				for (const q of query) {
					if (q.lt && (width <= q.lt)) {
						el.classList.add(q.class);
					}
					if (q.gt && (width >= q.gt)) {
						el.classList.add(q.class);
					}
				}
			}
		});
	}
};