Add simple 360 viewer
This commit is contained in:
@@ -1 +1 @@
|
|||||||
[{"name":"Album 1 name","description":"Album 2 description","protected":false,"coverFileName":"IMG_20200811_060850.jpg","photoDescription":{"IMG_20200811_060850.jpg":"Description 1","IMG_20200811_074445.jpg":"Description 2"},"folderName":"album_1","files":["IMG_20200811_060850.jpg","IMG_20200811_074445.jpg","IMG_20200811_080037.jpg","IMG_20200811_081746.jpg","IMG_20200811_084017.jpg"],"files_360":["photo.jpg"]}]
|
[{"name":"Album 1 name","description":"Album 2 description","protected":false,"coverFileName":"IMG_20200811_060850.jpg","photoDescription":{"IMG_20200811_060850.jpg":"Description 1","IMG_20200811_074445.jpg":"Description 2"},"folderName":"album_1","files":["IMG_20200811_060850.jpg","IMG_20200811_074445.jpg","IMG_20200811_080037.jpg","IMG_20200811_081746.jpg","IMG_20200811_084017.jpg"],"files_360":["360-Video-Featured-StudioBinder-Compressed.jpg","photo.jpg"]}]
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 144 KiB |
@@ -25,6 +25,9 @@ export default class Photo extends Vue {
|
|||||||
@Prop({required: true})
|
@Prop({required: true})
|
||||||
public readonly album!: IAlbum;
|
public readonly album!: IAlbum;
|
||||||
|
|
||||||
|
@Prop({default: false})
|
||||||
|
public readonly t360!: boolean;
|
||||||
|
|
||||||
@Ref('element') public readonly element!: HTMLElement;
|
@Ref('element') public readonly element!: HTMLElement;
|
||||||
|
|
||||||
public height: string = '10px';
|
public height: string = '10px';
|
||||||
@@ -45,8 +48,9 @@ export default class Photo extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get photoStyle() {
|
get photoStyle() {
|
||||||
|
const folder = this.t360 ? "360_photos" : "photos";
|
||||||
return {
|
return {
|
||||||
'background-image': `url('/pictures/albums/${this.album.folderName}/photos/${this.file}')`
|
'background-image': `url('/pictures/albums/${this.album.folderName}/${folder}/${this.file}')`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,8 +61,12 @@ export default class Photo extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClick() {
|
onClick() {
|
||||||
|
if (this.t360) {
|
||||||
|
this.$emit('clickPhoto', this.album.files_360.indexOf(this.file));
|
||||||
|
} else {
|
||||||
this.$emit('clickPhoto', this.album.files.indexOf(this.file));
|
this.$emit('clickPhoto', this.album.files.indexOf(this.file));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.updateHeight();
|
this.updateHeight();
|
||||||
|
|||||||
1
src/types/vuejs-vr.d.ts
vendored
Normal file
1
src/types/vuejs-vr.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
declare module 'vuejs-vr';
|
||||||
@@ -9,6 +9,11 @@
|
|||||||
<Photo v-for="file in filesToShow" :key="file" :file="file" :album="album"
|
<Photo v-for="file in filesToShow" :key="file" :file="file" :album="album"
|
||||||
@clickPhoto="clickPhoto"></Photo>
|
@clickPhoto="clickPhoto"></Photo>
|
||||||
</div>
|
</div>
|
||||||
|
<span>360*</span>
|
||||||
|
<div class="photos360" v-if="album !== null">
|
||||||
|
<Photo v-for="file in filesToShow360" :key="file" :file="file" :album="album"
|
||||||
|
@clickPhoto="clickPhoto360" :t360="true"></Photo>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<vue-gallery v-if="album !== null"
|
<vue-gallery v-if="album !== null"
|
||||||
:options="options"
|
:options="options"
|
||||||
@@ -16,6 +21,14 @@
|
|||||||
:index="index"
|
:index="index"
|
||||||
@close="index = null">
|
@close="index = null">
|
||||||
</vue-gallery>
|
</vue-gallery>
|
||||||
|
<div class="pano-wrapper" v-if="index360 !== null">
|
||||||
|
<div class="pano-container">
|
||||||
|
<pano :source="source360"></pano>
|
||||||
|
</div>
|
||||||
|
<div class="pano-button pano-prev" @click="prev360">‹</div>
|
||||||
|
<div class="pano-button pano-next" @click="next360">›</div>
|
||||||
|
<div class="pano-button pano-close" @click="index360 = null">×</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -25,6 +38,8 @@ import { Vue, Component, Prop, Watch, Ref } from 'vue-property-decorator';
|
|||||||
|
|
||||||
import VueGallery from 'vue-gallery';
|
import VueGallery from 'vue-gallery';
|
||||||
|
|
||||||
|
import { Pano } from 'vuejs-vr';
|
||||||
|
|
||||||
import { StoreType } from '@/store';
|
import { StoreType } from '@/store';
|
||||||
import { IAlbum } from '@/store/albums/state';
|
import { IAlbum } from '@/store/albums/state';
|
||||||
|
|
||||||
@@ -38,13 +53,18 @@ import Photo from '@/components/Photo.vue';
|
|||||||
LeftBlock,
|
LeftBlock,
|
||||||
Photo,
|
Photo,
|
||||||
VueGallery,
|
VueGallery,
|
||||||
|
Pano,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class AlbumPage extends Vue {
|
export default class AlbumPage extends Vue {
|
||||||
public filesToShow: string[] = [];
|
public filesToShow: string[] = [];
|
||||||
|
|
||||||
|
public filesToShow360: string[] = [];
|
||||||
|
|
||||||
public index: number | null = null;
|
public index: number | null = null;
|
||||||
|
|
||||||
|
public index360: number | null = null;
|
||||||
|
|
||||||
public options: object = {};
|
public options: object = {};
|
||||||
|
|
||||||
get album(): IAlbum | null {
|
get album(): IAlbum | null {
|
||||||
@@ -98,7 +118,11 @@ export default class AlbumPage extends Vue {
|
|||||||
|
|
||||||
this.album.files.forEach((item, index) => {
|
this.album.files.forEach((item, index) => {
|
||||||
setTimeout(() => this.filesToShow.push(item), 300 * index);
|
setTimeout(() => this.filesToShow.push(item), 300 * index);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
this.album.files_360.forEach((item, index) => {
|
||||||
|
setTimeout(() => this.filesToShow360.push(item), 300 * index);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch('album')
|
@Watch('album')
|
||||||
@@ -110,6 +134,38 @@ export default class AlbumPage extends Vue {
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clickPhoto360(index: number) {
|
||||||
|
this.index360 = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
get source360() {
|
||||||
|
if (this.index360 === null)
|
||||||
|
return '';
|
||||||
|
|
||||||
|
const filename = this.album!.files_360[this.index360];
|
||||||
|
return `/pictures/albums/${this.album!.folderName}/360_photos/${filename}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
next360() {
|
||||||
|
const newIndex = this.index360! + 1;
|
||||||
|
|
||||||
|
if (newIndex >= this.album!.files_360.length) {
|
||||||
|
this.index360 = 0;
|
||||||
|
} else {
|
||||||
|
this.index360 = newIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prev360() {
|
||||||
|
const newIndex = this.index360! - 1;
|
||||||
|
|
||||||
|
if (newIndex! < 0) {
|
||||||
|
this.index360 = this.album!.files_360.length - 1;
|
||||||
|
} else {
|
||||||
|
this.index360 = newIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.updateFiles();
|
this.updateFiles();
|
||||||
|
|
||||||
@@ -124,6 +180,47 @@ export default class AlbumPage extends Vue {
|
|||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pano-wrapper {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 200;
|
||||||
|
background-color: rgba(0, 0, 0, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pano-container {
|
||||||
|
margin-top: 5%;
|
||||||
|
margin-left: 5%;
|
||||||
|
width: 90%;
|
||||||
|
height: 85%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pano-button {
|
||||||
|
position: fixed;
|
||||||
|
|
||||||
|
padding: 1em;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pano-prev {
|
||||||
|
top: 45%;
|
||||||
|
left: -3%;
|
||||||
|
font-size: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pano-next {
|
||||||
|
top: 45%;
|
||||||
|
right: -3%;
|
||||||
|
font-size: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pano-close {
|
||||||
|
top: -3%;
|
||||||
|
right: -1%;
|
||||||
|
font-size: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 961px) {
|
@media (max-width: 961px) {
|
||||||
.photos-wrapper {
|
.photos-wrapper {
|
||||||
width: calc(100vw);
|
width: calc(100vw);
|
||||||
@@ -137,12 +234,11 @@ export default class AlbumPage extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.photos {
|
.photos, .photos360 {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Reference in New Issue
Block a user