Skip to content

Instantly share code, notes, and snippets.

@brianmichel
Created November 6, 2022 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmichel/a5913844c7c1551b03154611f3cb4882 to your computer and use it in GitHub Desktop.
Save brianmichel/a5913844c7c1551b03154611f3cb4882 to your computer and use it in GitHub Desktop.
A strange Safari animation
<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