Skip to content

Commit

Permalink
Improve subscription & unsubscription logic
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 committed Oct 6, 2024
1 parent 1252f3d commit 49a7307
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
}">
<div
v-if="config.imageUrl || config.imageSrcSet"
v-show="!config.embedSvg || embeddedSvgReady"
ref="canvasBackground"
style="
height: inherit;
Expand Down Expand Up @@ -169,10 +170,10 @@

<script>
import mixin from '../widget-mixin'
import OhCanvasLayer from './oh-canvas-layer'
import { OhCanvasLayoutDefinition } from '@/assets/definitions/widgets/layout'
import { basicActionsMixin } from '@/components/widgets/widget-basic-actions'
import embeddedSvgMixin from '@/components/widgets/layout/oh-canvas-embedded-svg-mixin'
import OhCanvasLayer from './oh-canvas-layer'
import { OhCanvasLayoutDefinition } from '@/assets/definitions/widgets/layout'
export default {
emits: ['svgOnClickConfigUpdate'],
Expand Down Expand Up @@ -225,27 +226,26 @@ export default {
this.$fullscreen.support = true
this.canvasLayoutStyle()
this.computeLayout()
},
mounted () {
// Chrome reports a wrong size in fullscreen, store initial resolution and use non-dynamically.
this.windowWidth = window.screen.width
this.windowHeight = window.screen.height
if (this.config.embedSvg) {
if (!this.embeddedSvgReady) {
this.embedSvg().then(() => {
this.subscribeEmbeddedSvgListeners()
this.setupEmbeddedSvgStateTracking()
this.embeddedSvgReady = true
})
} else {
this.embedSvg().then(() => {
this.subscribeEmbeddedSvgListeners()
this.setupEmbeddedSvgStateTracking()
}
this.embeddedSvgReady = true
})
}
},
mounted () {
// Chrome reports a wrong size in fullscreen, store initial resolution and use non-dynamically.
this.windowWidth = window.screen.width
this.windowHeight = window.screen.height
},
beforeDestroy () {
if (!this.context.editmode) {
window.removeEventListener('resize', this.setDimensions)
}
if (this.config.embedSvg && this.embeddedSvgReady) {
this.embeddedSvgReady = false
this.unsubscribeEmbeddedSvgListeners()
this.unsubscribeEmbeddedSvgStateTracking()
}
Expand Down

0 comments on commit 49a7307

Please sign in to comment.