Restoring scroll position when going from home to scene to home.
This commit is contained in:
parent
f5b60ac743
commit
48b1f15070
|
@ -5,6 +5,7 @@
|
||||||
<div class="content-inner">
|
<div class="content-inner">
|
||||||
<Releases
|
<Releases
|
||||||
:releases="releases"
|
:releases="releases"
|
||||||
|
referer="home"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,6 +25,13 @@ async function mounted() {
|
||||||
await this.fetchReleases();
|
await this.fetchReleases();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updated() {
|
||||||
|
if (this.from.name === 'scene' && this.from.hash === '#home') {
|
||||||
|
const releaseTile = document.querySelector(`#scene-${this.from.params.releaseId}`);
|
||||||
|
if (releaseTile) releaseTile.scrollIntoView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
FilterBar,
|
FilterBar,
|
||||||
|
@ -34,8 +42,13 @@ export default {
|
||||||
releases: [],
|
releases: [],
|
||||||
networks: [],
|
networks: [],
|
||||||
pageTitle: null,
|
pageTitle: null,
|
||||||
|
from: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
beforeRouteEnter(to, from, next) {
|
||||||
|
next(vm => vm.$set(vm, 'from', from));
|
||||||
|
},
|
||||||
|
updated,
|
||||||
mounted,
|
mounted,
|
||||||
methods: {
|
methods: {
|
||||||
fetchReleases,
|
fetchReleases,
|
||||||
|
|
|
@ -10,7 +10,10 @@
|
||||||
v-for="release in releases"
|
v-for="release in releases"
|
||||||
:key="`release-${release.id}`"
|
:key="`release-${release.id}`"
|
||||||
>
|
>
|
||||||
<ReleaseTile :release="release" />
|
<ReleaseTile
|
||||||
|
:release="release"
|
||||||
|
:referer="referer"
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -46,6 +49,10 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
referer: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
range,
|
range,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
:id="`${release.type}-${release.id}`"
|
||||||
|
:class="{ [release.type]: true }"
|
||||||
class="tile"
|
class="tile"
|
||||||
:class="{ movie: release.type === 'movie' }"
|
|
||||||
>
|
>
|
||||||
<span class="poster">
|
<span class="poster">
|
||||||
<span class="details">
|
<span class="details">
|
||||||
|
@ -47,10 +48,8 @@
|
||||||
>{{ `(${formatDate(release.dateAdded, 'MMM D, YYYY')})` }}</a>
|
>{{ `(${formatDate(release.dateAdded, 'MMM D, YYYY')})` }}</a>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<a
|
<router-link
|
||||||
:href="`/${release.type || 'scene'}/${release.id}/${release.slug || ''}`"
|
:to="{ name: release.type || 'scene', params: { releaseId: release.id, releaseSlug: release.slug }, ...(referer && { hash: `#${referer}` }) }"
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
class="link"
|
class="link"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
|
@ -72,14 +71,12 @@
|
||||||
:title="release.title"
|
:title="release.title"
|
||||||
class="thumbnail"
|
class="thumbnail"
|
||||||
>No thumbnail available</div>
|
>No thumbnail available</div>
|
||||||
</a>
|
</router-link>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<a
|
<router-link
|
||||||
:href="`/${release.type || 'scene'}/${release.id}`"
|
:to="{ name: release.type || 'scene', params: { releaseId: release.id, releaseSlug: release.slug }, ...(referer && { hash: `#${referer}` }) }"
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
class="row link"
|
class="row link"
|
||||||
>
|
>
|
||||||
<h3
|
<h3
|
||||||
|
@ -92,7 +89,7 @@
|
||||||
icon="film"
|
icon="film"
|
||||||
/>{{ release.title }}
|
/>{{ release.title }}
|
||||||
</h3>
|
</h3>
|
||||||
</a>
|
</router-link>
|
||||||
|
|
||||||
<span class="row">
|
<span class="row">
|
||||||
<ul class="actors nolist">
|
<ul class="actors nolist">
|
||||||
|
@ -135,6 +132,10 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
referer: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -113,6 +113,7 @@ const releaseFields = `
|
||||||
title
|
title
|
||||||
date
|
date
|
||||||
slug
|
slug
|
||||||
|
type
|
||||||
createdAt
|
createdAt
|
||||||
url
|
url
|
||||||
${releaseActorsFragment}
|
${releaseActorsFragment}
|
||||||
|
|
|
@ -17,11 +17,15 @@ Vue.use(VueRouter);
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
|
redirect: { name: 'home' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/home',
|
||||||
component: Home,
|
component: Home,
|
||||||
name: 'home',
|
name: 'home',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/scene/:releaseId/:releaseTitle?',
|
path: '/scene/:releaseId/:releaseSlug?',
|
||||||
component: Release,
|
component: Release,
|
||||||
name: 'scene',
|
name: 'scene',
|
||||||
},
|
},
|
||||||
|
@ -74,6 +78,9 @@ const routes = [
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
routes,
|
routes,
|
||||||
|
afterEach(to, from) {
|
||||||
|
console.log(to, from);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
|
@ -326,7 +326,8 @@ exports.up = knex => Promise.resolve()
|
||||||
.references('id')
|
.references('id')
|
||||||
.inTable('studios');
|
.inTable('studios');
|
||||||
|
|
||||||
table.string('type', 10);
|
table.string('type', 10)
|
||||||
|
.defaultTo('scene');
|
||||||
|
|
||||||
table.string('shoot_id');
|
table.string('shoot_id');
|
||||||
table.string('entry_id');
|
table.string('entry_id');
|
||||||
|
|
Loading…
Reference in New Issue