@@ -16,6 +16,7 @@ import type { PosterItem } from '~/models/poster.model';
16
16
import ListItemPanel from ' ~/components/common/list/ListItemPanel.vue' ;
17
17
import PosterComponent from ' ~/components/common/poster/PosterComponent.vue' ;
18
18
import { type ListScrollItem , ListScrollItemType } from ' ~/models/list-scroll.model' ;
19
+ import { useAppStateStoreRefs } from ' ~/stores/app-state.store' ;
19
20
import { useI18n } from ' ~/utils/i18n.utils' ;
20
21
21
22
const props = defineProps ({
@@ -119,9 +120,11 @@ const i18n = useI18n('list', 'item');
119
120
const { item, noHeader, nextHasHeader, poster, hideDate, scrollIntoView, height, color } =
120
121
toRefs (props );
121
122
123
+ const { root } = useAppStateStoreRefs ();
122
124
const itemRef = ref <
123
125
Omit < InstanceType < typeof NTimelineItem > , ' $el' > & { $el ?: HTMLDivElement }
124
126
> ();
127
+ const buttons = ref <InstanceType <typeof NButtonGroup > & { $el? : HTMLDivElement }>();
125
128
126
129
const focusin = ref (false );
127
130
const focusTimeout = ref <ReturnType <typeof setTimeout >>();
@@ -138,11 +141,26 @@ const toggleFocusin = (focus: boolean) => {
138
141
139
142
const open = ref (false );
140
143
const dragged = ref (0 );
144
+
145
+ const hoverTimeout = ref <ReturnType <typeof setTimeout >>();
146
+ const overOpen = (e : MouseEvent ) => {
147
+ clearTimeout (hoverTimeout .value );
148
+ if (open .value ) return ;
149
+ if (e .shiftKey || e .ctrlKey || e .shiftKey || e .metaKey ) return ;
150
+ const offsetWidth = (root .value ?.clientWidth ?? window .innerWidth ) - e .clientX ;
151
+ if (offsetWidth > 50 ) return ;
152
+ hoverTimeout .value = setTimeout (() => {
153
+ open .value = true ;
154
+ }, 100 );
155
+ };
156
+
141
157
const onHover = (_event : MouseEvent , _hover : boolean ) => {
142
158
emit (' onHover' , { item: item ?.value , hover: _hover });
143
159
itemRef .value ?.$el ?.focus ({ preventScroll: true });
144
160
open .value = _hover && (_event .altKey || _event .ctrlKey );
145
161
if (! _hover ) dragged .value = 0 ;
162
+ if (! _hover ) return clearTimeout (hoverTimeout .value );
163
+ return overOpen (_event );
146
164
};
147
165
148
166
const touchStart = ref <TouchEvent >();
@@ -153,7 +171,6 @@ const onTouchStart = (e: TouchEvent) => {
153
171
initialDrag .value = dragged .value ;
154
172
};
155
173
156
- const buttons = ref <InstanceType <typeof NButtonGroup > & { $el? : HTMLDivElement }>();
157
174
const onToucheMove = (e : TouchEvent ) => {
158
175
const _width = buttons .value ?.$el ?.clientWidth ;
159
176
if (! _width ) return ;
@@ -238,6 +255,7 @@ const onClick = (e: MouseEvent | KeyboardEvent) =>
238
255
@keydown.ctrl =" open = !open"
239
256
@mouseenter.passive =" e => onHover(e, true)"
240
257
@mouseleave.passive =" e => onHover(e, false)"
258
+ @mousemove.passive =" overOpen"
241
259
@touchstart.passive =" onTouchStart"
242
260
@touchmove.passive =" onToucheMove"
243
261
@touchend.passive =" onTouchEnd"
0 commit comments