Skip to content

Commit

Permalink
fix(XaiImage): Use props.src properly
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Sep 19, 2023
1 parent b2dc4df commit d563ae5
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions vue-components/src/components/TrameXaiImage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import XaiHeatMap from "./TrameXaiHeatMap";

const { ref, toRefs, reactive, computed, onBeforeUnmount, watch } = window.Vue;
const { ref, toRefs, reactive, computed, onBeforeUnmount, watch, watchEffect } =
window.Vue;

export default {
components: {
Expand Down Expand Up @@ -119,7 +120,6 @@ export default {
// Methods ----------------------------------------------------------------

function updateSizes() {
console.log("updateSizes");
imageStyle.height = "auto";
imageStyle.width = "auto";
const annotationStyleTmp = { ...annotationStyle.value };
Expand Down Expand Up @@ -186,28 +186,22 @@ export default {
imageHeight.value = this.height;
}

// Watch ------------------------------------------------------------------
watch(
() => props.url,
(url) => (image.src = url)
);
watch(() => props.maxWidth, updateSizes);
watch(() => props.maxHeight, updateSizes);

// Created ----------------------------------------------------------------

image.addEventListener("load", updateImageSize);
image.src = props.src;

onBeforeUnmount(() => {
image.removeEventListener("load", updateImageSize);
});

updateSizes();
// Watch ------------------------------------------------------------------
watchEffect(() => (image.src = props.src));
watch(() => props.maxWidth, updateSizes);
watch(() => props.maxHeight, updateSizes);

// Public API -------------------------------------------------------------

expose({ updateAreaSelection });
updateSizes();

return {
// props
Expand Down

0 comments on commit d563ae5

Please sign in to comment.