From a1e1b30df73b8138e77961f00c40797478e68763 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Fri, 25 Mar 2022 17:14:17 +1100 Subject: Simplify transition code --- src/components/TileInfoModal.vue | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) (limited to 'src/components/TileInfoModal.vue') diff --git a/src/components/TileInfoModal.vue b/src/components/TileInfoModal.vue index 367546d..fedd933 100644 --- a/src/components/TileInfoModal.vue +++ b/src/components/TileInfoModal.vue @@ -4,34 +4,13 @@ import {TolNode} from '../lib'; export default defineComponent({ props: { - tolNode: {type: Object as PropType}, // The node to display, or null to hide + tolNode: {type: Object as PropType}, options: {type: Object, required: true}, }, - data(){ - return { - lastNode: null as TolNode | null, // Caches tolNode to prevent content-change during fade-out - }; - }, - watch: { - tolNode(newNode){ - if (newNode != null){ - this.lastNode = newNode; - } - }, - }, computed: { - transitionStyles(): Record { - return { - visibility: this.tolNode != null ? 'visible' : 'hidden', - opacity: this.tolNode != null ? '1' : '0', - transition: 'visibility, opacity', - transitionDuration: this.options.transitionDuration + 'ms', - }; - }, imgStyles(): Record { return { - backgroundImage: this.lastNode == null ? 'none' : - 'url(\'/img/' + this.lastNode.name.replaceAll('\'', '\\\'') + '.png\')', + backgroundImage: 'url(\'/img/' + this.tolNode.name.replaceAll('\'', '\\\'') + '.png\')', width: this.options.infoModalImgSz + 'px', height: this.options.infoModalImgSz + 'px', backgroundSize: 'cover', @@ -46,18 +25,18 @@ export default defineComponent({ } }, }, - emits: ['info-modal-close'] + emits: ['info-modal-close'], });