n8n/packages/editor-ui/src/components/IntersectionObserved.vue
Milorad FIlipović 5059c57f4a
refactor(editor): Refactor utils files and mixins (#4654)
*  Added `utils` module. Moved `canvasHelpers` and old `utils.ts` file to it
*  Moved rest of utils and helpers
*  Fixing sytax errors
* 🔨 Refactoring new utils files
* 🔨 Organizing imports, adding comments and a bit more refactoring
* ✔️ Fixing tests
* 🔨 Moving mixins to `src`
2022-11-23 13:41:53 +01:00

31 lines
580 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>