Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
:class="{
dragging,
loaded,
zoomed: zoomRatio > 1
zoomed: zoomRatio > 1,
embedded: isEmbedded
}"
:src="data"
:style="imgStyle"
Expand All @@ -36,7 +37,8 @@
:class="{
dragging,
loaded,
zoomed: zoomRatio > 1
zoomed: zoomRatio > 1,
embedded: isEmbedded
}"
:style="imgStyle"
:playsinline="true"
Expand Down Expand Up @@ -134,6 +136,10 @@ export default {
return this.basename
},
imgStyle() {
// let CSS size the element instead of forcing dimensions in JS
if (this.isEmbedded) {
return {}
}
if (this.zoomRatio === 1) {
return {
height: this.zoomHeight + 'px',
Expand Down Expand Up @@ -492,6 +498,14 @@ img, video {
transition: none !important;
cursor: move;
}

&.embedded {
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
object-fit: contain;
}
}

.live-photo_play_button {
Expand Down
10 changes: 10 additions & 0 deletions src/mixins/Mime.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ export default {
type: Number,
default: undefined,
},
// is the component mounted outside of the viewer modal?
isEmbedded: {
type: Boolean,
default: false,
},
},

data() {
Expand Down Expand Up @@ -157,6 +162,11 @@ export default {
* based on the viewer maximum size
*/
updateHeightWidth() {
// let CSS size the element when mounted outside of the viewer modal
if (this.isEmbedded) {
return
}

const modalWrapper = this.$parent.$el.querySelector('.modal-wrapper')
if (modalWrapper && this.naturalHeight > 0 && this.naturalWidth > 0) {
const modalContainer = modalWrapper.querySelector('.modal-container')
Expand Down
Loading