Refactor brightness, contrast, and saturation filters into Vue props.

This commit is contained in:
Julian Stirling 2025-10-21 12:09:33 +01:00
parent 0be62d773d
commit 5c2d61baaa
3 changed files with 28 additions and 28 deletions

View file

@ -14,15 +14,25 @@ export default {
src: { src: {
type: String, type: String,
required: true required: true
},
brightness: {
type: Number,
required: true
},
contrast: {
type: Number,
required: true
},
saturation: {
type: Number,
required: true
} }
}, },
data: function() { data: function() {
return { return {
osdViewer: null, osdViewer: null
brightness: 1,
contrast: 1,
saturation: 1,
}; };
}, },
@ -32,6 +42,15 @@ export default {
handler(newVal) { handler(newVal) {
this.loadOpenSeaDragon(newVal); this.loadOpenSeaDragon(newVal);
} }
},
brightness() {
this.updateFilter();
},
contrast() {
this.updateFilter();
},
saturation() {
this.updateFilter();
} }
}, },

View file

@ -25,6 +25,9 @@
id="openseadragon" id="openseadragon"
ref="openseadragon" ref="openseadragon"
:src="selectedScanDZI" :src="selectedScanDZI"
:brightness="brightness"
:contrast="contrast"
:saturation="saturation"
/> />
</div> </div>
@ -42,7 +45,6 @@
max="1.8" max="1.8"
step="0.01" step="0.01"
v-model.number="brightness" v-model.number="brightness"
@input="updateViewerFilter"
/> />
</label> </label>
<label> <label>
@ -53,7 +55,6 @@
max="1.8" max="1.8"
step="0.01" step="0.01"
v-model.number="contrast" v-model.number="contrast"
@input="updateViewerFilter"
/> />
</label> </label>
<label> <label>
@ -64,7 +65,6 @@
max="2" max="2"
step="0.01" step="0.01"
v-model.number="saturation" v-model.number="saturation"
@input="updateViewerFilter"
/> />
</label> </label>
</div> </div>
@ -124,20 +124,10 @@ export default {
goFullscreen() { goFullscreen() {
this.$refs.openseadragon.openFullscreen(); this.$refs.openseadragon.openFullscreen();
}, },
updateViewerFilter() {
const viewer = this.$refs.openseadragon;
if (viewer) {
viewer.brightness = this.brightness;
viewer.contrast = this.contrast;
viewer.saturation = this.saturation;
viewer.updateFilter();
}
},
resetFilters() { resetFilters() {
this.brightness = 1; this.brightness = 1;
this.contrast = 1; this.contrast = 1;
this.saturation = 1; this.saturation = 1;
this.updateViewerFilter();
}, },
}, },
}; };

View file

@ -101,10 +101,7 @@ export default {
scans: [], scans: [],
ongoing: null, ongoing: null,
selectedScan: null, selectedScan: null,
osdViewer: null, osdViewer: null
brightness: 1,
contrast: 1,
saturation: 1,
}; };
}, },
@ -222,7 +219,7 @@ export default {
} else { } else {
this.modalError("Scan not stitched for viewing in webapp, please download or stitch"); this.modalError("Scan not stitched for viewing in webapp, please download or stitch");
} }
}, }
} }
} }
</script> </script>
@ -239,10 +236,4 @@ export default {
margin-bottom: 30px; margin-bottom: 30px;
} }
input[type="range"] {
pointer-events: auto;
z-index: 1001;
}
</style> </style>