2020-07-09 17:36:42 +02:00
|
|
|
<template>
|
2022-06-20 14:57:58 +02:00
|
|
|
<div :id="id" :style="nStyle"></div>
|
2020-07-09 17:36:42 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-06-20 14:57:58 +02:00
|
|
|
export default {
|
|
|
|
|
name: "OpenSeadreagonComponent",
|
|
|
|
|
props: {
|
|
|
|
|
id: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
options: {
|
|
|
|
|
type: Object,
|
|
|
|
|
},
|
|
|
|
|
nStyle: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data: function () {
|
|
|
|
|
return {
|
|
|
|
|
viewer: null,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
updated: function () {
|
|
|
|
|
if (this.viewer) {
|
|
|
|
|
this.viewer.destroy();
|
|
|
|
|
this.viewer = null;
|
2020-07-09 17:36:42 +02:00
|
|
|
}
|
2022-06-20 14:57:58 +02:00
|
|
|
if (this.id !== "openseadragon_undefined") this.setup();
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
options: {
|
|
|
|
|
handler(n, o) {
|
|
|
|
|
// Pour reload la preivew en cas d'upload d'un nouveau média
|
|
|
|
|
this.$forceUpdate();
|
|
|
|
|
},
|
|
|
|
|
deep: true, // Pour checker dans tout l'objet si il y a un changement
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
setup: function () {
|
|
|
|
|
if (!this.viewer && this.options) {
|
|
|
|
|
const _options = this.options;
|
|
|
|
|
_options.id = this.id;
|
|
|
|
|
this.viewer = new OpenSeadragon(_options);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2020-07-09 17:36:42 +02:00
|
|
|
</script>
|