Scrolling release actors, added custom scroll bars.

This commit is contained in:
DebaucheryLibrarian
2022-11-28 05:45:25 +01:00
parent 732fc98704
commit 00b54b414d
3 changed files with 116 additions and 17 deletions

View File

@@ -63,12 +63,19 @@
</div>
<div class="row associations">
<ul class="actors nolist">
<ul
ref="actors"
class="actors nolist noselect bar-inline"
@mousedown.prevent="startActorsScroll"
>
<li
v-for="actor in release.actors"
:key="actor.id"
>
<Actor :actor="actor" />
<Actor
:actor="actor"
:has-scrolled="actorsHasScrolled"
/>
</li>
</ul>
</div>
@@ -308,6 +315,29 @@ async function unstashScene(stashId) {
});
}
function startActorsScroll(event) {
event.preventDefault();
this.$refs.actors.addEventListener('mousemove', this.scrollActors);
document.addEventListener('mouseup', this.endActorsScroll);
this.actorsScrollStart = { mouse: event.clientX, scroll: this.$refs.actors.scrollLeft };
this.actorsHasScrolled = false;
}
function scrollActors(event) {
this.$refs.actors.scrollLeft = this.actorsScrollStart.scroll + this.actorsScrollStart.mouse - event.clientX;
if (Math.abs(this.actorsScrollStart.mouse - event.clientX) > 10) {
this.actorsHasScrolled = true;
}
}
function endActorsScroll() {
this.$refs.actors.removeEventListener('mousemove', this.scrollActors);
document.removeEventListener('mouseup', this.endActorsScroll);
}
function me() {
return this.$store.state.auth.user;
}
@@ -358,6 +388,10 @@ function showAlbum() {
return (this.release.photos?.length > 0 || this.release.scenesPhotos?.length > 0) && this.$route.hash === '#album';
}
async function mounted() {
this.fetchRelease();
}
export default {
components: {
Actor,
@@ -376,6 +410,8 @@ export default {
summary: null,
summaryCopied: false,
stashedBy: [],
actorsScrollStart: 0,
actorsHasScrolled: false,
hasClipboard: !!navigator?.clipboard?.writeText,
};
},
@@ -388,12 +424,15 @@ export default {
watch: {
$route: fetchRelease,
},
mounted: fetchRelease,
mounted,
methods: {
copySummary,
endActorsScroll,
fetchRelease,
scrollActors,
selectSummary,
setSummary,
fetchRelease,
startActorsScroll,
stashScene,
unstashScene,
},
@@ -504,11 +543,16 @@ export default {
}
.actors {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
grid-gap: .5rem;
flex-grow: 1;
flex-wrap: wrap;
display: block;
padding-bottom: .25rem;
overflow-x: auto;
white-space: nowrap;
.actor {
width: 10rem;
margin-right: .25rem;
user-select: none;
}
}
.movies {