n8n/packages/editor-ui/src/components/IntersectionObserved.vue
Iván Ovejero 5ca2148c7e
refactor(editor): Apply Prettier (no-changelog) (#4920)
*  Adjust `format` script

* 🔥 Remove exemption for `editor-ui`

* 🎨 Prettify

* 👕 Fix lint
2022-12-14 10:04:10 +01:00

30 lines
579 B
Vue

<template>
<span ref="observed">
<slot></slot>
</span>
</template>
<script lang="ts">
import mixins from 'vue-typed-mixins';
import emitter from '@/mixins/emitter';
export default mixins(emitter).extend({
name: 'IntersectionObserved',
props: ['enabled'],
mounted() {
if (!this.$props.enabled) {
return;
}
this.$nextTick(() => {
this.$dispatch('IntersectionObserver', 'observe', this.$refs.observed);
});
},
beforeDestroy() {
if (this.$props.enabled) {
this.$dispatch('IntersectionObserver', 'unobserve', this.$refs.observed);
}
},
});
</script>