File tree 4 files changed +86
-2
lines changed
4 files changed +86
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ import './components/alpine/dialog';
44
44
import './components/alpine/dislikeButton' ;
45
45
import './components/alpine/likeButton' ;
46
46
import './components/alpine/livewireDialog' ;
47
+ import './components/alpine/posterRow' ;
47
48
import './components/alpine/smallBookmarkButton' ;
48
49
import './components/alpine/tabs' ;
49
50
import './components/alpine/toggle' ;
Original file line number Diff line number Diff line change
1
+ document . addEventListener ( 'alpine:init' , ( ) => {
2
+ Alpine . data ( 'posterRow' , ( ) => ( {
3
+ tab : null ,
4
+ init ( ) {
5
+ this . tab = this . $root . dataset . defaultTab ;
6
+ } ,
7
+ getPosterRow ( ) {
8
+ let panel = this . $el . closest ( '.panelV2' ) ;
9
+ let posterRows = panel . querySelectorAll ( '[x-ref="posters"]' ) ;
10
+
11
+ let posterRow = [ ...posterRows ] . find ( ( el ) => el . checkVisibility ( ) ) ;
12
+
13
+ return posterRow ;
14
+ } ,
15
+ scrollLeft : {
16
+ [ 'x-on:click.prevent' ] ( ) {
17
+ let posterRow = this . getPosterRow ( ) ;
18
+
19
+ let scrollBy = posterRow . offsetWidth / 2 ;
20
+ let currentScroll = posterRow . scrollLeft ;
21
+ let maxScroll = posterRow . scrollWidth - posterRow . offsetWidth ;
22
+
23
+ if ( currentScroll == 0 ) {
24
+ posterRow . scrollTo ( {
25
+ left : maxScroll ,
26
+ behavior : 'smooth' ,
27
+ } ) ;
28
+ } else if ( currentScroll < scrollBy ) {
29
+ posterRow . scrollTo ( {
30
+ left : 0 ,
31
+ behavior : 'smooth' ,
32
+ } ) ;
33
+ } else {
34
+ posterRow . scrollBy ( {
35
+ left : - 1 * scrollBy ,
36
+ behavior : 'smooth' ,
37
+ } ) ;
38
+ }
39
+ } ,
40
+ } ,
41
+ scrollRight : {
42
+ [ 'x-on:click.prevent' ] ( ) {
43
+ let posterRow = this . getPosterRow ( ) ;
44
+
45
+ let scrollBy = posterRow . offsetWidth / 2 ;
46
+ let currentScroll = posterRow . scrollLeft ;
47
+ let maxScroll = posterRow . scrollWidth - posterRow . offsetWidth ;
48
+ let remainingScroll = maxScroll - currentScroll ;
49
+
50
+ if ( remainingScroll == 0 ) {
51
+ posterRow . scrollTo ( {
52
+ left : 0 ,
53
+ behavior : 'smooth' ,
54
+ } ) ;
55
+ } else if ( remainingScroll < scrollBy ) {
56
+ posterRow . scrollTo ( {
57
+ left : maxScroll ,
58
+ behavior : 'smooth' ,
59
+ } ) ;
60
+ } else {
61
+ posterRow . scrollBy ( {
62
+ left : scrollBy ,
63
+ behavior : 'smooth' ,
64
+ } ) ;
65
+ }
66
+ } ,
67
+ } ,
68
+ } ) ) ;
69
+ } ) ;
Original file line number Diff line number Diff line change 1
1
<section class =" panelV2" x-data =" tabs" data-default-tab =" recommendations" id =" tab_wrapper" >
2
- <h2 class =" panel__heading" >Relations</h2 >
2
+ <header class =" panel__header" >
3
+ <h2 class =" panel__heading" >Relations</h2 >
4
+ <div class =" panel__actions" x-data =" posterRow" >
5
+ <div class =" panel__action" >
6
+ <button class =" form__standard-icon-button" x-bind =" scrollLeft" >
7
+ <i class =" {{ \config (' other.font-awesome' ) } } fa-angle-left" ></i >
8
+ </button >
9
+ </div >
10
+ <div class =" panel__action" >
11
+ <button class =" form__standard-icon-button" x-bind =" scrollRight" >
12
+ <i class =" {{ \config (' other.font-awesome' ) } } fa-angle-right" ></i >
13
+ </button >
14
+ </div >
15
+ </div >
16
+ </header >
3
17
<menu class =" panel__tabs" >
4
18
<li class =" panel__tab" x-bind =" tabButton" data-tab =" recommendations" >Recommendations</li >
5
19
<li class =" panel__tab" x-bind =" tabButton" data-tab =" collection" >Collection</li >
Original file line number Diff line number Diff line change 1
1
<div class =" panel__body" >
2
- <section class =" recommendations" style =" max-height : 330px !important " >
2
+ <section class =" recommendations" style =" max-height : 330px !important " x-ref = " posters " >
3
3
@switch (true )
4
4
@case ($torrent -> category -> movie_meta )
5
5
@forelse ($meta -> recommendedMovies ?? [] as $movie )
You can’t perform that action at this time.
0 commit comments