2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
id="vizContainer"
|
2022-04-15 17:00:08 +00:00
|
|
|
ref="el"
|
2022-05-06 15:52:37 +00:00
|
|
|
:class="{ fullscreen: isFullscreen }"
|
2022-04-15 14:24:30 +00:00
|
|
|
data-testid="visualizer"
|
2022-05-06 15:52:37 +00:00
|
|
|
@dblclick="toggleFullscreen"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2022-05-06 15:52:37 +00:00
|
|
|
<CloseModalBtn class="close" @click="hide"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineAsyncComponent, onMounted, ref } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
import initVisualizer from '@/utils/visualizer'
|
|
|
|
import { eventBus } from '@/utils'
|
|
|
|
|
2022-04-24 08:29:14 +00:00
|
|
|
const CloseModalBtn = defineAsyncComponent(() => import('@/components/ui/BtnCloseModal.vue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-05-06 15:52:37 +00:00
|
|
|
const el = ref<HTMLElement>()
|
2022-04-15 17:00:08 +00:00
|
|
|
const isFullscreen = ref(false)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const toggleFullscreen = () => {
|
2022-05-06 15:52:37 +00:00
|
|
|
isFullscreen.value ? document.exitFullscreen() : el.value?.requestFullscreen()
|
2022-04-15 17:00:08 +00:00
|
|
|
isFullscreen.value = !isFullscreen.value
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const hide = () => eventBus.emit('TOGGLE_VISUALIZER')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-05-06 15:52:37 +00:00
|
|
|
onMounted(() => {
|
|
|
|
try {
|
|
|
|
initVisualizer(el.value!)
|
|
|
|
} catch (e) {
|
|
|
|
// in e.g., DOM testing, the call will fail due to the lack of proper API support
|
|
|
|
}
|
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
#vizContainer {
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&.fullscreen {
|
|
|
|
// :fullscreen pseudo support is kind of buggy, so we use a class instead.
|
|
|
|
background: var(--color-bg-primary);
|
|
|
|
|
|
|
|
.close {
|
|
|
|
opacity: 0 !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.close {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
.close {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|