@@ -2,15 +2,11 @@ import GM_addStyle from "../../../../../../polyfill/GM_addStyle";
22import cc from 'classcat'
33import { ACTION_GRID_MAP , DirectionMode } from "../../constant" ;
44import useDirectionMode from "../../hooks/useDirectionMode" ;
5- import { defineComponent , onMounted , unref , h , ref , watch } from "../../vue" ;
5+ import { defineComponent , onMounted , unref , h } from "../../vue" ;
66import css from './style.css'
7+ import WhitePage from '../WhitePage' ;
78import useMouseGrid from "../../hooks/useMouseGrid" ;
8- import ImageGroup from "../ImageGroup" ;
9- import useTtbColumn from "../../hooks/useTtbColumn" ;
109import useImageList from "../../hooks/useImageList" ;
11- import useImageWidth from "../../hooks/useImageWidth" ;
12- import debounce from "../../../../utils/debounce" ;
13- import { useWindowSize } from "../../hooks/useWindowSize" ;
1410
1511export default defineComponent ( {
1612 setup ( ) {
@@ -20,31 +16,6 @@ export default defineComponent({
2016 const [ imagesRef ] = useImageList ( )
2117 const [ directionModeRef ] = useDirectionMode ( )
2218 const [ mouseGridRef ] = useMouseGrid ( )
23- const [ imageWidthRef ] = useImageWidth ( )
24- const [ ttbColumnRef ] = useTtbColumn ( )
25- const { width : windowWidthRef } = useWindowSize ( )
26-
27- const imageGroupHeightRef = ref ( 0 )
28- const imageGroupRef = ref < InstanceType < typeof ImageGroup > | null > ( null )
29- const refreshImageGroupHeight = debounce ( ( ) => {
30- const list = Array . from < HTMLElement > ( unref ( imageGroupRef ) ?. $el . children ?? [ ] )
31- const height = list . reduce ( ( acc , child ) => acc + child . clientHeight , 0 )
32- imageGroupHeightRef . value = height
33- } , 50 )
34- watch (
35- [
36- imagesRef ,
37- directionModeRef ,
38- ttbColumnRef ,
39- imageGroupRef ,
40- imageWidthRef ,
41- windowWidthRef ,
42- ] , ( ) => {
43- if ( DirectionMode . TTB !== unref ( directionModeRef ) ) return
44- refreshImageGroupHeight ( )
45- }
46- )
47-
4819 return ( ) => h (
4920 'div' ,
5021 {
@@ -60,60 +31,26 @@ export default defineComponent({
6031 {
6132 class : cc ( [
6233 'direction-wrapper' ,
63- 'max-h-(--body-height) ' ,
64- 'flex flex-row flex-wrap ' ,
65- 'overflow-x-hidden overflow-y-auto ' ,
34+ 'w-dvw ' ,
35+ 'flex flex-wrap justify-center ' ,
36+ 'snap-mandatory ltr:snap-y rtl:snap-y ' ,
6637 ] ) ,
6738 } ,
68- [
69- h (
70- ImageGroup ,
71- {
72- class : cc ( [
73- 'ltr:hidden rtl:hidden' ,
74- 'overflow-hidden' ,
75- {
76- 'hidden' : unref ( ttbColumnRef ) === 1 || unref ( ttbColumnRef ) === 2 ,
77- 'basic-[33%]' : unref ( ttbColumnRef ) === 3 ,
78- }
79- ] ) ,
80- images : unref ( imagesRef ) ,
81- style : `height: ${ unref ( imageGroupHeightRef ) } px` ,
82- } ,
83- ) ,
84- h (
85- ImageGroup ,
86- {
87- class : cc ( [
88- 'ltr:hidden rtl:hidden' ,
89- 'overflow-hidden' ,
90- {
91- 'hidden' : unref ( ttbColumnRef ) === 1 ,
92- 'basic-[50%]' : unref ( ttbColumnRef ) === 2 ,
93- 'basic-[33%]' : unref ( ttbColumnRef ) === 3 ,
94- } ,
95- ] ) ,
96- images : unref ( imagesRef ) ,
97- style : `height: ${ unref ( imageGroupHeightRef ) } px` ,
98- } ,
99- ) ,
100- h (
101- ImageGroup ,
39+ unref ( imagesRef )
40+ . map ( ( { component, props } ) => h (
41+ 'div' ,
10242 {
10343 class : cc ( [
104- {
105- 'w-dvw' : DirectionMode . TTB !== unref ( directionModeRef ) ,
106- 'flex' : unref ( ttbColumnRef ) === 1 ,
107- 'basic-[50%]' : DirectionMode . TTB === unref ( directionModeRef ) && unref ( ttbColumnRef ) === 2 ,
108- 'basic-[33%]' : DirectionMode . TTB === unref ( directionModeRef ) && unref ( ttbColumnRef ) === 3 ,
109- } ,
44+ 'wrapper' ,
45+ 'ltr:h-(--body-height) rtl:h-(--body-height)' ,
46+ 'ltr:snap-center rtl:snap-center' ,
47+ 'flex' ,
48+ { 'hidden' : unref ( directionModeRef ) === DirectionMode . TTB && component === WhitePage } ,
11049 ] ) ,
111- images : unref ( imagesRef ) ,
112- ref : imageGroupRef ,
50+ ...Object . fromEntries ( Object . entries ( props ) . filter ( ( [ k ] ) => k . startsWith ( 'data-' ) ) )
11351 } ,
114- ) ,
115- ] ,
116- )
52+ [ h ( component , { ...props } ) ] ,
53+ ) ) ) ,
11754 ] ,
11855 )
11956 } ,
0 commit comments