yumechi-no-kuni/src/client/app/common/size.ts

19 lines
357 B
TypeScript
Raw Normal View History

2019-02-15 17:51:35 -06:00
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);
}
}
}
});
}
};