Created
November 6, 2022 15:04
-
-
Save brianmichel/a5913844c7c1551b03154611f3cb4882 to your computer and use it in GitHub Desktop.
A strange Safari animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="media-container" :style="dimensions"> | |
<img :src="'/media/' + photo.name + '_preview.jpg'" /> | |
</div> | |
</template> | |
<script lang="js"> | |
import { defineComponent } from "vue"; | |
export default defineComponent({ | |
name: "Detail", | |
inject: ['store'], | |
computed: { | |
photo() { | |
return this.store.photoForName(this.$route.params.filename); | |
}, | |
dimensions() { | |
return { | |
"--image-aspect-ratio": | |
this.photo.sizes.preview.width + | |
" / " + | |
this.photo.sizes.preview.height, | |
"--image-height": this.photo.sizes.preview.height + "px", | |
"--image-width": this.photo.sizes.preview.width + "px", | |
}; | |
} | |
}, | |
components: { | |
}, | |
}); | |
</script> | |
<style scoped lang="scss"> | |
.media-container { | |
aspect-ratio: var(--image-aspect-ratio); | |
display: flex; | |
flex-direction: column; | |
justify-content: center; | |
align-content: center; | |
} | |
img { | |
max-height: 90vh; | |
max-width: 100%; | |
object-fit: contain; | |
margin: 10px; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment